Skip to content

ExecutorLibrarySourceProvider using static source-based references to FHIRHelper #6

Description

@MikeRileyGTRI

ExecutorLibrarySourceProvider uses this code to search for libraries to load at runtime.
@Override public InputStream getLibrarySource(VersionedIdentifier versionedIdentifier) { Path path = Paths.get("src/main/resources").toAbsolutePath(); File source = new File(path.resolve(versionedIdentifier.getId() + "-" + versionedIdentifier.getVersion() + ".cql").toString());

try { return new FileInputStream(source); } catch (FileNotFoundException e) { throw new IllegalArgumentException("Cannot find library source " + versionedIdentifier.getId()); } }

The Paths base directory is FileSystem-dependent however, and doesn't translate over well. Deploying the war to tomcat, for example, breaks the library loading.

The Paths documentation itself provides a proposed solution

The Path is obtained by invoking the getPath method of the default FileSystem. Note that while this method is very convenient, using it will imply an assumed reference to the default FileSystem and limit the utility of the calling code. Hence it should not be used in library code intended for flexible reuse. A more flexible alternative is to use an existing Path instance as an anchor, such as:

Path dir = ... Path path = dir.resolve("file");

Paths Documentation Here

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions