Interface Manager
- All Superinterfaces:
Iterable<ComponentType>
- All Known Implementing Classes:
Component
,ComponentCollector
,ComponentCollector
,ComponentProvider
,ComponentProxy
,ComponentVertex
,ConfigurationStore
,ConnectionManager
,FileStorage
,FileSystemWatcher
,FreeMarkerRequestHandler
,HttpConnector
,HttpServer
,InMemorySessionManager
,InputStreamMonitor
,JsonConfigurationStore
,LanguageSelector
,MailConnectionManager
,MailMonitor
,MailSender
,NightConfigStore
,NioDispatcher
,PreferencesStore
,ProcessManager
,PurgeTerminator
,SessionManager
,SocketConnectionManager
,SocketConnector
,SocketServer
,SslCodec
,StaticContentDispatcher
,TomlConfigurationStore
,YamlConfigurationStore
Every component has access to a manager implementation that manages the component.
The Manager
for a component that extends from
Component
is provided by the base class itself.
Components that only implement the ComponentType
interface
get their Manager
assigned to their annotated
attribute when they are attached to the component tree.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionReturns the pipeline used when firing an event.void
addHandler
(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.channel()
Returns the channel of the component managed by this manager.children()
Returns the child components of the component managed by this manager as unmodifiable list.Returns the component managed by this manager.Returns the path of the 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.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 newEventPipeline
that processes the added events using a thread from a thread pool.newEventPipeline
(ExecutorService executorService) Return a newEventPipeline
that processes the added events using threads from the given executor service.parent()
Returns the parent of the component managed by this manager.void
Register 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.default Stream
<ComponentType> stream()
Returns the components visited when traversing the tree that starts with this component.void
Unregister the managed component as a running generator.Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Method Details
-
setName
Sets the (optional) name of the component.- Parameters:
name
- the name to set- Returns:
- the component (for comfortable chaining)
-
name
Returns the (optional) name of the component. -
componentPath
Returns 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. -
detach
Detaches 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
IllegalStateException
if called on a tree before aStart
event 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.- Returns:
- the component (for comfortable chaining)
- Throws:
IllegalStateException
- if invoked before aStart
event
-
attach
Attaches 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
Start
event is automatically fired with the list of components from the attached subtree as channels. This guarantees that every component gets aStart
event 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.- Type Parameters:
T
- the component node’s type- Parameters:
child
- the component to add- Returns:
- the added component (for comfortable chaining)
-
component
Returns the component managed by this manager.- Returns:
- the component
-
children
Returns the child components of the component managed by this manager as unmodifiable list.- Returns:
- the child components
-
parent
Returns the parent of the component managed by this manager.- Returns:
- the parent component or
null
if the component is not registered with another component
-
root
Returns the root of the tree the component managed by this manager belongs to.- Returns:
- the root
-
channel
Returns the channel of the component managed by this manager.- Returns:
- the channel that the component’s
handlers listen on by default and that
fire(Event, Channel...)
sends the event to
-
fire
Fires 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 (seechannel()
).If an event is fired inside an event handler, it is added to the
EventPipeline
that 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).- Type Parameters:
T
- the result type of the event- Parameters:
event
- the event to firechannels
- the channels to fire the event on- Returns:
- the event (for easy chaining)
-
addHandler
Adds a handler for the given method with the given scope and priority.This method is usually not invoked directly. Rather, a
HandlerDefinition.Evaluator
providesadd(...)
methods that evaluate the requiredmethod
andscope
arguments from easier to provide arguments and then call this method.- Parameters:
method
- the method to invokescope
- the handler scope to be used for matching eventspriority
- the priority of the handler- See Also:
-
activeEventPipeline
Returns the pipeline used when firing an event.- Returns:
- the event pipeline
- See Also:
-
newEventPipeline
Return a newEventPipeline
that processes the added events using a thread from a thread pool.- Returns:
- the pipeline
-
newEventPipeline
Return a newEventPipeline
that processes the added events using threads from the given executor service.- Parameters:
executorService
- the executor service- Returns:
- the pipeline
-
registerAsGenerator
void registerAsGenerator()Register the managed component as a running generator. -
unregisterAsGenerator
void unregisterAsGenerator()Unregister the managed component as a running generator. -
iterator
Returns an iterator that visits the components of the component subtree that has this node as root.- Specified by:
iterator
in interfaceIterable<ComponentType>
- Returns:
- the iterator
-
stream
Returns the components visited when traversing the tree that starts with this component.- Returns:
- the stream
-