Class ComponentVertex
- All Implemented Interfaces:
Iterable<ComponentType>,Channel,Eligible,Manager
- Direct Known Subclasses:
Component,ComponentProxy
ComponentVertex is extended by Component
for the use as base class for component implementations. As an
alternative for implementing components with an independent base class,
the derived class ComponentProxy can be
used.
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.jgrapes.core.Channel
Channel.Default -
Field Summary
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedComponentVertex(HandlerDefinition.ChannelReplacements channelReplacements) Initialize the ComponentVertex. -
Method Summary
Modifier and TypeMethodDescriptionReturns the pipeline used when firing an event.voidaddHandler(Method method, HandlerScope scope, int priority) Adds a handler for the given method with the given scope and priority.<T extends ComponentType>
Tattach(T child) Attaches the given component node (or complete tree) as a child to the component managed by this manager.Return the channel replacements passed to the constructor.children()Returns the child components of the component managed by this manager as unmodifiable list.abstract ComponentTypeReturns the component represented by this node in the tree.Returns the path of the component.static ComponentVertexcomponentVertex(ComponentType component, Channel componentChannel) Return the component node for a given component.detach()Detaches the component managed by this manager (with its children, if any) from the component tree that it currently belongs to.<T> Event<T> Fires the given event on the given channel.protected voidInitialize the handler list of this component.iterator()Returns an iterator that visits the components of the component subtree that has this node as root.name()Returns the (optional) name of the component.Return a newEventPipelinethat processes the added events using a thread from a thread pool.newEventPipeline(ExecutorService executorService) Return a newEventPipelinethat processes the added events using threads from the given executor service.parent()Returns the parent of the component managed by this manager.voidRegister the managed component as a running generator.root()Returns the root of the tree the component managed by this manager belongs to.Sets the (optional) name of the component.toString()If a name has been set for this component (seeManager.setName(String)), return the name, else return the object name provided byComponents.objectName(Object), usingcomponent()as argument.voidUnregister the managed component as a running generator.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.jgrapes.core.Channel
isEligibleForMethods inherited from interface org.jgrapes.core.Eligible
defaultCriterionMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
ComponentVertex
Initialize the ComponentVertex.By default it forms a stand-alone tree, i.e. the root is set to the component itself.
- Parameters:
channelReplacements- the channel replacements
-
-
Method Details
-
channelReplacements
Return the channel replacements passed to the constructor.- Returns:
- the channel replacements
-
initComponentsHandlers
Initialize the handler list of this component.May only be called when
component()can be relied on to return the correct value. -
setName
Description copied from interface:ManagerSets the (optional) name of the component. -
name
Description copied from interface:ManagerReturns the (optional) name of the component. -
componentPath
Description copied from interface:ManagerReturns the path of the component.The path is the concatenation of a slash (‘/’) and the component’s name for all components from the root component to this component. If a component doesn’t have a name set, the simple name of its class (see
Class.getSimpleName()) is used instead.- Specified by:
componentPathin interfaceManager
-
componentVertex
Return the component node for a given component.- Parameters:
component- the componentcomponentChannel- the component’s channel- Returns:
- the node representing the component in the tree
-
component
Returns the component represented by this node in the tree. -
children
Description copied from interface:ManagerReturns the child components of the component managed by this manager as unmodifiable list. -
parent
Description copied from interface:ManagerReturns the parent of the component managed by this manager. -
root
Description copied from interface:ManagerReturns the root of the tree the component managed by this manager belongs to. -
attach
Description copied from interface:ManagerAttaches the given component node (or complete tree) as a child to the component managed by this manager.The node or tree may not have been started.
If a component (or component tree) is attached to an already started tree, a
Startevent is automatically fired with the list of components from the attached subtree as channels. This guarantees that every component gets aStartevent once. For efficiency, it is therefore preferable to build a subtree first and attach it, instead of attaching the nodes to the existing tree one by one. -
detach
Description copied from interface:ManagerDetaches the component managed by this manager (with its children, if any) from the component tree that it currently belongs to.This method results in a
IllegalStateExceptionif called on a tree before aStartevent has been fired on it. The Reason for this restriction is that distributing buffered events between the two separated trees cannot easily be defined in an intuitive way. -
iterator
Description copied from interface:ManagerReturns an iterator that visits the components of the component subtree that has this node as root.- Specified by:
iteratorin interfaceIterable<ComponentType>- Specified by:
iteratorin interfaceManager- Returns:
- the iterator
-
addHandler
Description copied from interface:ManagerAdds a handler for the given method with the given scope and priority.This method is usually not invoked directly. Rather, a
HandlerDefinition.Evaluatorprovidesadd(...)methods that evaluate the requiredmethodandscopearguments from easier to provide arguments and then call this method.- Specified by:
addHandlerin interfaceManager- Parameters:
method- the method to invokescope- the handler scope to be used for matching eventspriority- the priority of the handler- See Also:
-
fire
Description copied from interface:ManagerFires the given event on the given channel.If no channels are specified as parameters, the event is fired on the event’s channel (see
Event.channels()). If the event doesn’t specify channels either, the event is fired on the channel of the component managed by this manager (seeManager.channel()).If an event is fired inside an event handler, it is added to the
EventPipelinethat has invoked the handler. If an event is fired by some other thread (not associated with a pipeline), a new pipeline is created for handling the event (and any events triggered by it). -
activeEventPipeline
Description copied from interface:ManagerReturns the pipeline used when firing an event.- Specified by:
activeEventPipelinein interfaceManager- Returns:
- the event pipeline
- See Also:
-
newEventPipeline
Description copied from interface:ManagerReturn a newEventPipelinethat processes the added events using a thread from a thread pool.- Specified by:
newEventPipelinein interfaceManager- Returns:
- the pipeline
-
newEventPipeline
Description copied from interface:ManagerReturn a newEventPipelinethat processes the added events using threads from the given executor service.- Specified by:
newEventPipelinein interfaceManager- Parameters:
executorService- the executor service- Returns:
- the pipeline
-
toString
If a name has been set for this component (seeManager.setName(String)), return the name, else return the object name provided byComponents.objectName(Object), usingcomponent()as argument. -
registerAsGenerator
Description copied from interface:ManagerRegister the managed component as a running generator.- Specified by:
registerAsGeneratorin interfaceManager
-
unregisterAsGenerator
Description copied from interface:ManagerUnregister the managed component as a running generator.- Specified by:
unregisterAsGeneratorin interfaceManager
-