Package dev.getelements.elements.sdk
Interface ElementPathLoader
- All Known Implementing Classes:
DirectoryElementPathLoader
public interface ElementPathLoader
Used to load
Element instances from local paths on disk. As a single Element may span multiple sources for
executable code, this provides loading semantics for code on disk in a structured manner. When loading
Elements, the loader will search a Path with the following rules.
- If the
Pathis a file, it will assume that the entireElementis in one file. - If thd
Pathis a directory, it will assume all files in the directory make up theElement - For each directory in the
Path, it will create a new subordinateElementRegistry - Each loaded
Elementwill follow the hierarchy of the directory. - Empty directories, or directories containing directories will be skipped.
- Aside from those specified (lib and classpath), directory names are irrelevant. All
Elementmetadata will come from the annotations.
Element.
- dev.getelements.element.attributes.properties - custom attributes for the Element
- lib - every file is assumed to be a jar file
- classpath - every file inside this directory is added to the classpath
- foo - com.example.foo
- foo/a - com.example.foo.a
- foo/b - com.example.foo.b
- bar - com.example.bar
- bar/a - com.example.bar.a
- bar/b - com.example.bar.b
ElementRegistry instances and Element instances chained as follows:
- Root
- Root -> Foo
- Root -> Foo -> A
- Root -> Foo -> B
- Root
- Root -> Bar
- Root -> Bar -> A
- Root -> Bar -> B
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe name of the file which represents a particularElement'sAttributes.static final StringThe Classpath directory name.static final StringThe environment variable for the element path.static final StringThe jar file extension.static final StringThe library directory name. -
Method Summary
Modifier and TypeMethodDescriptionload(MutableElementRegistry registry) Loads allElementinto the supplied registry, using the globally configured ELEMENTPATH as the source location.load(MutableElementRegistry registry, Path path) load(MutableElementRegistry registry, Path path, ClassLoader baseClassLoader) static ElementPathLoaderCreates a new instance of theElementPathLoaderusing the system default SPI.
-
Field Details
-
JAR_EXTENSION
The jar file extension.- See Also:
-
ELEMENT_PATH_ENV
The environment variable for the element path.- See Also:
-
LIB_DIR
The library directory name.- See Also:
-
CLASSPATH_DIR
The Classpath directory name.- See Also:
-
ATTRIBUTES_PROPERTIES_FILE
The name of the file which represents a particularElement'sAttributes. Uses thePropertiesformat when defining theAttributes. This allows for the separation of code and configuration at deployment time.- See Also:
-
-
Method Details
-
load
Loads allElementinto the supplied registry, using the globally configured ELEMENTPATH as the source location.- Parameters:
registry- the registry to receive the loadedElements
-
load
-
load
-
newDefaultInstance
Creates a new instance of theElementPathLoaderusing the system default SPI.- Returns:
- new
ElementPathLoader
-