Class Assembly
- All Implemented Interfaces:
HandleAware
,JsonDescriptorAware
,Loadable
Typically, an assembly includes all the hardware in a particular device and the system application adds the assembly as part of the startup process. This allows a single system app to define multiple supported device models by simply defining multiple assemblies and only installing the one that matches the actual hardware.
Assemblies are also intended for use in supporting optional expansion hardware. If a device supports another collection of hardware as an add-on or expansion kit, a corresponding assembly can be added for that expansion and removed if the kit is removed.
An assembly has a series of lifecycle callbacks that facilitate installation
and removal of the assembly. The constructor is expected to create all the core
objects in the assembly. When passed to AssemblyService
to be installed, the
handles for all objects in the context are set and any ConfigAware objects
are configured before calling the assembly install()
method. This allows
the install()
method to operate on all the objects that have already been
autowired and configured.
- Since:
- 1.0
- Version:
- 2023-01-19
-
Constructor Summary
ConstructorsConstructorDescriptionAssembly
(String name, JsonDescriptor descriptor) Create a new assembly with the specified name. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Add a board to the assemblyvoid
Adds the given bean to the assembly context.void
Autowires the given bean using the context, without actually adding it to the context.<T> List<T>
Returns a list of beans from the assembly context of the specified type.getCtx()
Returns the context for this assembly.Return the associated JsonDescriptor.Returns the handle for this bean.boolean
isCore()
Returns true if this is the core assembly.boolean
abstract void
load()
Callback to load the assembly.abstract void
start()
Callback during the installation phase.void
started()
Called after install completes and the assembly has been added to the device.void
stop()
Called when uninstalled from the device.void
unload()
Release all resources from the assembly in preparation for garbage collection.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.service.handle.HandleAware
addHandleChild, getName, getPath
-
Constructor Details
-
Assembly
Create a new assembly with the specified name.- Parameters:
name
- name of the assembly
-
-
Method Details
-
addBoard
Add a board to the assembly -
isCore
public boolean isCore()Returns true if this is the core assembly. -
getCtx
Returns the context for this assembly. This context will have the system application context as a parent. -
addToCtx
Adds the given bean to the assembly context.- Parameters:
bean
- the bean to add to the context
-
connect
Autowires the given bean using the context, without actually adding it to the context. If this is called duringload()
then the connect will be deferred untilstart()
is called. This ensures that all autowired dependencies are available before connecting.- Parameters:
bean
- the bean to autowire
-
getBeans
Returns a list of beans from the assembly context of the specified type. This only searches the assembly context. This allows quick access to beans in the assembly without having to track them as object properties. -
load
Callback to load the assembly. -
start
Callback during the installation phase. Any beans created during the load() callback are configured and have valid handles. -
started
public void started()Called after install completes and the assembly has been added to the device. Override as needed. -
stop
Called when uninstalled from the device. Cleanup all the resources for the assembly. This will be called before any listener callbacks. Any resources that need to exist for these callbacks can be cleaned up inunload()
. -
unload
Release all resources from the assembly in preparation for garbage collection. Override as needed. -
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
-
isInstalling
public boolean isInstalling() -
getDescriptor
Description copied from interface:JsonDescriptorAware
Return the associated JsonDescriptor.- Specified by:
getDescriptor
in interfaceJsonDescriptorAware
-
getBoards
-