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 theElementname, this will find theElementRecordassociated with it, throwing an exception if it is unable to find theElementDefinitionannotation.static ElementLoaderFactoryGets a defaultElementLoaderFactoryvia theServiceLoaderinterface.getElementRecordFromPackage(Attributes attributes, Package aPackage) Given thePackage, this will find theElementRecordassociated with it, throwing an exception if it is unable to find theElementDefinitionannotation.getExposedServices(Package aPackage) Scans the suppliedPackagefor specifieddefault ElementLoadergetIsolatedLoader(Attributes attributes, ClassLoader baseClassLoader, ElementLoaderFactory.ClassLoaderConstructor classLoaderCtor) Scans the classpath, using the suppliedClassLoader, forElementinstances.getIsolatedLoader(Attributes attributes, ClassLoader baseClassLoader, ElementLoaderFactory.ClassLoaderConstructor classLoaderCtor, Predicate<ElementDefinitionRecord> selector) Scans the classpath, using the suppliedClassLoader, forElementinstances.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, forElementinstances. If the element is found, then this returns an instance ofElementLoaderwhich can be used to instantiate theElement. With the suppliedClassLoader(from the suppliedFunctionthere must exist exactly oneElementDefinition.Results in a
ElementType.ISOLATED_CLASSPATHElement- Parameters:
attributes- the attributes to usebaseClassLoader- the baseClassLoader, this will be ultimately be the parent forElement'sClassLoaderinstance.classLoaderCtor- theClassLoaderclassloader- Returns:
- the
ElementLoader
-
getIsolatedLoader
ElementLoader getIsolatedLoader(Attributes attributes, ClassLoader baseClassLoader, ElementLoaderFactory.ClassLoaderConstructor classLoaderCtor, Predicate<ElementDefinitionRecord> selector) Scans the classpath, using the supplied
ClassLoader, forElementinstances. If the element is found, then this returns an instance ofElementLoaderwhich can be used to instantiate theElement. With the suppliedClassLoader(from the suppliedFunctionthere must exist exactly oneElementDefinition.Results in a
ElementType.ISOLATED_CLASSPATHElement- Parameters:
attributes- the attributes to usebaseClassLoader- the baseClassLoader, this will be ultimately be the parent forElement'sClassLoaderinstance.classLoaderCtor- theClassLoaderclassloaderselector- aPredicateto select a singleElementDefinitionRecordto load- Returns:
- the
ElementLoader
-
findElementDefinitionRecord
Optional<ElementDefinitionRecord> findElementDefinitionRecord(ClassLoader classLoader, Attributes attributes, Predicate<ElementDefinitionRecord> selector) Finds theElementname, this will find theElementRecordassociated with it, throwing an exception if it is unable to find theElementDefinitionannotation. Used in constructing shared elements.- Parameters:
classLoader-attributes- the attributes to useselector- aPredicateto select a singleElementDefinitionRecordto load- Returns:
- the
ElementRecord
-
getElementRecordFromPackage
Given thePackage, this will find theElementRecordassociated with it, throwing an exception if it is unable to find theElementDefinitionannotation. Used in constructing shared elements.- Parameters:
attributes- the attributes to useaPackage- the package to scan- Returns:
- the
ElementRecord
-
getExposedServices
Scans the suppliedPackagefor specified- Parameters:
aPackage- a package to scan- Returns:
- a
Streamof allElementServiceRecords exposed by theElement
-
getDefault
Gets a defaultElementLoaderFactoryvia theServiceLoaderinterface.- Returns:
- the
ElementLoaderFactory
-