Package dev.getelements.elements.sdk.spi
Class DefaultElementLoaderFactory
java.lang.Object
dev.getelements.elements.sdk.spi.DefaultElementLoaderFactory
- All Implemented Interfaces:
ElementLoaderFactory
-
Nested Class Summary
Nested classes/interfaces inherited from interface dev.getelements.elements.sdk.ElementLoaderFactory
ElementLoaderFactory.ClassLoaderConstructor
-
Constructor Summary
Constructors -
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.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 specifiedgetIsolatedLoader
(Attributes attributes, ClassLoader baseClassLoader, ElementLoaderFactory.ClassLoaderConstructor classLoaderCtor, Predicate<ElementDefinitionRecord> selector) Scans the classpath, using the suppliedClassLoader
, forElement
instances.getSharedLoader
(ElementRecord elementRecord, ServiceLocator serviceLocator) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface dev.getelements.elements.sdk.ElementLoaderFactory
getIsolatedLoader
-
Constructor Details
-
DefaultElementLoaderFactory
public DefaultElementLoaderFactory()
-
-
Method Details
-
getIsolatedLoader
public ElementLoader getIsolatedLoader(Attributes attributes, ClassLoader baseClassLoader, ElementLoaderFactory.ClassLoaderConstructor classLoaderCtor, Predicate<ElementDefinitionRecord> selector) Description copied from interface:ElementLoaderFactory
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
- Specified by:
getIsolatedLoader
in interfaceElementLoaderFactory
- 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
public Optional<ElementDefinitionRecord> findElementDefinitionRecord(ClassLoader classLoader, Attributes attributes, Predicate<ElementDefinitionRecord> selector) Description copied from interface:ElementLoaderFactory
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.- Specified by:
findElementDefinitionRecord
in interfaceElementLoaderFactory
- Parameters:
classLoader
-attributes
- the attributes to useselector
- aPredicate
to select a singleElementDefinitionRecord
to load- Returns:
- the
ElementRecord
-
getElementRecordFromPackage
Description copied from interface:ElementLoaderFactory
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.- Specified by:
getElementRecordFromPackage
in interfaceElementLoaderFactory
- Parameters:
attributes
- the attributes to useaPackage
- the package to scan- Returns:
- the
ElementRecord
-
getExposedServices
Description copied from interface:ElementLoaderFactory
Scans the suppliedPackage
for specified- Specified by:
getExposedServices
in interfaceElementLoaderFactory
- Parameters:
aPackage
- a package to scan- Returns:
- a
Stream
of allElementServiceRecord
s exposed by theElement
-