CSW Framework Design Description

The CSW Framework provides the APIs used to talk to components, such as HCDs and assemblies. The framework, which is based on Akka typed actors, creates an actor for each component, along with a supervisor and some related actors. For simplicity, component developers only need to implement a set of handlers (the ComponentHandlers trait for Scala, the JComponentHandlers interface for Java) which define how a component will behave.

See here for information on using the CSW framework to develop HCD and assembly components.

The framework packge documentation also contains an overview of the core classes that make up the CSW framework.

Entry Points

In order to start an assembly or HCD component, you first need a descriptor file (or object) called ComponentInfo.

The name of the component info file can be passed as a command line argument to an application based on the ContainerCmd class to deploy the component.

In a production environment, it is planned that components will be started at boot time using a HostConfig based application.

Component Creation

Components can be created in standalone or container mode. When an HCD or assembly is created, depending on the mode, either the ContainerBehaviorFactory or the SupervisorBehaviorFactory class is used to create the initial actor behavior. In container mode, a supervisor actor is created for each component and a single container actor accepts control messages for the container (subtypes of ContainerActorMessage).

Each supervisor then creates and watches its component and determines what to do when something goes wrong. It uses an instance of ComponentBehaviorFactory that is created via reflection from an entry in the component info file file to create the component.

The top level actor (TLA) representing the component’s behavior uses the instance of ComponentHandlers returned from the supplied ComponentBehaviorFactory to handle incoming messages and commands for the component.

Component Initialization and Lifecycle

The framework manages a component’s lifecycle so that it only receives commands once it has signaled that it has completed the initialization process. This includes tracking any connections listed in the component info file. Once the component is in the running state, it can be discovered using the Location Service and other components can start sending command messages to it.

Command Service Clients

Although components are actually actors, it is convenient to be able to treat them as objects and call methods on them. The CommandService trait, and its implementation: CommandServiceImpl provide a wrapper that uses Akka ask to send a message to a component and return a Future with it’s response. The CommandServiceFactory class can be used to make a CommandService instance from a location received from the Location Service.

Command Response Handling

A Command Response Manager class is used to manage the responses to a commands sent to a component.