it.amattioli.workstate.core
Class Machine

Show UML class diagram
java.lang.Object
  extended by it.amattioli.workstate.core.State
      extended by it.amattioli.workstate.core.RealState
          extended by it.amattioli.workstate.core.CompositeState
              extended by it.amattioli.workstate.core.SequentialState
                  extended by it.amattioli.workstate.core.Machine
All Implemented Interfaces:
AttributeHandler, AttributeReader, Receiver, Cloneable

public class Machine
extends SequentialState
implements Cloneable


Field Summary
static String CONVERSION_SERVICE_TAG
           
 
Fields inherited from class it.amattioli.workstate.core.SequentialState
CURRENT_STATE_TAG
 
Fields inherited from class it.amattioli.workstate.core.CompositeState
substates
 
Constructor Summary
Machine(MetaMachine metastate)
           
Machine(MetaMachine metastate, CompositeState parent)
           
 
Method Summary
protected  Map<String,Object> addAllAttributes(Map<String,Object> attributes)
          Add to the passed map all the attributes that are accessible from this state.
 boolean admitEvent(String eventName, Map<String,Object> stringParameters)
           
 Event buildEvent(String name, Map<String,Object> stringParameters)
           
 Machine clone()
           
 Object getAttribute(String tag)
          Get the value of an attribute accessible to this state.
 Machine getRootMachine()
           
 boolean hasAllowedAttribute(String tag)
          Check if the passed string is the tag of an attribute that can be accessed by this state.
 boolean isInState(MetaState matchingMetaState)
           
 void postEvent(Event event)
           
 void postEvent(String name)
           
 void postEvent(String name, Map<String,Object> stringParameters)
           
 void processEvents()
           
 void setAttribute(String tag, Object value)
          Set the value of an attribute accessible from this state.
 void setOwner(Object owner)
          Set the state machine owner.
 void terminate()
           
 void useConversionService(ConversionService conversionService)
           
 
Methods inherited from class it.amattioli.workstate.core.SequentialState
enter, enter, enterCurrent, exitCurrent, getCurrentState, isRegion, reEnterCurrent, restore
 
Methods inherited from class it.amattioli.workstate.core.CompositeState
addAvailableEvents, admitEvent, equals, exit, getMemento, isComplete, receive, receiveEvent, reEnter
 
Methods inherited from class it.amattioli.workstate.core.RealState
getAllAttributes, getLocalAttributes, getTag, hasOwnAttribute, reExit, toString
 
Methods inherited from class it.amattioli.workstate.core.State
checkActive, findAncestor, getAvailableEvents, getId, getMemento, getParent, hasMetaState, isActive
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

CONVERSION_SERVICE_TAG

public static final String CONVERSION_SERVICE_TAG
See Also:
Constant Field Values
Constructor Detail

Machine

public Machine(MetaMachine metastate,
               CompositeState parent)

Machine

public Machine(MetaMachine metastate)
Method Detail

setOwner

public void setOwner(Object owner)
              throws WorkflowException
Set the state machine owner. When a state machine is used inside the business layer, the machine will be often an attribute of an entity. This method allows to set a back reference to this entity so it is available to actions and guards as a state machine attribute whose tag is MetaMachine.OWNER_TAG.

Parameters:
owner - the owner of this state machine
Throws:
WorkflowException

getAttribute

public Object getAttribute(String tag)
Description copied from class: RealState
Get the value of an attribute accessible to this state. An attribute is accessible if it belongs to this state or to one of its ancestors.

Specified by:
getAttribute in interface AttributeReader
Overrides:
getAttribute in class RealState
Parameters:
tag - the attribute tag
Returns:
the attribute value

addAllAttributes

protected Map<String,Object> addAllAttributes(Map<String,Object> attributes)
Description copied from class: RealState
Add to the passed map all the attributes that are accessible from this state. If the map contains a key identical to an attribute tag the old entry will be retained.

Overrides:
addAllAttributes in class RealState

setAttribute

public void setAttribute(String tag,
                         Object value)
                  throws WorkflowException
Description copied from class: RealState
Set the value of an attribute accessible from this state. An attribute is accessible if it belongs to this state or to one of its ancestors.

Specified by:
setAttribute in interface AttributeHandler
Overrides:
setAttribute in class RealState
Parameters:
tag - the attribute tag
value - the new attribute value
Throws:
WorkflowException

hasAllowedAttribute

public boolean hasAllowedAttribute(String tag)
Description copied from class: RealState
Check if the passed string is the tag of an attribute that can be accessed by this state. An attribute is accessible if it belongs to this state or to one of its ancestors.

Overrides:
hasAllowedAttribute in class RealState
Parameters:
tag - the attribute tag
Returns:
true if the attribute is accessible, false otherwise

getRootMachine

public Machine getRootMachine()
Overrides:
getRootMachine in class State

buildEvent

public Event buildEvent(String name,
                        Map<String,Object> stringParameters)
                 throws WorkflowException
Overrides:
buildEvent in class CompositeState
Throws:
WorkflowException

admitEvent

public boolean admitEvent(String eventName,
                          Map<String,Object> stringParameters)
                   throws WorkflowException
Throws:
WorkflowException

postEvent

public void postEvent(String name,
                      Map<String,Object> stringParameters)
               throws WorkflowException
Throws:
WorkflowException

postEvent

public void postEvent(String name)
               throws WorkflowException
Throws:
WorkflowException

postEvent

public void postEvent(Event event)

processEvents

public void processEvents()
                   throws WorkflowException
Throws:
WorkflowException

isInState

public boolean isInState(MetaState matchingMetaState)

useConversionService

public void useConversionService(ConversionService conversionService)

terminate

public void terminate()
               throws WorkflowException
Overrides:
terminate in class SequentialState
Throws:
WorkflowException

clone

public Machine clone()
Overrides:
clone in class Object


Copyright © 2011. All Rights Reserved.