DPML
DPML Metro Component Type State Datatype
HomeUtilitiesStationMetroDepotTransit
State Descriptor Element
Description

A state is an immutable datastructure that defines a collection of available transitions, management operations, and possibly initialization or termination triggers. Actionable features of a state are exposed when the state is within the current state path. The current state path is a path composed of the current state, it's parent, parent's patrent, etc. unit the root state is reached. As such, any operations declared within the root state will always be available where operations and/transitions in sub-states will only available if the associated state is present in the state path.

Attributes
name The name of the state (required on sub-states).
terminal If set to 'true' the state will be classified as a terminal state.
Nested Elements
trigger An initialization or termination trigger.
state A nested state.
transition A state transition.
operation A management operation.
Example
<?xml version="1.0"?>

<type xmlns="link:xsd:dpml/lang/dpml-type#1.0">

  <info name="example"
      class="net.dpml.test.ExampleComponent"
      version="0.0.0"
      lifestyle="thread"
      collection="system"
      threadsafe="unknown"/>
      
  <services>
    <service class="net.dpml.test.ColorManager" version="1.0.0"/>
  </services>
  
  <context>
    <entry key="color" class="java.awt.Color" optional="false"/>
  </context>
  
  <state xmlns="link:xsd:dpml/lang/dpml-state#1.0">
    <trigger event="initialization">
      <transition name="init" target="available"/>
    </trigger>
    <state name="available">
      <trigger event="termination">
        <transition name="terminate" target="../terminated"/>
      </trigger>
    </state>
    <state name="terminated" terminal="true"/>
  </state>

</type>
Technical Note
Importing a State Graph

As an alternative to the above attributes and nested elements, a state graph may be imported from an external source. For example, a graph defining a common lifecycle model can be shared across multiple components.

XGraph Resource

The following example demonstrates the import of a state graph using the class attribute. The classname supplied must be a class that has a collocated .xgraph resource. The .xgraph resource is an XML file containing a state model described using the same attribute and element combinanations as described above.

<c:type name="http" class="net.dpml.http.impl.HttpServerImpl" threadsafe="true">
  <state class="net.dpml.activity.Startable"/>
</c:type>
Graph Artifact

Another alternative is to reference a state graph as a published artifact using the uri attribute.

<c:type class="org.acme.DefaultWidget" name="widget">
  <state uri="artifact:state:acme/widget/acme-widget#123"/>
</c:type>

The original graph artifact may be created using the state graph artifact builder task.