java.lang.Object
org.praxislive.base.AbstractRoot
org.praxislive.hub.BasicCoreRoot
- All Implemented Interfaces:
Lookup.Provider,Root
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
AbstractRoot.Controller, AbstractRoot.Delegate, AbstractRoot.DelegateConfiguration, AbstractRoot.State -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedBasicCoreRoot(Hub.Accessor hubAccess, List<Root> exts) Create an instance. -
Method Summary
Modifier and TypeMethodDescriptionprotected final voidActivation hook implementation of the BasicCoreRoot.protected voidbuildControlMap(Map<String, Control> ctrls) Build the controls on this root.protected voidbuildServiceMap(Map<Class<? extends Service>, ComponentAddress> srvs) Build the map of services implemented by this root.protected intThe exit value to be returned fromHub.exitValue().static Hub.CoreRootFactoryfactory()protected final voidForce termination of this root.protected final Hub.AccessorAcquire the hub accessor.final AbstractRoot.Controllerinitialize(String id, RootHub hub) Method used by the RootHub to initialize the Root and obtain a Controller.protected final Root.ControllerinstallRoot(String id, Root root) Install a root in the hub with the provided ID.protected voidprocessCall(Call call, PacketRouter router) Method called to handle every receivedCall.protected final voidstartRoot(String id, Root.Controller ctrl) Start the root with the provided ID and controller.protected voidTermination hook implementation.protected final Root.ControlleruninstallRoot(String id) 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
-
Constructor Details
-
BasicCoreRoot
Create an instance.- Parameters:
hubAccess- private roothub accessexts- extensions
-
-
Method Details
-
initialize
Description copied from interface:RootMethod 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:
initializein interfaceRoot- Overrides:
initializein classAbstractRoot- Parameters:
id- the unique ID of this Roothub- 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)andbuildServiceMap(java.util.Map). Further customization should be done in the starting hook.- Overrides:
activatingin classAbstractRoot
-
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:
terminatingin classAbstractRoot
-
forceTermination
protected final void forceTermination()Force termination of this root. -
exitValue
protected int exitValue()The exit value to be returned fromHub.exitValue(). By default this returns the value passed to theSystemManagerServiceimplementation, if any, otherwise 0.- Returns:
- exit value
-
processCall
Description copied from class:AbstractRootMethod called to handle every receivedCall. The provided router should be used for all ongoing or return calls.- Specified by:
processCallin classAbstractRoot- Parameters:
call-router-
-
buildServiceMap
Build the map of services implemented by this root. Usually the root address fromAbstractRoot.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 addsRootManagerServiceandSystemManagerServiceat the root address if they are absent from the map.- Parameters:
srvs- map of service addresses to register
-
buildControlMap
Build the controls on this root. Subclasses may override this method and choose whether or not to call the super implementation. This implementation adds allRootManagerServiceandSystemManagerServicecontrols if they are absent from the map.- Parameters:
ctrls- map of control id to control
-
installRoot
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 - seestartRoot(java.lang.String, org.praxislive.core.Root.Controller).- Parameters:
id- root IDroot- root to initialize and install- Returns:
- root controller
- Throws:
Exception- if id is invalid or in use, or if root cannot be initialized
-
uninstallRoot
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
Start the root with the provided ID and controller.- Parameters:
id- root IDctrl- root controller
-
getHubAccessor
Acquire the hub accessor.- Returns:
- hub accessor
-
factory
-