Package dev.getelements.elements.sdk.spi
Class ElementScopedElementRegistry
java.lang.Object
dev.getelements.elements.sdk.spi.ElementScopedElementRegistry
- All Implemented Interfaces:
ElementRegistry,AutoCloseable
Provides a registry where a
Element may be registered. Because each Element runs inside its own
isolated ClassLoader, there may be multiple instances of this type. However, from the perspective of a
Element, there is only one. The ElementRegistry also forms a hierarchy in which the element may load
subordinate Elements which are equally isolated.-
Field Summary
Fields inherited from interface dev.getelements.elements.sdk.ElementRegistry
ROOT -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes allElementinstances within thisElementRegistryand closes the registry itself.Returns a new subordinate registry.onClose(Consumer<ElementRegistry> onClose) Adds aConsumerto thisElementRegistrywhich will get called when it is closed.Adds aConsumerto thisElementRegistrywhich will get called when anEventis sourced from anElementwithin this registry.voidstream()Streams allElementisntances in thisElementRegistry.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.ElementRegistry
find
-
Constructor Details
-
ElementScopedElementRegistry
-
-
Method Details
-
stream
Description copied from interface:ElementRegistryStreams allElementisntances in thisElementRegistry.- Specified by:
streamin interfaceElementRegistry- Returns:
- the
StreamofElements
-
newSubordinateRegistry
Description copied from interface:ElementRegistryReturns a new subordinate registry. This registry will be linked to this registry and inherit all currently registeredElements contained in. Searching the new subordinate registry will make all registeredElements available that are available to this registry. The returnedMutableElementRegistrywill receive events from thisElementRegistryand forward them along to allElements therein. This allows anElementto load private instances as it sees fit without affecting its parent's hierarchy and thus enforcing encapsulation.- Specified by:
newSubordinateRegistryin interfaceElementRegistry- Returns:
- a new subordinate
-
publish
Description copied from interface:ElementRegistry- Specified by:
publishin interfaceElementRegistry- Parameters:
event- the event
-
onEvent
Description copied from interface:ElementRegistryAdds aConsumerto thisElementRegistrywhich will get called when anEventis sourced from anElementwithin this registry.- Specified by:
onEventin interfaceElementRegistry- Parameters:
onEvent- the event consumer- Returns:
- a
Subscriptionto the event
-
onClose
Description copied from interface:ElementRegistryAdds aConsumerto thisElementRegistrywhich will get called when it is closed.- Specified by:
onClosein interfaceElementRegistry- Parameters:
onClose- the on close consumer- Returns:
- a
Subscriptionto the event
-
close
public void close()Description copied from interface:ElementRegistryCloses allElementinstances within thisElementRegistryand closes the registry itself.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceElementRegistry
-