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
Element
s, the loader will search a Path
with the following rules.
- If the
Path
is a file, it will assume that the entireElement
is in one file. - If thd
Path
is 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
Element
will 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
Element
metadata 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 String
The name of the file which represents a particularElement
'sAttributes
.static final String
The Classpath directory name.static final String
The environment variable for the element path.static final String
The jar file extension.static final String
The library directory name. -
Method Summary
Modifier and TypeMethodDescriptionload
(MutableElementRegistry registry) Loads allElement
into 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 ElementPathLoader
Creates a new instance of theElementPathLoader
using 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 theProperties
format when defining theAttributes
. This allows for the separation of code and configuration at deployment time.- See Also:
-
-
Method Details
-
load
Loads allElement
into the supplied registry, using the globally configured ELEMENTPATH as the source location.- Parameters:
registry
- the registry to receive the loadedElement
s
-
load
-
load
-
newDefaultInstance
Creates a new instance of theElementPathLoader
using the system default SPI.- Returns:
- new
ElementPathLoader
-