Package dev.getelements.elements.sdk
Interface ElementLoaderFactory
- All Known Implementing Classes:
DefaultElementLoaderFactory
public interface ElementLoaderFactory
The
ElementLoader
factory. This loads an instance of a Element
on-demand.-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionfindElementDefinitionRecord
(ClassLoader classLoader, Attributes attributes, Predicate<ElementDefinitionRecord> selector) Finds theElement
name, this will find theElementRecord
associated with it, throwing an exception if it is unable to find theElementDefinition
annotation.static ElementLoaderFactory
Gets a defaultElementLoaderFactory
via theServiceLoader
interface.getElementRecordFromPackage
(Attributes attributes, Package aPackage) Given thePackage
, this will find theElementRecord
associated with it, throwing an exception if it is unable to find theElementDefinition
annotation.getExposedServices
(Package aPackage) Scans the suppliedPackage
for specifieddefault ElementLoader
getIsolatedLoader
(Attributes attributes, ClassLoader baseClassLoader, ElementLoaderFactory.ClassLoaderConstructor classLoaderCtor) Scans the classpath, using the suppliedClassLoader
, forElement
instances.getIsolatedLoader
(Attributes attributes, ClassLoader baseClassLoader, ElementLoaderFactory.ClassLoaderConstructor classLoaderCtor, Predicate<ElementDefinitionRecord> selector) Scans the classpath, using the suppliedClassLoader
, forElement
instances.getSharedLoader
(ElementRecord elementRecord, ServiceLocator serviceLocator)
-
Method Details
-
getIsolatedLoader
default ElementLoader getIsolatedLoader(Attributes attributes, ClassLoader baseClassLoader, ElementLoaderFactory.ClassLoaderConstructor classLoaderCtor) Scans the classpath, using the supplied
ClassLoader
, forElement
instances. If the element is found, then this returns an instance ofElementLoader
which can be used to instantiate theElement
. With the suppliedClassLoader
(from the suppliedFunction
there must exist exactly oneElementDefinition
.Results in a
ElementType.ISOLATED_CLASSPATH
Element
- Parameters:
attributes
- the attributes to usebaseClassLoader
- the baseClassLoader
, this will be ultimately be the parent forElement
'sClassLoader
instance.classLoaderCtor
- theClassLoader
classloader- Returns:
- the
ElementLoader
-
getIsolatedLoader
ElementLoader getIsolatedLoader(Attributes attributes, ClassLoader baseClassLoader, ElementLoaderFactory.ClassLoaderConstructor classLoaderCtor, Predicate<ElementDefinitionRecord> selector) Scans the classpath, using the supplied
ClassLoader
, forElement
instances. If the element is found, then this returns an instance ofElementLoader
which can be used to instantiate theElement
. With the suppliedClassLoader
(from the suppliedFunction
there must exist exactly oneElementDefinition
.Results in a
ElementType.ISOLATED_CLASSPATH
Element
- Parameters:
attributes
- the attributes to usebaseClassLoader
- the baseClassLoader
, this will be ultimately be the parent forElement
'sClassLoader
instance.classLoaderCtor
- theClassLoader
classloaderselector
- aPredicate
to select a singleElementDefinitionRecord
to load- Returns:
- the
ElementLoader
-
findElementDefinitionRecord
Optional<ElementDefinitionRecord> findElementDefinitionRecord(ClassLoader classLoader, Attributes attributes, Predicate<ElementDefinitionRecord> selector) Finds theElement
name, this will find theElementRecord
associated with it, throwing an exception if it is unable to find theElementDefinition
annotation. Used in constructing shared elements.- Parameters:
classLoader
-attributes
- the attributes to useselector
- aPredicate
to select a singleElementDefinitionRecord
to load- Returns:
- the
ElementRecord
-
getElementRecordFromPackage
Given thePackage
, this will find theElementRecord
associated with it, throwing an exception if it is unable to find theElementDefinition
annotation. Used in constructing shared elements.- Parameters:
attributes
- the attributes to useaPackage
- the package to scan- Returns:
- the
ElementRecord
-
getExposedServices
Scans the suppliedPackage
for specified- Parameters:
aPackage
- a package to scan- Returns:
- a
Stream
of allElementServiceRecord
s exposed by theElement
-
getDefault
Gets a defaultElementLoaderFactory
via theServiceLoader
interface.- Returns:
- the
ElementLoaderFactory
-