Class BasicCoreRoot

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

public class BasicCoreRoot extends 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.
  • Constructor Details

    • BasicCoreRoot

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

    • initialize

      public final 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
      Overrides:
      initialize in class AbstractRoot
      Parameters:
      id - the unique ID of this Root
      hub - the RootHub the Root resides within
      Returns:
      Controller for use by the RootHub instance
    • 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 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 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(Call call, PacketRouter router)
      Description copied from class: AbstractRoot
      Method called to handle every received Call. The provided router should be used for all ongoing or return calls.
      Specified by:
      processCall in class AbstractRoot
      Parameters:
      call -
      router -
    • buildServiceMap

      protected void buildServiceMap(Map<Class<? extends Service>,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,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 Root.Controller installRoot(String id, 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 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, 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()