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 Element
s which are equally isolated.-
Field Summary
Fields inherited from interface dev.getelements.elements.sdk.ElementRegistry
ROOT
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Closes allElement
instances within thisElementRegistry
and closes the registry itself.Returns a new subordinate registry.onClose
(Consumer<ElementRegistry> onClose) Adds aConsumer
to thisElementRegistry
which will get called when it is closed.Adds aConsumer
to thisElementRegistry
which will get called when anEvent
is sourced from anElement
within this registry.void
stream()
Streams allElement
isntances in thisElementRegistry
.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.ElementRegistry
find
-
Constructor Details
-
ElementScopedElementRegistry
-
-
Method Details
-
stream
Description copied from interface:ElementRegistry
Streams allElement
isntances in thisElementRegistry
.- Specified by:
stream
in interfaceElementRegistry
- Returns:
- the
Stream
ofElement
s
-
newSubordinateRegistry
Description copied from interface:ElementRegistry
Returns a new subordinate registry. This registry will be linked to this registry and inherit all currently registeredElement
s contained in. Searching the new subordinate registry will make all registeredElement
s available that are available to this registry. The returnedMutableElementRegistry
will receive events from thisElementRegistry
and forward them along to allElement
s therein. This allows anElement
to load private instances as it sees fit without affecting its parent's hierarchy and thus enforcing encapsulation.- Specified by:
newSubordinateRegistry
in interfaceElementRegistry
- Returns:
- a new subordinate
-
publish
Description copied from interface:ElementRegistry
- Specified by:
publish
in interfaceElementRegistry
- Parameters:
event
- the event
-
onEvent
Description copied from interface:ElementRegistry
Adds aConsumer
to thisElementRegistry
which will get called when anEvent
is sourced from anElement
within this registry.- Specified by:
onEvent
in interfaceElementRegistry
- Parameters:
onEvent
- the event consumer- Returns:
- a
Subscription
to the event
-
onClose
Description copied from interface:ElementRegistry
Adds aConsumer
to thisElementRegistry
which will get called when it is closed.- Specified by:
onClose
in interfaceElementRegistry
- Parameters:
onClose
- the on close consumer- Returns:
- a
Subscription
to the event
-
close
public void close()Description copied from interface:ElementRegistry
Closes allElement
instances within thisElementRegistry
and closes the registry itself.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceElementRegistry
-