Support state activity
- AbstractState now extends LifecycleObjectSupport getting access to TaskScheduler. - Modify all configs so that we can have a cancellable Action which is executed after state is entered and which is cancelled(if running) when state is exited. - Fixes #239
This commit is contained in:
@@ -307,7 +307,7 @@ public abstract class AbstractStateMachineFactory<S, E> extends LifecycleObjectS
|
||||
return delegate;
|
||||
}
|
||||
|
||||
private BeanFactory resolveBeanFactory() {
|
||||
protected BeanFactory resolveBeanFactory() {
|
||||
if (stateMachineModel.getConfigurationData().getBeanFactory() != null) {
|
||||
return stateMachineModel.getConfigurationData().getBeanFactory();
|
||||
} else {
|
||||
@@ -315,7 +315,7 @@ public abstract class AbstractStateMachineFactory<S, E> extends LifecycleObjectS
|
||||
}
|
||||
}
|
||||
|
||||
private TaskExecutor resolveTaskExecutor() {
|
||||
protected TaskExecutor resolveTaskExecutor() {
|
||||
if (stateMachineModel.getConfigurationData().getTaskExecutor() != null) {
|
||||
return stateMachineModel.getConfigurationData().getTaskExecutor();
|
||||
} else {
|
||||
@@ -323,7 +323,7 @@ public abstract class AbstractStateMachineFactory<S, E> extends LifecycleObjectS
|
||||
}
|
||||
}
|
||||
|
||||
private TaskScheduler resolveTaskScheduler() {
|
||||
protected TaskScheduler resolveTaskScheduler() {
|
||||
if (stateMachineModel.getConfigurationData().getTaskScheduler() != null) {
|
||||
return stateMachineModel.getConfigurationData().getTaskScheduler();
|
||||
} else {
|
||||
@@ -486,7 +486,7 @@ public abstract class AbstractStateMachineFactory<S, E> extends LifecycleObjectS
|
||||
continue;
|
||||
}
|
||||
state = buildStateInternal(stateData.getState(), stateData.getDeferred(), stateData.getEntryActions(),
|
||||
stateData.getExitActions(), pseudoState);
|
||||
stateData.getExitActions(), stateData.getStateActions(), pseudoState);
|
||||
if (stateData.isInitial()) {
|
||||
initialState = state;
|
||||
initialAction = stateData.getInitialAction();
|
||||
@@ -514,7 +514,7 @@ public abstract class AbstractStateMachineFactory<S, E> extends LifecycleObjectS
|
||||
}
|
||||
PseudoState<S, E> pseudoState = new HistoryPseudoState<S, E>(PseudoStateKind.HISTORY_SHALLOW, defaultStateHolder, containingStateHolder);
|
||||
state = buildStateInternal(stateData.getState(), stateData.getDeferred(), stateData.getEntryActions(),
|
||||
stateData.getExitActions(), pseudoState);
|
||||
stateData.getExitActions(), stateData.getStateActions(), pseudoState);
|
||||
states.add(state);
|
||||
stateMap.put(stateData.getState(), state);
|
||||
historyState = pseudoState;
|
||||
@@ -534,7 +534,7 @@ public abstract class AbstractStateMachineFactory<S, E> extends LifecycleObjectS
|
||||
}
|
||||
PseudoState<S, E> pseudoState = new HistoryPseudoState<S, E>(PseudoStateKind.HISTORY_DEEP, defaultStateHolder, containingStateHolder);
|
||||
state = buildStateInternal(stateData.getState(), stateData.getDeferred(), stateData.getEntryActions(),
|
||||
stateData.getExitActions(), pseudoState);
|
||||
stateData.getExitActions(), stateData.getStateActions(), pseudoState);
|
||||
states.add(state);
|
||||
stateMap.put(stateData.getState(), state);
|
||||
historyState = pseudoState;
|
||||
@@ -553,7 +553,7 @@ public abstract class AbstractStateMachineFactory<S, E> extends LifecycleObjectS
|
||||
}
|
||||
PseudoState<S, E> pseudoState = new ChoicePseudoState<S, E>(choices);
|
||||
state = buildStateInternal(stateData.getState(), stateData.getDeferred(), stateData.getEntryActions(),
|
||||
stateData.getExitActions(), pseudoState);
|
||||
stateData.getExitActions(), stateData.getStateActions(), pseudoState);
|
||||
states.add(state);
|
||||
stateMap.put(stateData.getState(), state);
|
||||
} else if (stateData.getPseudoStateKind() == PseudoStateKind.JUNCTION) {
|
||||
@@ -569,7 +569,7 @@ public abstract class AbstractStateMachineFactory<S, E> extends LifecycleObjectS
|
||||
}
|
||||
PseudoState<S, E> pseudoState = new JunctionPseudoState<S, E>(junctions);
|
||||
state = buildStateInternal(stateData.getState(), stateData.getDeferred(), stateData.getEntryActions(),
|
||||
stateData.getExitActions(), pseudoState);
|
||||
stateData.getExitActions(), stateData.getStateActions(), pseudoState);
|
||||
states.add(state);
|
||||
stateMap.put(stateData.getState(), state);
|
||||
} else if (stateData.getPseudoStateKind() == PseudoStateKind.ENTRY) {
|
||||
@@ -579,7 +579,7 @@ public abstract class AbstractStateMachineFactory<S, E> extends LifecycleObjectS
|
||||
if (s.equals(entry.getSource())) {
|
||||
PseudoState<S, E> pseudoState = new EntryPseudoState<S, E>(stateMap.get(entry.getTarget()));
|
||||
state = buildStateInternal(stateData.getState(), stateData.getDeferred(), stateData.getEntryActions(),
|
||||
stateData.getExitActions(), pseudoState);
|
||||
stateData.getExitActions(), stateData.getStateActions(), pseudoState);
|
||||
states.add(state);
|
||||
stateMap.put(stateData.getState(), state);
|
||||
break;
|
||||
@@ -596,7 +596,7 @@ public abstract class AbstractStateMachineFactory<S, E> extends LifecycleObjectS
|
||||
}
|
||||
PseudoState<S, E> pseudoState = new ExitPseudoState<S, E>(holder);
|
||||
state = buildStateInternal(stateData.getState(), stateData.getDeferred(), stateData.getEntryActions(),
|
||||
stateData.getExitActions(), pseudoState);
|
||||
stateData.getExitActions(), stateData.getStateActions(), pseudoState);
|
||||
states.add(state);
|
||||
stateMap.put(stateData.getState(), state);
|
||||
break;
|
||||
@@ -611,7 +611,7 @@ public abstract class AbstractStateMachineFactory<S, E> extends LifecycleObjectS
|
||||
}
|
||||
PseudoState<S, E> pseudoState = new ForkPseudoState<S, E>(forks);
|
||||
state = buildStateInternal(stateData.getState(), stateData.getDeferred(), stateData.getEntryActions(),
|
||||
stateData.getExitActions(), pseudoState);
|
||||
stateData.getExitActions(), stateData.getStateActions(), pseudoState);
|
||||
states.add(state);
|
||||
stateMap.put(stateData.getState(), state);
|
||||
} else if (stateData.getPseudoStateKind() == PseudoStateKind.JOIN) {
|
||||
@@ -655,7 +655,7 @@ public abstract class AbstractStateMachineFactory<S, E> extends LifecycleObjectS
|
||||
JoinPseudoState<S, E> pseudoState = new JoinPseudoState<S, E>(joins, joinTargets);
|
||||
|
||||
state = buildStateInternal(stateData.getState(), stateData.getDeferred(), stateData.getEntryActions(),
|
||||
stateData.getExitActions(), pseudoState);
|
||||
stateData.getExitActions(), stateData.getStateActions(), pseudoState);
|
||||
states.add(state);
|
||||
stateMap.put(stateData.getState(), state);
|
||||
}
|
||||
@@ -735,8 +735,9 @@ public abstract class AbstractStateMachineFactory<S, E> extends LifecycleObjectS
|
||||
Boolean contextEventsEnabled, BeanFactory beanFactory, TaskExecutor taskExecutor,
|
||||
TaskScheduler taskScheduler, String beanName, String machineId);
|
||||
|
||||
protected abstract State<S, E> buildStateInternal(S id, Collection<E> deferred, Collection<? extends Action<S, E>> entryActions, Collection<? extends Action<S, E>> exitActions,
|
||||
PseudoState<S, E> pseudoState);
|
||||
protected abstract State<S, E> buildStateInternal(S id, Collection<E> deferred,
|
||||
Collection<? extends Action<S, E>> entryActions, Collection<? extends Action<S, E>> exitActions,
|
||||
Collection<? extends Action<S, E>> stateActions, PseudoState<S, E> pseudoState);
|
||||
|
||||
private Iterator<Node<StateData<S, E>>> buildStateDataIterator() {
|
||||
Tree<StateData<S, E>> tree = new Tree<StateData<S, E>>();
|
||||
|
||||
@@ -84,9 +84,23 @@ public class ObjectStateMachineFactory<S, E> extends AbstractStateMachineFactory
|
||||
}
|
||||
|
||||
@Override
|
||||
protected State<S, E> buildStateInternal(S id, Collection<E> deferred, Collection<? extends Action<S, E>> entryActions,
|
||||
Collection<? extends Action<S, E>> exitActions, PseudoState<S, E> pseudoState) {
|
||||
return new ObjectState<S, E>(id, deferred, entryActions, exitActions, pseudoState);
|
||||
protected State<S, E> buildStateInternal(S id, Collection<E> deferred,
|
||||
Collection<? extends Action<S, E>> entryActions, Collection<? extends Action<S, E>> exitActions,
|
||||
Collection<? extends Action<S, E>> stateActions, PseudoState<S, E> pseudoState) {
|
||||
ObjectState<S,E> objectState = new ObjectState<S, E>(id, deferred, entryActions, exitActions, stateActions, pseudoState, null, null);
|
||||
BeanFactory beanFactory = resolveBeanFactory();
|
||||
if (beanFactory != null) {
|
||||
objectState.setBeanFactory(beanFactory);
|
||||
}
|
||||
TaskExecutor taskExecutor = resolveTaskExecutor();
|
||||
if (taskExecutor != null) {
|
||||
objectState.setTaskExecutor(taskExecutor);
|
||||
}
|
||||
TaskScheduler taskScheduler = resolveTaskScheduler();
|
||||
if (taskScheduler != null) {
|
||||
objectState.setTaskScheduler(taskScheduler);
|
||||
}
|
||||
return objectState;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -148,10 +148,26 @@ public class DefaultStateConfigurer<S, E>
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public StateConfigurer<S, E> state(S state, Collection<? extends Action<S, E>> stateActions) {
|
||||
addIncomplete(null, state, null, null, null, stateActions);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public StateConfigurer<S, E> state(S state, Action<S, E> stateAction) {
|
||||
Collection<Action<S, E>> stateActions = null;
|
||||
if (stateAction != null) {
|
||||
stateActions = new ArrayList<Action<S, E>>(1);
|
||||
stateActions.add(stateAction);
|
||||
}
|
||||
return state(state, stateActions);
|
||||
}
|
||||
|
||||
@Override
|
||||
public StateConfigurer<S, E> state(S state, Collection<? extends Action<S, E>> entryActions,
|
||||
Collection<? extends Action<S, E>> exitActions) {
|
||||
addIncomplete(null, state, null, entryActions, exitActions);
|
||||
addIncomplete(null, state, null, entryActions, exitActions, null);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -177,7 +193,7 @@ public class DefaultStateConfigurer<S, E>
|
||||
if (deferred != null) {
|
||||
d = Arrays.asList(deferred);
|
||||
}
|
||||
addIncomplete(null, state, d, null, null);
|
||||
addIncomplete(null, state, d, null, null, null);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -240,7 +256,8 @@ public class DefaultStateConfigurer<S, E>
|
||||
}
|
||||
|
||||
private void addIncomplete(Object parent, S state, Collection<E> deferred,
|
||||
Collection<? extends Action<S, E>> entryActions, Collection<? extends Action<S, E>> exitActions) {
|
||||
Collection<? extends Action<S, E>> entryActions, Collection<? extends Action<S, E>> exitActions,
|
||||
Collection<? extends Action<S, E>> stateActions) {
|
||||
StateData<S, E> stateData = incomplete.get(state);
|
||||
if (stateData == null) {
|
||||
stateData = new StateData<S, E>(parent, region, state, deferred, entryActions, exitActions);
|
||||
@@ -261,6 +278,9 @@ public class DefaultStateConfigurer<S, E>
|
||||
if (stateData.getExitActions() == null) {
|
||||
stateData.setExitActions(exitActions);
|
||||
}
|
||||
if (stateData.getStateActions() == null) {
|
||||
stateData.setStateActions(stateActions);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -91,6 +91,24 @@ public interface StateConfigurer<S, E> extends
|
||||
*/
|
||||
StateConfigurer<S, E> state(S state, StateMachineFactory<S, E> stateMachineFactory);
|
||||
|
||||
/**
|
||||
* Specify a state {@code S} with state {@link Action}s.
|
||||
*
|
||||
* @param state the state
|
||||
* @param stateActions the state actions
|
||||
* @return configurer for chaining
|
||||
*/
|
||||
StateConfigurer<S, E> state(S state, Collection<? extends Action<S, E>> stateActions);
|
||||
|
||||
/**
|
||||
* Specify a state {@code S} with state {@link Action}.
|
||||
*
|
||||
* @param state the state
|
||||
* @param stateAction the state action
|
||||
* @return configurer for chaining
|
||||
*/
|
||||
StateConfigurer<S, E> state(S state, Action<S, E> stateAction);
|
||||
|
||||
/**
|
||||
* Specify a state {@code S} with entry and exit {@link Action}s.
|
||||
*
|
||||
|
||||
@@ -44,6 +44,7 @@ public class StateData<S, E> {
|
||||
private Collection<E> deferred;
|
||||
private Collection<? extends Action<S, E>> entryActions;
|
||||
private Collection<? extends Action<S, E>> exitActions;
|
||||
private Collection<? extends Action<S, E>> stateActions;
|
||||
private boolean initial = false;
|
||||
private Action<S, E> initialAction;
|
||||
private boolean end = false;
|
||||
@@ -243,6 +244,24 @@ public class StateData<S, E> {
|
||||
this.exitActions = exitActions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the state actions.
|
||||
*
|
||||
* @return the state actions
|
||||
*/
|
||||
public Collection<? extends Action<S, E>> getStateActions() {
|
||||
return stateActions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the state actions.
|
||||
*
|
||||
* @param stateActions the state actions
|
||||
*/
|
||||
public void setStateActions(Collection<? extends Action<S, E>> stateActions) {
|
||||
this.stateActions = stateActions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the parent.
|
||||
*
|
||||
|
||||
@@ -127,6 +127,26 @@ public abstract class AbstractSimpleState<S, E> extends AbstractState<S, E> {
|
||||
this.ids.add(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new abstract simple state.
|
||||
*
|
||||
* @param id the id
|
||||
* @param deferred the deferred
|
||||
* @param entryActions the entry actions
|
||||
* @param exitActions the exit actions
|
||||
* @param stateActions the state actions
|
||||
* @param pseudoState the pseudo state
|
||||
* @param regions the regions
|
||||
* @param submachine the submachine
|
||||
*/
|
||||
public AbstractSimpleState(S id, Collection<E> deferred, Collection<? extends Action<S, E>> entryActions,
|
||||
Collection<? extends Action<S, E>> exitActions, Collection<? extends Action<S, E>> stateActions,
|
||||
PseudoState<S, E> pseudoState, Collection<Region<S, E>> regions, StateMachine<S, E> submachine) {
|
||||
super(id, deferred, entryActions, exitActions, stateActions, pseudoState, regions, submachine);
|
||||
this.ids = new ArrayList<S>();
|
||||
this.ids.add(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<S> getIds() {
|
||||
return Collections.unmodifiableCollection(ids);
|
||||
|
||||
@@ -17,13 +17,19 @@ package org.springframework.statemachine.state;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.scheduling.TaskScheduler;
|
||||
import org.springframework.statemachine.StateContext;
|
||||
import org.springframework.statemachine.StateMachine;
|
||||
import org.springframework.statemachine.action.Action;
|
||||
import org.springframework.statemachine.region.Region;
|
||||
import org.springframework.statemachine.support.LifecycleObjectSupport;
|
||||
import org.springframework.statemachine.trigger.Trigger;
|
||||
|
||||
/**
|
||||
@@ -34,17 +40,21 @@ import org.springframework.statemachine.trigger.Trigger;
|
||||
* @param <S> the type of state
|
||||
* @param <E> the type of event
|
||||
*/
|
||||
public abstract class AbstractState<S, E> implements State<S, E> {
|
||||
public abstract class AbstractState<S, E> extends LifecycleObjectSupport implements State<S, E> {
|
||||
|
||||
private static final Log log = LogFactory.getLog(AbstractState.class);
|
||||
|
||||
private final S id;
|
||||
private final PseudoState<S, E> pseudoState;
|
||||
private final Collection<E> deferred;
|
||||
private final Collection<? extends Action<S, E>> entryActions;
|
||||
private final Collection<? extends Action<S, E>> exitActions;
|
||||
private final Collection<? extends Action<S, E>> stateActions;
|
||||
private final Collection<Region<S, E>> regions = new ArrayList<Region<S, E>>();
|
||||
private final StateMachine<S, E> submachine;
|
||||
private List<Trigger<S, E>> triggers = new ArrayList<Trigger<S, E>>();
|
||||
private final CompositeStateListener<S, E> stateListener = new CompositeStateListener<S, E>();
|
||||
private final List<ScheduledFuture<?>> cancellableActions = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* Instantiates a new abstract state.
|
||||
@@ -134,13 +144,32 @@ public abstract class AbstractState<S, E> implements State<S, E> {
|
||||
* @param regions the regions
|
||||
* @param submachine the submachine
|
||||
*/
|
||||
private AbstractState(S id, Collection<E> deferred, Collection<? extends Action<S, E>> entryActions,
|
||||
public AbstractState(S id, Collection<E> deferred, Collection<? extends Action<S, E>> entryActions,
|
||||
Collection<? extends Action<S, E>> exitActions, PseudoState<S, E> pseudoState, Collection<Region<S, E>> regions,
|
||||
StateMachine<S, E> submachine) {
|
||||
this(id, deferred, entryActions, exitActions, null, pseudoState, regions, submachine);
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new abstract state.
|
||||
*
|
||||
* @param id the state identifier
|
||||
* @param deferred the deferred
|
||||
* @param entryActions the entry actions
|
||||
* @param exitActions the exit actions
|
||||
* @param stateActions the state actions
|
||||
* @param pseudoState the pseudo state
|
||||
* @param regions the regions
|
||||
* @param submachine the submachine
|
||||
*/
|
||||
public AbstractState(S id, Collection<E> deferred, Collection<? extends Action<S, E>> entryActions,
|
||||
Collection<? extends Action<S, E>> exitActions, Collection<? extends Action<S, E>> stateActions,
|
||||
PseudoState<S, E> pseudoState, Collection<Region<S, E>> regions, StateMachine<S, E> submachine) {
|
||||
this.id = id;
|
||||
this.deferred = deferred;
|
||||
this.entryActions = entryActions;
|
||||
this.exitActions = exitActions;
|
||||
this.stateActions = stateActions;
|
||||
this.pseudoState = pseudoState;
|
||||
|
||||
// use of private ctor should prevent user to
|
||||
@@ -163,6 +192,7 @@ public abstract class AbstractState<S, E> implements State<S, E> {
|
||||
|
||||
@Override
|
||||
public void exit(StateContext<S, E> context) {
|
||||
cancelStateActions();
|
||||
stateListener.onExit(context);
|
||||
for (Trigger<S, E> trigger : triggers) {
|
||||
trigger.disarm();
|
||||
@@ -175,6 +205,7 @@ public abstract class AbstractState<S, E> implements State<S, E> {
|
||||
for (Trigger<S, E> trigger : triggers) {
|
||||
trigger.arm();
|
||||
}
|
||||
scheduleStateActions(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -256,19 +287,79 @@ public abstract class AbstractState<S, E> implements State<S, E> {
|
||||
return regions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the triggers.
|
||||
*
|
||||
* @param triggers the triggers
|
||||
*/
|
||||
public void setTriggers(List<Trigger<S, E>> triggers) {
|
||||
this.triggers = triggers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the triggers.
|
||||
*
|
||||
* @return the triggers
|
||||
*/
|
||||
public List<Trigger<S, E>> getTriggers() {
|
||||
return triggers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "AbstractState [id=" + id + ", pseudoState=" + pseudoState + ", deferred=" + deferred
|
||||
+ ", entryActions=" + entryActions + ", exitActions=" + exitActions + ", regions=" + regions
|
||||
+ ", submachine=" + submachine + "]";
|
||||
/**
|
||||
* Cancel existing state actions and clear list.
|
||||
*/
|
||||
protected void cancelStateActions() {
|
||||
for (ScheduledFuture<?> future : cancellableActions) {
|
||||
future.cancel(true);
|
||||
}
|
||||
cancellableActions.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* Schedule state actions and store futures into list to
|
||||
* be cancelled.
|
||||
*
|
||||
* @param context the context
|
||||
*/
|
||||
protected void scheduleStateActions(StateContext<S, E> context) {
|
||||
if (stateActions == null) {
|
||||
return;
|
||||
}
|
||||
for (Action<S, E> action : stateActions) {
|
||||
ScheduledFuture<?> future = scheduleAction(action, context);
|
||||
if (future != null) {
|
||||
cancellableActions.add(future);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Schedule action and return future which can be used to cancel it.
|
||||
*
|
||||
* @param action the action
|
||||
* @param context the context
|
||||
* @return the scheduled future
|
||||
*/
|
||||
protected ScheduledFuture<?> scheduleAction(final Action<S, E> action, final StateContext<S, E> context) {
|
||||
TaskScheduler taskScheduler = getTaskScheduler();
|
||||
if (taskScheduler == null) {
|
||||
log.error("Unable to schedule action as taskSchedule is not set, action=[" + action + "]");
|
||||
return null;
|
||||
}
|
||||
ScheduledFuture<?> future = taskScheduler.schedule(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
action.execute(context);
|
||||
}
|
||||
}, new Date());
|
||||
return future;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "AbstractState [id=" + id + ", pseudoState=" + pseudoState + ", deferred=" + deferred + ", entryActions="
|
||||
+ entryActions + ", exitActions=" + exitActions + ", stateActions=" + stateActions + ", regions="
|
||||
+ regions + ", submachine=" + submachine + "]";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -121,6 +121,24 @@ public class ObjectState<S, E> extends AbstractSimpleState<S, E> {
|
||||
super(id, deferred, entryActions, exitActions, pseudoState, submachine);
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new object state.
|
||||
*
|
||||
* @param id the id
|
||||
* @param deferred the deferred
|
||||
* @param entryActions the entry actions
|
||||
* @param exitActions the exit actions
|
||||
* @param stateActions the state actions
|
||||
* @param pseudoState the pseudo state
|
||||
* @param regions the regions
|
||||
* @param submachine the submachine
|
||||
*/
|
||||
public ObjectState(S id, Collection<E> deferred, Collection<? extends Action<S, E>> entryActions,
|
||||
Collection<? extends Action<S, E>> exitActions, Collection<? extends Action<S, E>> stateActions,
|
||||
PseudoState<S, E> pseudoState, Collection<Region<S, E>> regions, StateMachine<S, E> submachine) {
|
||||
super(id, deferred, entryActions, exitActions, stateActions, pseudoState, regions, submachine);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exit(StateContext<S, E> context) {
|
||||
super.exit(context);
|
||||
|
||||
@@ -18,6 +18,7 @@ package org.springframework.statemachine;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
@@ -165,6 +166,8 @@ public abstract class AbstractStateMachineTests {
|
||||
|
||||
long sleep;
|
||||
long now;
|
||||
public AtomicBoolean interrupted = new AtomicBoolean(false);
|
||||
public CountDownLatch interruptedLatch = new CountDownLatch(1);
|
||||
|
||||
public TestSleepAction(long sleep) {
|
||||
super();
|
||||
@@ -178,6 +181,9 @@ public abstract class AbstractStateMachineTests {
|
||||
try {
|
||||
Thread.sleep(sleep);
|
||||
} catch (InterruptedException e) {
|
||||
System.out.println("XXXXX " + e);
|
||||
interrupted.set(true);
|
||||
interruptedLatch.countDown();
|
||||
}
|
||||
}
|
||||
super.execute(context);
|
||||
|
||||
@@ -0,0 +1,252 @@
|
||||
/*
|
||||
* Copyright 2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.statemachine.action;
|
||||
|
||||
import static org.hamcrest.Matchers.containsInAnyOrder;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.hamcrest.Matchers.notNullValue;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.statemachine.AbstractStateMachineTests;
|
||||
import org.springframework.statemachine.StateMachine;
|
||||
import org.springframework.statemachine.StateMachineSystemConstants;
|
||||
import org.springframework.statemachine.config.EnableStateMachine;
|
||||
import org.springframework.statemachine.config.EnumStateMachineConfigurerAdapter;
|
||||
import org.springframework.statemachine.config.builders.StateMachineStateConfigurer;
|
||||
import org.springframework.statemachine.config.builders.StateMachineTransitionConfigurer;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public class StateDoActivityActionTests extends AbstractStateMachineTests {
|
||||
|
||||
@Test
|
||||
public void testSimpleStateActions() throws Exception {
|
||||
context.register(Config1.class);
|
||||
context.refresh();
|
||||
StateMachine<TestStates,TestEvents> machine =
|
||||
context.getBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE, StateMachine.class);
|
||||
TestAction testActionS1 = context.getBean("testActionS1", TestAction.class);
|
||||
TestAction testActionS2 = context.getBean("testActionS2", TestAction.class);
|
||||
|
||||
assertThat(machine, notNullValue());
|
||||
machine.start();
|
||||
|
||||
machine.sendEvent(TestEvents.E1);
|
||||
assertThat(testActionS1.onExecuteLatch.await(2, TimeUnit.SECONDS), is(true));
|
||||
|
||||
machine.sendEvent(TestEvents.E2);
|
||||
assertThat(testActionS2.onExecuteLatch.await(2, TimeUnit.SECONDS), is(true));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testExitAbortsAction() throws Exception {
|
||||
context.register(Config2.class);
|
||||
context.refresh();
|
||||
StateMachine<TestStates,TestEvents> machine =
|
||||
context.getBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE, StateMachine.class);
|
||||
TestSleepAction testActionS1 = context.getBean("testActionS1", TestSleepAction.class);
|
||||
TestSleepAction testActionS2 = context.getBean("testActionS2", TestSleepAction.class);
|
||||
|
||||
assertThat(machine, notNullValue());
|
||||
machine.start();
|
||||
|
||||
machine.sendEvent(TestEvents.E1);
|
||||
assertThat(testActionS1.interruptedLatch.await(2, TimeUnit.SECONDS), is(true));
|
||||
assertThat(testActionS1.onExecuteLatch.await(2, TimeUnit.SECONDS), is(true));
|
||||
|
||||
machine.sendEvent(TestEvents.E2);
|
||||
assertThat(testActionS2.interruptedLatch.await(2, TimeUnit.SECONDS), is(true));
|
||||
assertThat(testActionS2.onExecuteLatch.await(2, TimeUnit.SECONDS), is(true));
|
||||
assertThat(machine.getState().getIds(), containsInAnyOrder(TestStates.S3));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInternalTransitionDoesNotAbort() throws Exception {
|
||||
context.register(Config3.class);
|
||||
context.refresh();
|
||||
StateMachine<TestStates,TestEvents> machine =
|
||||
context.getBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE, StateMachine.class);
|
||||
TestSleepAction testActionS1 = context.getBean("testActionS1", TestSleepAction.class);
|
||||
TestSleepAction testActionS2 = context.getBean("testActionS2", TestSleepAction.class);
|
||||
TestAction testActionS1I = context.getBean("testActionS1I", TestAction.class);
|
||||
TestAction testActionS2I = context.getBean("testActionS2I", TestAction.class);
|
||||
|
||||
assertThat(machine, notNullValue());
|
||||
machine.start();
|
||||
machine.sendEvent(TestEvents.E3);
|
||||
assertThat(testActionS1I.onExecuteLatch.await(2, TimeUnit.SECONDS), is(true));
|
||||
assertThat(testActionS1.interruptedLatch.await(2, TimeUnit.SECONDS), is(false));
|
||||
machine.sendEvent(TestEvents.E1);
|
||||
|
||||
machine.sendEvent(TestEvents.E4);
|
||||
assertThat(testActionS2I.onExecuteLatch.await(2, TimeUnit.SECONDS), is(true));
|
||||
assertThat(testActionS2.interruptedLatch.await(2, TimeUnit.SECONDS), is(false));
|
||||
machine.sendEvent(TestEvents.E2);
|
||||
|
||||
assertThat(testActionS1.interruptedLatch.await(2, TimeUnit.SECONDS), is(true));
|
||||
assertThat(testActionS2.interruptedLatch.await(2, TimeUnit.SECONDS), is(true));
|
||||
assertThat(testActionS1.onExecuteLatch.await(2, TimeUnit.SECONDS), is(true));
|
||||
assertThat(testActionS2.onExecuteLatch.await(2, TimeUnit.SECONDS), is(true));
|
||||
assertThat(machine.getState().getIds(), containsInAnyOrder(TestStates.S3));
|
||||
}
|
||||
|
||||
@Configuration
|
||||
@EnableStateMachine
|
||||
static class Config1 extends EnumStateMachineConfigurerAdapter<TestStates, TestEvents> {
|
||||
|
||||
@Override
|
||||
public void configure(StateMachineStateConfigurer<TestStates, TestEvents> states) throws Exception {
|
||||
states
|
||||
.withStates()
|
||||
.initial(TestStates.S1)
|
||||
.state(TestStates.S1, testActionS1())
|
||||
.state(TestStates.S2, testActionS2())
|
||||
.state(TestStates.S3);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void configure(StateMachineTransitionConfigurer<TestStates, TestEvents> transitions) throws Exception {
|
||||
transitions
|
||||
.withExternal()
|
||||
.source(TestStates.S1)
|
||||
.target(TestStates.S2)
|
||||
.event(TestEvents.E1)
|
||||
.and()
|
||||
.withExternal()
|
||||
.source(TestStates.S2)
|
||||
.target(TestStates.S3)
|
||||
.event(TestEvents.E2);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public TestAction testActionS1() {
|
||||
return new TestAction();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public TestAction testActionS2() {
|
||||
return new TestAction();
|
||||
}
|
||||
}
|
||||
|
||||
@Configuration
|
||||
@EnableStateMachine
|
||||
static class Config2 extends EnumStateMachineConfigurerAdapter<TestStates, TestEvents> {
|
||||
|
||||
@Override
|
||||
public void configure(StateMachineStateConfigurer<TestStates, TestEvents> states) throws Exception {
|
||||
states
|
||||
.withStates()
|
||||
.initial(TestStates.S1)
|
||||
.state(TestStates.S1, testActionS1())
|
||||
.state(TestStates.S2, testActionS2())
|
||||
.state(TestStates.S3);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void configure(StateMachineTransitionConfigurer<TestStates, TestEvents> transitions) throws Exception {
|
||||
transitions
|
||||
.withExternal()
|
||||
.source(TestStates.S1)
|
||||
.target(TestStates.S2)
|
||||
.event(TestEvents.E1)
|
||||
.and()
|
||||
.withExternal()
|
||||
.source(TestStates.S2)
|
||||
.target(TestStates.S3)
|
||||
.event(TestEvents.E2);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public TestSleepAction testActionS1() {
|
||||
return new TestSleepAction(5000);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public TestSleepAction testActionS2() {
|
||||
return new TestSleepAction(5000);
|
||||
}
|
||||
}
|
||||
|
||||
@Configuration
|
||||
@EnableStateMachine
|
||||
static class Config3 extends EnumStateMachineConfigurerAdapter<TestStates, TestEvents> {
|
||||
|
||||
@Override
|
||||
public void configure(StateMachineStateConfigurer<TestStates, TestEvents> states) throws Exception {
|
||||
states
|
||||
.withStates()
|
||||
.initial(TestStates.S1)
|
||||
.state(TestStates.S1, testActionS1())
|
||||
.state(TestStates.S2, testActionS2())
|
||||
.state(TestStates.S3);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void configure(StateMachineTransitionConfigurer<TestStates, TestEvents> transitions) throws Exception {
|
||||
transitions
|
||||
.withExternal()
|
||||
.source(TestStates.S1)
|
||||
.target(TestStates.S2)
|
||||
.event(TestEvents.E1)
|
||||
.and()
|
||||
.withExternal()
|
||||
.source(TestStates.S2)
|
||||
.target(TestStates.S3)
|
||||
.event(TestEvents.E2)
|
||||
.and()
|
||||
.withInternal()
|
||||
.source(TestStates.S1)
|
||||
.event(TestEvents.E3)
|
||||
.action(testActionS1I())
|
||||
.and()
|
||||
.withInternal()
|
||||
.source(TestStates.S2)
|
||||
.event(TestEvents.E4)
|
||||
.action(testActionS2I());
|
||||
}
|
||||
|
||||
@Bean
|
||||
public TestSleepAction testActionS1() {
|
||||
return new TestSleepAction(5000);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public TestSleepAction testActionS2() {
|
||||
return new TestSleepAction(5000);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public TestAction testActionS1I() {
|
||||
return new TestAction();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public TestAction testActionS2I() {
|
||||
return new TestAction();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected AnnotationConfigApplicationContext buildContext() {
|
||||
return new AnnotationConfigApplicationContext();
|
||||
}
|
||||
}
|
||||
@@ -438,6 +438,26 @@ public class UmlModelParser {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (state.getDoActivity() instanceof OpaqueBehavior) {
|
||||
String beanId = UmlUtils.resolveBodyByLanguage(LANGUAGE_BEAN, (OpaqueBehavior)state.getDoActivity());
|
||||
if (StringUtils.hasText(beanId)) {
|
||||
Action<String, String> bean = resolver.resolveAction(beanId);
|
||||
if (bean != null) {
|
||||
ArrayList<Action<String, String>> stateActions = new ArrayList<Action<String, String>>();
|
||||
stateActions.add(bean);
|
||||
stateData.setStateActions(stateActions);
|
||||
}
|
||||
} else {
|
||||
String expression = UmlUtils.resolveBodyByLanguage(LANGUAGE_SPEL, (OpaqueBehavior)state.getDoActivity());
|
||||
if (StringUtils.hasText(expression)) {
|
||||
SpelExpressionParser parser = new SpelExpressionParser(
|
||||
new SpelParserConfiguration(SpelCompilerMode.MIXED, null));
|
||||
ArrayList<Action<String, String>> stateActions = new ArrayList<Action<String, String>>();
|
||||
stateActions.add(new SpelExpressionAction<String, String>(parser.parseExpression(expression)));
|
||||
stateData.setExitActions(stateActions);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (state.getEntry() instanceof Activity) {
|
||||
String beanId = ((Activity)state.getEntry()).getName();
|
||||
Action<String, String> bean = resolver.resolveAction(beanId);
|
||||
@@ -456,6 +476,15 @@ public class UmlModelParser {
|
||||
stateData.setExitActions(exits);
|
||||
}
|
||||
}
|
||||
if (state.getDoActivity() instanceof Activity) {
|
||||
String beanId = ((Activity)state.getDoActivity()).getName();
|
||||
Action<String, String> bean = resolver.resolveAction(beanId);
|
||||
if (bean != null) {
|
||||
ArrayList<Action<String, String>> stateActions = new ArrayList<Action<String, String>>();
|
||||
stateActions.add(bean);
|
||||
stateData.setStateActions(stateActions);
|
||||
}
|
||||
}
|
||||
return stateData;
|
||||
}
|
||||
|
||||
|
||||
@@ -658,6 +658,24 @@ public class UmlStateMachineModelFactoryTests extends AbstractUmlTests {
|
||||
assertThat(stateMachine.getState().getIds(), containsInAnyOrder("S2", "S21", "S31"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
public void testSimpleStateActions() throws Exception {
|
||||
context.register(Config22.class);
|
||||
context.refresh();
|
||||
StateMachine<String, String> stateMachine = context.getBean(StateMachine.class);
|
||||
LatchAction e1Action = context.getBean("e1Action", LatchAction.class);
|
||||
LatchAction e2Action = context.getBean("e2Action", LatchAction.class);
|
||||
stateMachine.start();
|
||||
assertThat(stateMachine.getState().getIds(), containsInAnyOrder("S1"));
|
||||
stateMachine.sendEvent("E1");
|
||||
assertThat(e1Action.latch.await(1, TimeUnit.SECONDS), is(true));
|
||||
assertThat(stateMachine.getState().getIds(), containsInAnyOrder("S2"));
|
||||
stateMachine.sendEvent("E2");
|
||||
assertThat(e2Action.latch.await(1, TimeUnit.SECONDS), is(true));
|
||||
assertThat(stateMachine.getState().getIds(), containsInAnyOrder("S3"));
|
||||
}
|
||||
|
||||
@Configuration
|
||||
@EnableStateMachine
|
||||
public static class Config2 extends StateMachineConfigurerAdapter<String, String> {
|
||||
@@ -1068,6 +1086,33 @@ public class UmlStateMachineModelFactoryTests extends AbstractUmlTests {
|
||||
}
|
||||
}
|
||||
|
||||
@Configuration
|
||||
@EnableStateMachine
|
||||
public static class Config22 extends StateMachineConfigurerAdapter<String, String> {
|
||||
|
||||
@Override
|
||||
public void configure(StateMachineModelConfigurer<String, String> model) throws Exception {
|
||||
model
|
||||
.withModel()
|
||||
.factory(modelFactory());
|
||||
}
|
||||
|
||||
@Bean
|
||||
public StateMachineModelFactory<String, String> modelFactory() {
|
||||
return new UmlStateMachineModelFactory("classpath:org/springframework/statemachine/uml/simple-state-actions.uml");
|
||||
}
|
||||
|
||||
@Bean
|
||||
public LatchAction e1Action() {
|
||||
return new LatchAction();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public LatchAction e2Action() {
|
||||
return new LatchAction();
|
||||
}
|
||||
}
|
||||
|
||||
public static class LatchAction implements Action<String, String> {
|
||||
CountDownLatch latch = new CountDownLatch(1);
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<xmi:XMI xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI"/>
|
||||
@@ -0,0 +1,142 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<notation:Diagram xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" xmlns:notation="http://www.eclipse.org/gmf/runtime/1.0.2/notation" xmlns:style="http://www.eclipse.org/papyrus/infra/viewpoints/policy/style" xmlns:uml="http://www.eclipse.org/uml2/5.0.0/UML" xmi:id="_HdPi0GFnEeayxc_c7moBjA" type="PapyrusUMLStateMachineDiagram" name="StateMachine Diagram" measurementUnit="Pixel">
|
||||
<children xmi:type="notation:Shape" xmi:id="_HdPi0WFnEeayxc_c7moBjA" type="StateMachine_Shape">
|
||||
<children xmi:type="notation:DecorationNode" xmi:id="_HdPi0mFnEeayxc_c7moBjA" type="StateMachine_NameLabel">
|
||||
<layoutConstraint xmi:type="notation:Bounds" xmi:id="_HdPi02FnEeayxc_c7moBjA" width="471" height="20"/>
|
||||
</children>
|
||||
<children xmi:type="notation:BasicCompartment" xmi:id="_HdPi1GFnEeayxc_c7moBjA" type="StateMachine_RegionCompartment">
|
||||
<children xmi:type="notation:Shape" xmi:id="_HdPi1WFnEeayxc_c7moBjA" type="Region_Shape">
|
||||
<eAnnotations xmi:type="ecore:EAnnotation" xmi:id="_HdPi1mFnEeayxc_c7moBjA" source="RegionAnnotationKey">
|
||||
<details xmi:type="ecore:EStringToStringMapEntry" xmi:id="_HdPi12FnEeayxc_c7moBjA" key="RegionZoneKey" value=""/>
|
||||
</eAnnotations>
|
||||
<children xmi:type="notation:BasicCompartment" xmi:id="_HdPi2GFnEeayxc_c7moBjA" type="Region_SubvertexCompartment">
|
||||
<children xmi:type="notation:Shape" xmi:id="_J_gEMGFnEeayxc_c7moBjA" type="State_Shape">
|
||||
<children xmi:type="notation:DecorationNode" xmi:id="_J_gEMmFnEeayxc_c7moBjA" type="State_NameLabel">
|
||||
<layoutConstraint xmi:type="notation:Bounds" xmi:id="_SDhlAGFnEeayxc_c7moBjA" width="245"/>
|
||||
</children>
|
||||
<children xmi:type="notation:DecorationNode" xmi:id="_J_gEM2FnEeayxc_c7moBjA" type="State_FloatingNameLabel">
|
||||
<layoutConstraint xmi:type="notation:Location" xmi:id="_J_gENGFnEeayxc_c7moBjA" x="40"/>
|
||||
</children>
|
||||
<children xmi:type="notation:BasicCompartment" xmi:id="_J_grQGFnEeayxc_c7moBjA" type="State_RegionCompartment">
|
||||
<layoutConstraint xmi:type="notation:Bounds" xmi:id="_J_grQWFnEeayxc_c7moBjA" y="-1" width="245"/>
|
||||
</children>
|
||||
<children xmi:type="notation:BasicCompartment" xmi:id="_J_ljwGFnEeayxc_c7moBjA" type="compartment_shape_display">
|
||||
<styles xmi:type="notation:TitleStyle" xmi:id="_J_ljwWFnEeayxc_c7moBjA"/>
|
||||
<layoutConstraint xmi:type="notation:Bounds" xmi:id="_J_ljwmFnEeayxc_c7moBjA"/>
|
||||
</children>
|
||||
<children xmi:type="notation:Shape" xmi:id="_OfiEYGFoEeayxc_c7moBjA" type="Behavior_DoActivityBehaviorLabel">
|
||||
<element xmi:type="uml:OpaqueBehavior" href="simple-state-actions.uml#_OfGmkGFoEeayxc_c7moBjA"/>
|
||||
<layoutConstraint xmi:type="notation:Location" xmi:id="_OfiEYWFoEeayxc_c7moBjA" x="-10" y="-10"/>
|
||||
</children>
|
||||
<element xmi:type="uml:State" href="simple-state-actions.uml#_J_W6QGFnEeayxc_c7moBjA"/>
|
||||
<layoutConstraint xmi:type="notation:Bounds" xmi:id="_J_gEMWFnEeayxc_c7moBjA" x="110" y="34" width="245" height="44"/>
|
||||
</children>
|
||||
<children xmi:type="notation:Shape" xmi:id="_Le3lMGFnEeayxc_c7moBjA" type="State_Shape">
|
||||
<children xmi:type="notation:DecorationNode" xmi:id="_Le4MQGFnEeayxc_c7moBjA" type="State_NameLabel">
|
||||
<layoutConstraint xmi:type="notation:Bounds" xmi:id="_a1vMEGFoEeayxc_c7moBjA" width="245"/>
|
||||
</children>
|
||||
<children xmi:type="notation:DecorationNode" xmi:id="_Le4MQWFnEeayxc_c7moBjA" type="State_FloatingNameLabel">
|
||||
<layoutConstraint xmi:type="notation:Location" xmi:id="_Le4MQmFnEeayxc_c7moBjA" x="40"/>
|
||||
</children>
|
||||
<children xmi:type="notation:BasicCompartment" xmi:id="_Le4MQ2FnEeayxc_c7moBjA" type="State_RegionCompartment">
|
||||
<layoutConstraint xmi:type="notation:Bounds" xmi:id="_Le4MRGFnEeayxc_c7moBjA" y="-1" width="245"/>
|
||||
</children>
|
||||
<children xmi:type="notation:BasicCompartment" xmi:id="_Le9r0GFnEeayxc_c7moBjA" type="compartment_shape_display">
|
||||
<styles xmi:type="notation:TitleStyle" xmi:id="_Le9r0WFnEeayxc_c7moBjA"/>
|
||||
<layoutConstraint xmi:type="notation:Bounds" xmi:id="_Le9r0mFnEeayxc_c7moBjA"/>
|
||||
</children>
|
||||
<children xmi:type="notation:Shape" xmi:id="_VxU3AGFoEeayxc_c7moBjA" type="Behavior_DoActivityBehaviorLabel">
|
||||
<element xmi:type="uml:OpaqueBehavior" href="simple-state-actions.uml#_VxNiQGFoEeayxc_c7moBjA"/>
|
||||
<layoutConstraint xmi:type="notation:Location" xmi:id="_VxU3AWFoEeayxc_c7moBjA" x="-10" y="-10"/>
|
||||
</children>
|
||||
<element xmi:type="uml:State" href="simple-state-actions.uml#_LeyFoGFnEeayxc_c7moBjA"/>
|
||||
<layoutConstraint xmi:type="notation:Bounds" xmi:id="_Le3lMWFnEeayxc_c7moBjA" x="111" y="122" width="245" height="44"/>
|
||||
</children>
|
||||
<children xmi:type="notation:Shape" xmi:id="_NL0PMGFnEeayxc_c7moBjA" type="State_Shape">
|
||||
<children xmi:type="notation:DecorationNode" xmi:id="_NL02QGFnEeayxc_c7moBjA" type="State_NameLabel">
|
||||
<layoutConstraint xmi:type="notation:Bounds" xmi:id="_f81owGFoEeayxc_c7moBjA" width="245"/>
|
||||
</children>
|
||||
<children xmi:type="notation:DecorationNode" xmi:id="_NL02QWFnEeayxc_c7moBjA" type="State_FloatingNameLabel">
|
||||
<layoutConstraint xmi:type="notation:Location" xmi:id="_NL02QmFnEeayxc_c7moBjA" x="40"/>
|
||||
</children>
|
||||
<children xmi:type="notation:BasicCompartment" xmi:id="_NL02Q2FnEeayxc_c7moBjA" type="State_RegionCompartment">
|
||||
<layoutConstraint xmi:type="notation:Bounds" xmi:id="_NL02RGFnEeayxc_c7moBjA" y="-1" width="245"/>
|
||||
</children>
|
||||
<element xmi:type="uml:State" href="simple-state-actions.uml#_NLuIkGFnEeayxc_c7moBjA"/>
|
||||
<layoutConstraint xmi:type="notation:Bounds" xmi:id="_NL0PMWFnEeayxc_c7moBjA" x="111" y="206" width="245"/>
|
||||
</children>
|
||||
<children xmi:type="notation:Shape" xmi:id="_OULlcGFnEeayxc_c7moBjA" type="Pseudostate_InitialShape">
|
||||
<children xmi:type="notation:DecorationNode" xmi:id="_OUMMgGFnEeayxc_c7moBjA" type="Pseudostate_InitialFloatingNameLabel">
|
||||
<layoutConstraint xmi:type="notation:Location" xmi:id="_OUMMgWFnEeayxc_c7moBjA" x="25" y="3"/>
|
||||
</children>
|
||||
<children xmi:type="notation:DecorationNode" xmi:id="_OUMMgmFnEeayxc_c7moBjA" type="Pseudostate_InitialStereotypeLabel">
|
||||
<layoutConstraint xmi:type="notation:Location" xmi:id="_OUMzkGFnEeayxc_c7moBjA" x="25" y="-10"/>
|
||||
</children>
|
||||
<element xmi:type="uml:Pseudostate" href="simple-state-actions.uml#_OUDCkGFnEeayxc_c7moBjA"/>
|
||||
<layoutConstraint xmi:type="notation:Bounds" xmi:id="_OULlcWFnEeayxc_c7moBjA" x="34" y="42"/>
|
||||
</children>
|
||||
<layoutConstraint xmi:type="notation:Bounds" xmi:id="_HdPi2WFnEeayxc_c7moBjA"/>
|
||||
</children>
|
||||
<element xmi:type="uml:Region" href="simple-state-actions.uml#_HdOUsGFnEeayxc_c7moBjA"/>
|
||||
<layoutConstraint xmi:type="notation:Bounds" xmi:id="_HdPi2mFnEeayxc_c7moBjA" width="471" height="271"/>
|
||||
</children>
|
||||
<layoutConstraint xmi:type="notation:Bounds" xmi:id="_HdPi22FnEeayxc_c7moBjA" y="20" width="471" height="271"/>
|
||||
</children>
|
||||
<element xmi:type="uml:StateMachine" href="simple-state-actions.uml#_HdEjsGFnEeayxc_c7moBjA"/>
|
||||
<layoutConstraint xmi:type="notation:Bounds" xmi:id="_HdPi3GFnEeayxc_c7moBjA" x="30" y="30" width="471" height="291"/>
|
||||
</children>
|
||||
<styles xmi:type="notation:StringValueStyle" xmi:id="_HdPi3WFnEeayxc_c7moBjA" name="diagram_compatibility_version" stringValue="1.2.0"/>
|
||||
<styles xmi:type="notation:DiagramStyle" xmi:id="_HdPi3mFnEeayxc_c7moBjA"/>
|
||||
<styles xmi:type="style:PapyrusViewStyle" xmi:id="_HdPi32FnEeayxc_c7moBjA">
|
||||
<owner xmi:type="uml:Model" href="simple-state-actions.uml#_Hc1TIGFnEeayxc_c7moBjA"/>
|
||||
</styles>
|
||||
<element xmi:type="uml:StateMachine" href="simple-state-actions.uml#_HdEjsGFnEeayxc_c7moBjA"/>
|
||||
<edges xmi:type="notation:Connector" xmi:id="_PuQWwGFnEeayxc_c7moBjA" type="Transition_Edge" source="_OULlcGFnEeayxc_c7moBjA" target="_J_gEMGFnEeayxc_c7moBjA">
|
||||
<children xmi:type="notation:DecorationNode" xmi:id="_PuQ90GFnEeayxc_c7moBjA" type="Transition_NameLabel">
|
||||
<layoutConstraint xmi:type="notation:Location" xmi:id="_PuQ90WFnEeayxc_c7moBjA"/>
|
||||
</children>
|
||||
<children xmi:type="notation:DecorationNode" xmi:id="_PuQ90mFnEeayxc_c7moBjA" type="Transition_GuardLabel">
|
||||
<layoutConstraint xmi:type="notation:Location" xmi:id="_PuQ902FnEeayxc_c7moBjA"/>
|
||||
</children>
|
||||
<children xmi:type="notation:DecorationNode" xmi:id="_PuQ91GFnEeayxc_c7moBjA" type="Transition_StereotypeLabel">
|
||||
<layoutConstraint xmi:type="notation:Location" xmi:id="_PuQ91WFnEeayxc_c7moBjA" y="60"/>
|
||||
</children>
|
||||
<styles xmi:type="notation:FontStyle" xmi:id="_PuQWwWFnEeayxc_c7moBjA"/>
|
||||
<element xmi:type="uml:Transition" href="simple-state-actions.uml#_PsRZwGFnEeayxc_c7moBjA"/>
|
||||
<bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_PuQWwmFnEeayxc_c7moBjA" points="[83, 100, -643984, -643984]$[141, 100, -643984, -643984]"/>
|
||||
<sourceAnchor xmi:type="notation:IdentityAnchor" xmi:id="_Pu0-gGFnEeayxc_c7moBjA" id="(0.9,0.4)"/>
|
||||
<targetAnchor xmi:type="notation:IdentityAnchor" xmi:id="_Pu1lkGFnEeayxc_c7moBjA" id="(0.0,0.36363636363636365)"/>
|
||||
</edges>
|
||||
<edges xmi:type="notation:Connector" xmi:id="_QZRpsGFnEeayxc_c7moBjA" type="Transition_Edge" source="_J_gEMGFnEeayxc_c7moBjA" target="_Le3lMGFnEeayxc_c7moBjA">
|
||||
<children xmi:type="notation:DecorationNode" xmi:id="_QZRps2FnEeayxc_c7moBjA" type="Transition_NameLabel">
|
||||
<layoutConstraint xmi:type="notation:Location" xmi:id="_QZRptGFnEeayxc_c7moBjA"/>
|
||||
</children>
|
||||
<children xmi:type="notation:DecorationNode" xmi:id="_QZRptWFnEeayxc_c7moBjA" type="Transition_GuardLabel">
|
||||
<layoutConstraint xmi:type="notation:Location" xmi:id="_QZRptmFnEeayxc_c7moBjA" x="-5" y="25"/>
|
||||
</children>
|
||||
<children xmi:type="notation:DecorationNode" xmi:id="_QZRpt2FnEeayxc_c7moBjA" type="Transition_StereotypeLabel">
|
||||
<layoutConstraint xmi:type="notation:Location" xmi:id="_QZRpuGFnEeayxc_c7moBjA" y="60"/>
|
||||
</children>
|
||||
<styles xmi:type="notation:FontStyle" xmi:id="_QZRpsWFnEeayxc_c7moBjA"/>
|
||||
<element xmi:type="uml:Transition" href="simple-state-actions.uml#_QZHRoGFnEeayxc_c7moBjA"/>
|
||||
<bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_QZRpsmFnEeayxc_c7moBjA"/>
|
||||
<sourceAnchor xmi:type="notation:IdentityAnchor" xmi:id="_QZqEMGFnEeayxc_c7moBjA" id="(0.4775510204081633,1.0)"/>
|
||||
<targetAnchor xmi:type="notation:IdentityAnchor" xmi:id="_QZqrQGFnEeayxc_c7moBjA" id="(0.47346938775510206,0.0)"/>
|
||||
</edges>
|
||||
<edges xmi:type="notation:Connector" xmi:id="_RAfasGFnEeayxc_c7moBjA" type="Transition_Edge" source="_Le3lMGFnEeayxc_c7moBjA" target="_NL0PMGFnEeayxc_c7moBjA">
|
||||
<children xmi:type="notation:DecorationNode" xmi:id="_RAfas2FnEeayxc_c7moBjA" type="Transition_NameLabel">
|
||||
<layoutConstraint xmi:type="notation:Location" xmi:id="_RAfatGFnEeayxc_c7moBjA"/>
|
||||
</children>
|
||||
<children xmi:type="notation:DecorationNode" xmi:id="_RAfatWFnEeayxc_c7moBjA" type="Transition_GuardLabel">
|
||||
<layoutConstraint xmi:type="notation:Location" xmi:id="_RAfatmFnEeayxc_c7moBjA" x="-4" y="29"/>
|
||||
</children>
|
||||
<children xmi:type="notation:DecorationNode" xmi:id="_RAfat2FnEeayxc_c7moBjA" type="Transition_StereotypeLabel">
|
||||
<layoutConstraint xmi:type="notation:Location" xmi:id="_RAfauGFnEeayxc_c7moBjA" y="60"/>
|
||||
</children>
|
||||
<styles xmi:type="notation:FontStyle" xmi:id="_RAfasWFnEeayxc_c7moBjA"/>
|
||||
<element xmi:type="uml:Transition" href="simple-state-actions.uml#_RAVpsGFnEeayxc_c7moBjA"/>
|
||||
<bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_RAfasmFnEeayxc_c7moBjA"/>
|
||||
<sourceAnchor xmi:type="notation:IdentityAnchor" xmi:id="_RA3OIGFnEeayxc_c7moBjA" id="(0.4489795918367347,1.0)"/>
|
||||
<targetAnchor xmi:type="notation:IdentityAnchor" xmi:id="_RA3OIWFnEeayxc_c7moBjA" id="(0.4489795918367347,0.0)"/>
|
||||
</edges>
|
||||
</notation:Diagram>
|
||||
@@ -0,0 +1,32 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<uml:Model xmi:version="20131001" xmlns:xmi="http://www.omg.org/spec/XMI/20131001" xmlns:uml="http://www.eclipse.org/uml2/5.0.0/UML" xmi:id="_Hc1TIGFnEeayxc_c7moBjA" name="RootElement">
|
||||
<packagedElement xmi:type="uml:StateMachine" xmi:id="_HdEjsGFnEeayxc_c7moBjA" name="StateMachine">
|
||||
<region xmi:type="uml:Region" xmi:id="_HdOUsGFnEeayxc_c7moBjA" name="Region1">
|
||||
<transition xmi:type="uml:Transition" xmi:id="_PsRZwGFnEeayxc_c7moBjA" source="_OUDCkGFnEeayxc_c7moBjA" target="_J_W6QGFnEeayxc_c7moBjA"/>
|
||||
<transition xmi:type="uml:Transition" xmi:id="_QZHRoGFnEeayxc_c7moBjA" source="_J_W6QGFnEeayxc_c7moBjA" target="_LeyFoGFnEeayxc_c7moBjA">
|
||||
<trigger xmi:type="uml:Trigger" xmi:id="_GC85oGFoEeayxc_c7moBjA" event="_-Q-yIGFnEeayxc_c7moBjA"/>
|
||||
</transition>
|
||||
<transition xmi:type="uml:Transition" xmi:id="_RAVpsGFnEeayxc_c7moBjA" source="_LeyFoGFnEeayxc_c7moBjA" target="_NLuIkGFnEeayxc_c7moBjA">
|
||||
<trigger xmi:type="uml:Trigger" xmi:id="_IBUq0GFoEeayxc_c7moBjA" event="_BOMKIGFoEeayxc_c7moBjA"/>
|
||||
</transition>
|
||||
<subvertex xmi:type="uml:State" xmi:id="_J_W6QGFnEeayxc_c7moBjA" name="S1">
|
||||
<doActivity xmi:type="uml:OpaqueBehavior" xmi:id="_OfGmkGFoEeayxc_c7moBjA" name="e1Action">
|
||||
<language>bean</language>
|
||||
<body>e1Action</body>
|
||||
</doActivity>
|
||||
</subvertex>
|
||||
<subvertex xmi:type="uml:State" xmi:id="_LeyFoGFnEeayxc_c7moBjA" name="S2">
|
||||
<doActivity xmi:type="uml:OpaqueBehavior" xmi:id="_VxNiQGFoEeayxc_c7moBjA" name="e2Action">
|
||||
<language>bean</language>
|
||||
<body>e2Action</body>
|
||||
</doActivity>
|
||||
</subvertex>
|
||||
<subvertex xmi:type="uml:State" xmi:id="_NLuIkGFnEeayxc_c7moBjA" name="S3"/>
|
||||
<subvertex xmi:type="uml:Pseudostate" xmi:id="_OUDCkGFnEeayxc_c7moBjA" name=""/>
|
||||
</region>
|
||||
</packagedElement>
|
||||
<packagedElement xmi:type="uml:Signal" xmi:id="_5wYUwGFnEeayxc_c7moBjA" name="E1"/>
|
||||
<packagedElement xmi:type="uml:Signal" xmi:id="_8DY5MGFnEeayxc_c7moBjA" name="E2"/>
|
||||
<packagedElement xmi:type="uml:SignalEvent" xmi:id="_-Q-yIGFnEeayxc_c7moBjA" name="SignalEventE1" signal="_5wYUwGFnEeayxc_c7moBjA"/>
|
||||
<packagedElement xmi:type="uml:SignalEvent" xmi:id="_BOMKIGFoEeayxc_c7moBjA" name="SignalEventE2" signal="_8DY5MGFnEeayxc_c7moBjA"/>
|
||||
</uml:Model>
|
||||
Reference in New Issue
Block a user