DPML
DPML Metro Active Management Principals
HomeUtilitiesStationMetro
Active Management

A component lifecycle strategy covers the management of the lifetime of a component. Frequently containers will provide common lifecycle interfaces following the Avalon style Initializable, Startable, and Executable interface. These approaches suffer from the immediate disavantage of locking a component implementation to a particular framework API - but more importantly, they limit the scope of a potential lifecycle to a static generilized scenario.

Metro takes a fundimentally different approach to lifecycle management in that a lifecycle is viewed in terms of states and transitions. The process of establishing a component is representated by a series of initialization transitions applied to a state graph. The process of decommissioning is expressed as a series of terminator transitions. On completion of the instantiation phase a component may be managed in terms of additional states, transitions and operations. Using this approach components may declare complex highly-tailored custom lifecycle behaviour without reference to a particular container API. Secondly, through a remote management framework - management applications can dynamically interact with and adapt to the active state of a component instance.

Example Component

The following code fragment demonstrates the implementation within a component that deals with start and stop semantics. The component expects start to be invoked during initialization and that stop will be invoked duirng component decomissioning. Note that the implementation does not reference any static constructs such as a container specific lifecycle interface.

public DemoComponent
{
    public void start() throws Exception
    {
        ...
    }

    public void stop() throws Exception
    {
        ...
    }
}

Metro uses a generic state model based on the standard OMG Collaboration Framework Specifications as the basis for component state management. The lifecycle logic of a component is may be declared as a graph artifact, embedded graph resource, or directly within a type definition.

Example of an XML specification for a start/stop/restart lifecycle declared within a type descriptor.

<c:type class="net.dpml.test.lifecycle.StartableComponent" name="lifecycle">
  <state>
    <trigger event="initialization">
      <transition name="init" target="started">
        <operation name="startup" method="start"/>
      </transition>
    </trigger>
    <state name="started">
      <transition name="stop" target="../stopped">
        <operation name="stop" method="stop"/>
      </transition>
      <trigger event="termination">
        <apply id="stop"/>
      </trigger>
    </state>
    <state name="stopped">
      <transition name="start" target="../started">
        <operation name="start" method="start"/>
      </transition>
    </state>
  </state>
</c:type>