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 theElementname, this will find theElementRecordassociated with it, return an empty optional if it is unable to find theElementDefinitionannotation.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 specifiedgetIsolatedLoaderWithParent(Attributes attributes, ClassLoader baseClassLoader, ElementLoaderFactory.ClassLoaderConstructor classLoaderCtor, Element element, Predicate<ElementDefinitionRecord> selector) Scans the classpath, using the suppliedClassLoader, forElementinstances.getSharedLoader(ElementRecord elementRecord, ServiceLocator serviceLocator) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface dev.getelements.elements.sdk.ElementLoaderFactory
findElementDefinitionRecord, getIsolatedLoader, getIsolatedLoader, getIsolatedLoader, getIsolatedLoader, getIsolatedLoaderWithParent
-
Constructor Details
-
DefaultElementLoaderFactory
public DefaultElementLoaderFactory()
-
-
Method Details
-
getIsolatedLoaderWithParent
public ElementLoader getIsolatedLoaderWithParent(Attributes attributes, ClassLoader baseClassLoader, ElementLoaderFactory.ClassLoaderConstructor classLoaderCtor, Element element, Predicate<ElementDefinitionRecord> selector) Description copied from interface:ElementLoaderFactoryScans 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 oneElementDefinitionwith the suppliedPredicate.Results in a
The returnedElementType.ISOLATED_CLASSPATHElementElementLoaderwill use theElement's classpath with a filtered version of the supplied baseClassLoaderas the parent classloader.- Specified by:
getIsolatedLoaderWithParentin interfaceElementLoaderFactory- Parameters:
attributes- the attributes to usebaseClassLoader- the baseClassLoader, this will be ultimately be the parent forElement'sClassLoaderinstance.classLoaderCtor- theClassLoaderclassloaderelement- the parentElementto use for the classloader isolation, may be null indicating that isolation should exist for the bootstrap classpath only.selector- aPredicateto select a singleElementDefinitionRecordto load- Returns:
- the
ElementLoader
-
findElementDefinitionRecord
public Optional<ElementDefinitionRecord> findElementDefinitionRecord(ClassLoader classLoader, Attributes attributes, Predicate<ElementDefinitionRecord> selector) Description copied from interface:ElementLoaderFactoryFinds theElementname, this will find theElementRecordassociated with it, return an empty optional if it is unable to find theElementDefinitionannotation. Used in constructing shared elements.- Specified by:
findElementDefinitionRecordin interfaceElementLoaderFactory- Parameters:
classLoader- the classloader to scanattributes- the attributes to useselector- aPredicateto select a singleElementDefinitionRecordto load- Returns:
- the
ElementRecord
-
getElementRecordFromPackage
Description copied from interface:ElementLoaderFactoryGiven thePackage, this will find theElementRecordassociated with it, throwing an exception if it is unable to find theElementDefinitionannotation. Used in constructing shared elements.- Specified by:
getElementRecordFromPackagein interfaceElementLoaderFactory- Parameters:
attributes- the attributes to useaPackage- the package to scan- Returns:
- the
ElementRecord
-
getExposedServices
Description copied from interface:ElementLoaderFactoryScans the suppliedPackagefor specified- Specified by:
getExposedServicesin interfaceElementLoaderFactory- Parameters:
aPackage- a package to scan- Returns:
- a
Streamof allElementServiceRecords exposed by theElement
-