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

public interface Manager extends Iterable<ComponentType>
The interface that provides the methods for manipulating the component and the component’s hierarchy and for firing events.

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 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 a Start 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 a Start event
    • attach

      <T extends ComponentType> T attach(T child)
      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 a Start 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

      <T> Event<T> fire(Event<T> event, Channel... channels)
      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 (see channel()).

      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 fire
      channels - the channels to fire the event on
      Returns:
      the event (for easy chaining)
    • addHandler

      void addHandler(Method method, HandlerScope scope, int priority)
      Adds a handler for the given method with the given scope and priority.

      This method is usually not invoked directly. Rather, a HandlerDefinition.Evaluator provides add(...) methods that evaluate the required method and scope arguments from easier to provide arguments and then call this method.

      Parameters:
      method - the method to invoke
      scope - the handler scope to be used for matching events
      priority - 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 new EventPipeline that processes the added events using a thread from a thread pool.
      Returns:
      the pipeline
    • newEventPipeline

      Return a new EventPipeline that processes the added events using threads from the given executor service.
      Parameters:
      executorService - the executor service
      Returns:
      the pipeline
    • registerAsGenerator

      Register the managed component as a running generator.
    • 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 interface Iterable<ComponentType>
      Returns:
      the iterator
    • stream

      Returns the components visited when traversing the tree that starts with this component.
      Returns:
      the stream