Class BasicCoreRoot

java.lang.Object
org.praxislive.base.AbstractRoot
org.praxislive.hub.BasicCoreRoot
All Implemented Interfaces:
org.praxislive.core.Lookup.Provider, org.praxislive.core.Root

public class BasicCoreRoot extends org.praxislive.base.AbstractRoot
A base implementation of a core root for use with Hub. This is the default implementation used unless a custom Hub.CoreRootFactory is provided. It is recommended to extend this class to provide custom core root behaviour.
  • Nested Class Summary

    Nested classes/interfaces inherited from class org.praxislive.base.AbstractRoot

    org.praxislive.base.AbstractRoot.Controller, org.praxislive.base.AbstractRoot.Delegate, org.praxislive.base.AbstractRoot.DelegateConfiguration, org.praxislive.base.AbstractRoot.State
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    BasicCoreRoot(Hub.Accessor hubAccess, List<org.praxislive.core.Root> exts)
    Create an instance.
  • Method Summary

    Modifier and Type
    Method
    Description
    protected final void
    Activation hook implementation of the BasicCoreRoot.
    protected void
    buildControlMap(Map<String,org.praxislive.core.Control> ctrls)
    Build the controls on this root.
    protected void
    buildServiceMap(Map<Class<? extends org.praxislive.core.services.Service>,org.praxislive.core.ComponentAddress> srvs)
    Build the map of services implemented by this root.
    protected int
    The exit value to be returned from Hub.exitValue().
     
    protected final void
    Force termination of this root.
    protected final Hub.Accessor
    Acquire the hub accessor.
    final org.praxislive.base.AbstractRoot.Controller
    initialize(String id, org.praxislive.core.RootHub hub)
     
    protected final org.praxislive.core.Root.Controller
    installRoot(String id, org.praxislive.core.Root root)
    Install a root in the hub with the provided ID.
    protected void
    processCall(org.praxislive.core.Call call, org.praxislive.core.PacketRouter router)
     
    protected final void
    startRoot(String id, org.praxislive.core.Root.Controller ctrl)
    Start the root with the provided ID and controller.
    protected void
    Termination hook implementation.
    protected final org.praxislive.core.Root.Controller
    Uninstall the root with the provided ID and trigger it to shutdown.

    Methods inherited from class org.praxislive.base.AbstractRoot

    attachDelegate, createContext, createController, createRouter, delegateConfig, detachDelegate, findService, getAddress, getExecutionContext, getLookup, getRootHub, getRouter, getState, interrupt, invokeLater, setIdle, setRunning, starting, stopping, update

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • BasicCoreRoot

      protected BasicCoreRoot(Hub.Accessor hubAccess, List<org.praxislive.core.Root> exts)
      Create an instance.
      Parameters:
      hubAccess - private roothub access
      exts - extensions
  • Method Details

    • initialize

      public final org.praxislive.base.AbstractRoot.Controller initialize(String id, org.praxislive.core.RootHub hub)
      Specified by:
      initialize in interface org.praxislive.core.Root
      Overrides:
      initialize in class org.praxislive.base.AbstractRoot
    • activating

      protected final void activating()
      Activation hook implementation of the BasicCoreRoot. During activation, controls and services on the core root are registered, extensions are installed, the root is set to running, and extensions are started.

      The AbstractRoot.starting() hook will be called after extensions are installed, but before they are running.

      This method is currently final. Customizing controls and services can be achieved using buildControlMap(java.util.Map) and buildServiceMap(java.util.Map). Further customization should be done in the starting hook.

      Overrides:
      activating in class org.praxislive.base.AbstractRoot
    • terminating

      protected void terminating()
      Termination hook implementation. This implementation shuts down all registered roots. If overriding this method, ensure to call the super implementation, or otherwise terminate all roots.
      Overrides:
      terminating in class org.praxislive.base.AbstractRoot
    • forceTermination

      protected final void forceTermination()
      Force termination of this root.
    • exitValue

      protected int exitValue()
      The exit value to be returned from Hub.exitValue(). By default this returns the value passed to the SystemManagerService implementation, if any, otherwise 0.
      Returns:
      exit value
    • processCall

      protected void processCall(org.praxislive.core.Call call, org.praxislive.core.PacketRouter router)
      Specified by:
      processCall in class org.praxislive.base.AbstractRoot
    • buildServiceMap

      protected void buildServiceMap(Map<Class<? extends org.praxislive.core.services.Service>,org.praxislive.core.ComponentAddress> srvs)
      Build the map of services implemented by this root. Usually the root address from AbstractRoot.getAddress() will be used, although subclasses may use subpaths of that address if required. Subclasses may override this method and choose whether or not to call the super implementation. This implementation adds RootManagerService and SystemManagerService at the root address if they are absent from the map.
      Parameters:
      srvs - map of service addresses to register
    • buildControlMap

      protected void buildControlMap(Map<String,org.praxislive.core.Control> ctrls)
      Build the controls on this root. Subclasses may override this method and choose whether or not to call the super implementation. This implementation adds all RootManagerService and SystemManagerService controls if they are absent from the map.
      Parameters:
      ctrls - map of control id to control
    • installRoot

      protected final org.praxislive.core.Root.Controller installRoot(String id, org.praxislive.core.Root root) throws Exception
      Install a root in the hub with the provided ID. This method will initialize the root and register it in the roothub, returning the root controller. It does not start the root - see startRoot(java.lang.String, org.praxislive.core.Root.Controller).
      Parameters:
      id - root ID
      root - root to initialize and install
      Returns:
      root controller
      Throws:
      Exception - if id is invalid or in use, or if root cannot be initialized
    • uninstallRoot

      protected final org.praxislive.core.Root.Controller uninstallRoot(String id)
      Uninstall the root with the provided ID and trigger it to shutdown.
      Parameters:
      id - root ID
      Returns:
      root controller (or null if no registered root with id)
    • startRoot

      protected final void startRoot(String id, org.praxislive.core.Root.Controller ctrl)
      Start the root with the provided ID and controller.
      Parameters:
      id - root ID
      ctrl - root controller
    • getHubAccessor

      protected final Hub.Accessor getHubAccessor()
      Acquire the hub accessor.
      Returns:
      hub accessor
    • factory

      public static Hub.CoreRootFactory factory()