Update docs

- Add missing docs for @StatesOnTransition supported
  method arguments.
- Fixes #124
This commit is contained in:
Janne Valkealahti
2015-11-20 16:22:04 +00:00
parent baed808847
commit 01dc737bf6
2 changed files with 22 additions and 0 deletions

View File

@@ -679,6 +679,15 @@ Default _@OnTransition_ annotation can't be used with a state and
event enums user have created due to java language limitations, thus
string representation have to be used.
Additionally it is possible to access `Event Headers` and
`ExtendedState` by adding needed arguments to a method. Method
is then called automatically with these arguments.
[source,java,indent=0]
----
include::samples/DocsConfigurationSampleTests.java[tags=snippetII]
----
However if you want to have a type safe annotation it is possible to
create a new annotation and use _@OnTransition_ as meta annotation.
This user level annotation can make a reference to actual states and

View File

@@ -22,6 +22,7 @@ import java.lang.annotation.Target;
import java.util.Arrays;
import java.util.EnumSet;
import java.util.HashSet;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.support.StaticListableBeanFactory;
@@ -36,12 +37,14 @@ import org.springframework.messaging.Message;
import org.springframework.messaging.support.MessageBuilder;
import org.springframework.scheduling.concurrent.ConcurrentTaskScheduler;
import org.springframework.statemachine.AbstractStateMachineTests;
import org.springframework.statemachine.ExtendedState;
import org.springframework.statemachine.StateContext;
import org.springframework.statemachine.StateMachine;
import org.springframework.statemachine.access.StateMachineAccess;
import org.springframework.statemachine.access.StateMachineFunction;
import org.springframework.statemachine.action.Action;
import org.springframework.statemachine.action.SpelExpressionAction;
import org.springframework.statemachine.annotation.EventHeaders;
import org.springframework.statemachine.annotation.OnTransition;
import org.springframework.statemachine.annotation.WithStateMachine;
import org.springframework.statemachine.config.EnableStateMachine;
@@ -415,6 +418,16 @@ public class DocsConfigurationSampleTests extends AbstractStateMachineTests {
}
// end::snippetI[]
// tag::snippetII[]
@WithStateMachine
static class Bean4 {
@StatesOnTransition(source = States.S1, target = States.S2)
public void fromS1ToS2(@EventHeaders Map<String, Object> headers, ExtendedState extendedState) {
}
}
// end::snippetII[]
// tag::snippetJ[]
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)