Class AbstractService
java.lang.Object
com.tccc.kos.commons.util.ready.ReadyBean
com.tccc.kos.commons.core.service.AbstractService
- All Implemented Interfaces:
CtxEventListener
,ContextHandleAware
,HandleAware
,Ready
,ReadyListener
- Direct Known Subclasses:
AbstractConfigurableService
,ApiClient
,AppService
,AssemblyService
,BrowserService
,ConfigService
,FirmwareService
,FuseService
,HandleService
,HardwareService
,KeyValService
,ManifestService
,NodeMgrService
,RegionService
,SerialService
,SpawnService
,StateService
,TroubleService
,UdevService
public abstract class AbstractService
extends ReadyBean
implements ContextHandleAware, CtxEventListener
Abstract base class for all services. It implements HandleAware and
uses @HandleRoot so that any subclasses will automatically be added to the
handle cache, as long as the service is added to the context.
This class implements Ready and ReadyListener in order to make all services easily consumable as ReadyListener targets. By default, this class calls ready() from the onReady() callback, which means by default a service will cascade ready events up as soon as they are ready. To make ready status of this service dependent on other services, simply annotate the corresponding fields with @WhenReady. In order to do work when all dependencies are ready, simply override onReady() and either call super.onReady() or getReady().ready() when done, which cascades the ready event up.
If your service is configurable, use the AbstractConfigurableService instead.
- Since:
- 1.0
- Version:
- 2023-03-06
-
Method Summary
Modifier and TypeMethodDescriptionReturns the handle for this bean.Returns the prefix for the object to be used when the handle is allocated by the context.Methods inherited from class com.tccc.kos.commons.util.ready.ReadyBean
getReady, onBeanReady, onDependenciesReady
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.tccc.kos.commons.core.context.CtxEventListener
onCtxAutowiringCompleted, onCtxDestroyed, onCtxPhaseCompleted
Methods inherited from interface com.tccc.kos.commons.core.service.handle.HandleAware
addHandleChild, getName, getPath
Methods inherited from interface com.tccc.kos.commons.util.ready.ReadyListener
onDependenciesGroupReady
-
Method Details
-
getHandlePrefix
Description copied from interface:ContextHandleAware
Returns the prefix for the object to be used when the handle is allocated by the context. The prefix typically reflects the type of the object, such that two objects with the same name but different types are uniquely identified. This value should be the name of the getter if this object was to be fetched from a parent object. For example, if class was Pump there may be two instances: water and carb. The prefix for the water pump may be "water" while the prefix for carb may be "carb", as this distinguishes them. In cases where there is a single getter, it's not uncommon for the prefix to be the type of the object so that's the default implementation.- Specified by:
getHandlePrefix
in interfaceContextHandleAware
-
getHandle
Description copied from interface:HandleAware
Returns the handle for this bean. This is used by the context to compute the opaque handle for the object.- Specified by:
getHandle
in interfaceHandleAware
- Returns:
- the handle node for the bean
-