com.tomgibara.pronto.state
Interface StateActivator<S,L,P>

Type Parameters:
S - the type of states the activator will transition between
L - the type of label that decorates transitions
P - the type of parameter accepted during state transitions (should be ? if parameters are not supported)

public interface StateActivator<S,L,P>

Implementations of this interface are supplied to StateEngine instances for the purpose of performing actions during state transitions. Only activators are able to prevent a transition or state change from completing. If a state activator instance is to be shared between many concurrently operating state engines it must be thread safe, otherwise a single engine will guarantee single threaded access to its methods.

Author:
Tom Gibara

Method Summary
 void changeState(S state)
          This method is called to indicate that the current state is to be changed directly (ie.
 void transitionState(StateTransition<S,L> transition, P parameter)
          This method is called to indicate that the state is being changed via a state transition.
 

Method Detail

changeState

void changeState(S state)
                 throws ProntoStateException,
                        java.lang.RuntimeException
This method is called to indicate that the current state is to be changed directly (ie. not performed via a transition). This method may choose to throw a ProntoStateException if it wishes to veto the state change. Implementations are free to throw any other RuntimeException they wish (to signal an unexpected failure), which will be reported via the engine as a ProntoStateException, but will not prevent the state change.

Parameters:
state - the state to which the engine is moving
Throws:
ProntoStateException - if the state change should not occur
java.lang.RuntimeException - if the change of state failed

transitionState

void transitionState(StateTransition<S,L> transition,
                     P parameter)
                     throws ProntoStateException,
                            java.lang.RuntimeException
This method is called to indicate that the state is being changed via a state transition. This method may choose to throw a ProntoStateException if it wishes to veto the transition. Implementations are free to throw any other RuntimeException they wish (to signal an unexpected failure), which will be reported via the engine as a ProntoStateException in which case the engine will be in an indeterminate state.

Parameters:
transition - the transition which the engine is to make
parameter - a parameter for the transition, may be null
Throws:
ProntoStateException - if the transition should not be made
java.lang.RuntimeException - if transition into the new state failed


Copyright © 2006-2007 Tom Gibara. All Rights Reserved.