Class AbstractRoot

    • Constructor Detail

      • AbstractRoot

        protected AbstractRoot()
        Default constructor.
    • Method Detail

      • initialize

        public AbstractRoot.Controller initialize​(String id,
                                                  RootHub hub)
        Description copied from interface: Root
        Method used by the RootHub to initialize the Root and obtain a Controller. Root implementations will ensure this method can only be invoked once.
        Specified by:
        initialize in interface Root
        Parameters:
        id - the unique ID of this Root
        hub - the RootHub the Root resides within
        Returns:
        Controller for use by the RootHub instance
      • getAddress

        protected final ComponentAddress getAddress()
        Get the address of this Root. Only valid after initialization.
        Returns:
        address
      • getRootHub

        protected final RootHub getRootHub()
        Get the RootHub this Root is installed in. Only valid after initialization.
        Returns:
        RootHub
      • getRouter

        protected final PacketRouter getRouter()
        Get the PacketRouter for this Root. Only valid after initialization.
        Returns:
        router
      • getExecutionContext

        protected final ExecutionContext getExecutionContext()
        Get the ExecutionContext for this Root. Only valid after initialization.
        Returns:
        execution context
      • getState

        protected AbstractRoot.State getState()
        Get the State of this Root.
        Returns:
        State
      • createContext

        protected DefaultExecutionContext createContext​(long initialTime)
        Method used to create the DefaultExecutionContext during initialization. Subclasses may override to customize the execution context.
        Parameters:
        initialTime - the current clock time of the hub
        Returns:
        execution context
      • terminating

        protected void terminating()
        Hook called during termination of this Root, asynchronously after a call to AbstractRoot.Controller.shutdown() or other cause of termination. The default implementation does nothing.
      • update

        protected void update()
        Hook called regularly every time the internal time changes, after all ExecutionContext.ClockListener have been called. The default implementation does nothing.
      • processCall

        protected abstract void processCall​(Call call,
                                            PacketRouter router)
        Method called to handle every received Call. The provided router should be used for all ongoing or return calls.
        Parameters:
        call -
        router -
      • setRunning

        protected final boolean setRunning()
        Set the Root state to AbstractRoot.State.ACTIVE_RUNNING. The state will only be changed, and starting() called, if the existing state is idle.
        Returns:
        true if the state has been set to running
      • setIdle

        protected final boolean setIdle()
        Set the Root state to AbstractRoot.State.ACTIVE_IDLE. The state will only be changed, and stopping() called, if the existing state is running.
        Returns:
        true if the state has been set to idle
      • detachDelegate

        protected final void detachDelegate​(AbstractRoot.Delegate delegate)
        Detach the provide delegate (if it is attached). Also calls interrupt().
        Parameters:
        delegate -
      • interrupt

        protected final void interrupt()
        Interrupt the current update cycle, leaving pending calls or tasks to a subsequent update cycle.
      • invokeLater

        protected final boolean invokeLater​(Runnable task)
        Submit a task to be run asynchronously on the main Root thread. The task is added to the same queue as incoming packets.
        Parameters:
        task -
        Returns:
        true if the task has been successfully submitted