Package org.apache.mina.statemachine
Class StateMachineFactory
- java.lang.Object
-
- org.apache.mina.statemachine.StateMachineFactory
-
public class StateMachineFactory extends java.lang.ObjectCreatesStateMachines by readingState,TransitionandTransitions(or equivalent) andSelfTransitionannotations from one or more arbitrary objects.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classStateMachineFactory.TransitionsWrapperprivate static classStateMachineFactory.TransitionWrapper
-
Field Summary
Fields Modifier and Type Field Description private java.lang.Class<? extends java.lang.annotation.Annotation>entrySelfTransitionsAnnotationprivate java.lang.Class<? extends java.lang.annotation.Annotation>exitSelfTransitionsAnnotationprivate java.lang.Class<? extends java.lang.annotation.Annotation>transitionAnnotationprivate java.lang.Class<? extends java.lang.annotation.Annotation>transitionsAnnotation
-
Constructor Summary
Constructors Modifier Constructor Description protectedStateMachineFactory(java.lang.Class<? extends java.lang.annotation.Annotation> transitionAnnotation, java.lang.Class<? extends java.lang.annotation.Annotation> transitionsAnnotation, java.lang.Class<? extends java.lang.annotation.Annotation> entrySelfTransitionsAnnotation, java.lang.Class<? extends java.lang.annotation.Annotation> exitSelfTransitionsAnnotation)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description StateMachinecreate(java.lang.Object handler)Creates a newStateMachinefrom the specified handler object and using a start state with idstart.StateMachinecreate(java.lang.Object handler, java.lang.Object... handlers)Creates a newStateMachinefrom the specified handler objects and using a start state with idstart.StateMachinecreate(java.lang.String start, java.lang.Object handler)Creates a newStateMachinefrom the specified handler object and using theStatewith the specified id as start state.StateMachinecreate(java.lang.String start, java.lang.Object handler, java.lang.Object... handlers)Creates a newStateMachinefrom the specified handler objects and using theStatewith the specified id as start state.(package private) static State[]createStates(java.util.List<java.lang.reflect.Field> fields)(package private) static java.util.List<java.lang.reflect.Field>getFields(java.lang.Class<?> clazz)static StateMachineFactorygetInstance(java.lang.Class<? extends java.lang.annotation.Annotation> transitionAnnotation)Returns a newStateMachineFactoryinstance which createsStateMachines by reading the specifiedTransitionequivalent annotation.private static voidsetupSelfTransitions(java.lang.reflect.Method m, java.lang.Class<? extends java.lang.annotation.Annotation> onEntrySelfTransitionAnnotation, java.lang.Class<? extends java.lang.annotation.Annotation> onExitSelfTransitionAnnotation, java.util.Map<java.lang.String,State> states, java.lang.Object handler)private static voidsetupTransitions(java.lang.Class<? extends java.lang.annotation.Annotation> transitionAnnotation, java.lang.Class<? extends java.lang.annotation.Annotation> transitionsAnnotation, java.lang.Class<? extends java.lang.annotation.Annotation> onEntrySelfTransitionAnnotation, java.lang.Class<? extends java.lang.annotation.Annotation> onExitSelfTransitionAnnotation, java.util.Map<java.lang.String,State> states, java.lang.Object handler)private static voidsetupTransitions(java.lang.Class<? extends java.lang.annotation.Annotation> transitionAnnotation, java.lang.Class<? extends java.lang.annotation.Annotation> transitionsAnnotation, java.lang.Class<? extends java.lang.annotation.Annotation> onEntrySelfTransitionAnnotation, java.lang.Class<? extends java.lang.annotation.Annotation> onExitSelfTransitionAnnotation, java.util.Map<java.lang.String,State> states, java.util.List<java.lang.Object> handlers)
-
-
-
Field Detail
-
transitionAnnotation
private final java.lang.Class<? extends java.lang.annotation.Annotation> transitionAnnotation
-
transitionsAnnotation
private final java.lang.Class<? extends java.lang.annotation.Annotation> transitionsAnnotation
-
entrySelfTransitionsAnnotation
private final java.lang.Class<? extends java.lang.annotation.Annotation> entrySelfTransitionsAnnotation
-
exitSelfTransitionsAnnotation
private final java.lang.Class<? extends java.lang.annotation.Annotation> exitSelfTransitionsAnnotation
-
-
Constructor Detail
-
StateMachineFactory
protected StateMachineFactory(java.lang.Class<? extends java.lang.annotation.Annotation> transitionAnnotation, java.lang.Class<? extends java.lang.annotation.Annotation> transitionsAnnotation, java.lang.Class<? extends java.lang.annotation.Annotation> entrySelfTransitionsAnnotation, java.lang.Class<? extends java.lang.annotation.Annotation> exitSelfTransitionsAnnotation)
-
-
Method Detail
-
getInstance
public static StateMachineFactory getInstance(java.lang.Class<? extends java.lang.annotation.Annotation> transitionAnnotation)
Returns a newStateMachineFactoryinstance which createsStateMachines by reading the specifiedTransitionequivalent annotation.- Parameters:
transitionAnnotation- theTransitionequivalent annotation.- Returns:
- the
StateMachineFactory.
-
create
public StateMachine create(java.lang.Object handler)
Creates a newStateMachinefrom the specified handler object and using a start state with idstart.- Parameters:
handler- the object containing the annotations describing the state machine.- Returns:
- the
StateMachineobject.
-
create
public StateMachine create(java.lang.String start, java.lang.Object handler)
Creates a newStateMachinefrom the specified handler object and using theStatewith the specified id as start state.- Parameters:
start- the id of the startStateto use.handler- the object containing the annotations describing the state machine.- Returns:
- the
StateMachineobject.
-
create
public StateMachine create(java.lang.Object handler, java.lang.Object... handlers)
Creates a newStateMachinefrom the specified handler objects and using a start state with idstart.- Parameters:
handler- the first object containing the annotations describing the state machine.handlers- zero or more additional objects containing the annotations describing the state machine.- Returns:
- the
StateMachineobject.
-
create
public StateMachine create(java.lang.String start, java.lang.Object handler, java.lang.Object... handlers)
Creates a newStateMachinefrom the specified handler objects and using theStatewith the specified id as start state.- Parameters:
start- the id of the startStateto use.handler- the first object containing the annotations describing the state machine.handlers- zero or more additional objects containing the annotations describing the state machine.- Returns:
- the
StateMachineobject.
-
setupTransitions
private static void setupTransitions(java.lang.Class<? extends java.lang.annotation.Annotation> transitionAnnotation, java.lang.Class<? extends java.lang.annotation.Annotation> transitionsAnnotation, java.lang.Class<? extends java.lang.annotation.Annotation> onEntrySelfTransitionAnnotation, java.lang.Class<? extends java.lang.annotation.Annotation> onExitSelfTransitionAnnotation, java.util.Map<java.lang.String,State> states, java.util.List<java.lang.Object> handlers)
-
setupSelfTransitions
private static void setupSelfTransitions(java.lang.reflect.Method m, java.lang.Class<? extends java.lang.annotation.Annotation> onEntrySelfTransitionAnnotation, java.lang.Class<? extends java.lang.annotation.Annotation> onExitSelfTransitionAnnotation, java.util.Map<java.lang.String,State> states, java.lang.Object handler)
-
setupTransitions
private static void setupTransitions(java.lang.Class<? extends java.lang.annotation.Annotation> transitionAnnotation, java.lang.Class<? extends java.lang.annotation.Annotation> transitionsAnnotation, java.lang.Class<? extends java.lang.annotation.Annotation> onEntrySelfTransitionAnnotation, java.lang.Class<? extends java.lang.annotation.Annotation> onExitSelfTransitionAnnotation, java.util.Map<java.lang.String,State> states, java.lang.Object handler)
-
getFields
static java.util.List<java.lang.reflect.Field> getFields(java.lang.Class<?> clazz)
-
createStates
static State[] createStates(java.util.List<java.lang.reflect.Field> fields)
-
-