Update docs
- Add missing docs for @StatesOnTransition supported method arguments. - Fixes #124
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user