diff --git a/spring-statemachine-core/src/main/java/org/springframework/statemachine/StateContext.java b/spring-statemachine-core/src/main/java/org/springframework/statemachine/StateContext.java
index a49fb426..318dd8e1 100644
--- a/spring-statemachine-core/src/main/java/org/springframework/statemachine/StateContext.java
+++ b/spring-statemachine-core/src/main/java/org/springframework/statemachine/StateContext.java
@@ -15,29 +15,44 @@
*/
package org.springframework.statemachine;
+import org.springframework.messaging.Message;
import org.springframework.messaging.MessageHeaders;
import org.springframework.statemachine.action.Action;
import org.springframework.statemachine.guard.Guard;
+import org.springframework.statemachine.state.State;
import org.springframework.statemachine.transition.Transition;
/**
- * {@code StateContext} is representing a current context used in
+ * {@code StateContext} is representing of a current context used in
+ * various stages in a state machine execution. These include for example
* {@link Transition}s, {@link Action}s and {@link Guard}s order to get access
* to event headers and {@link ExtendedState}.
+ *
+ * Context really is not a current state of a state machine but
+ * more like a snapshot of where state machine is when this context
+ * is passed to various methods.
*
* @author Janne Valkealahti
*
*/
public interface StateContext {
+ /**
+ * Gets the message associated with a context. Message may be null if transition
+ * is not triggered by a signal.
+ *
+ * @return the message
+ */
+ Message getMessage();
+
/**
* Gets the event associated with a context. Event may be null if transition
* is not triggered by a signal.
- *
+ *
* @return the event
*/
E getEvent();
-
+
/**
* Gets the event message headers.
*
@@ -75,4 +90,29 @@ public interface StateContext {
*/
StateMachine getStateMachine();
+ /**
+ * Gets the source state of this context. Generally source
+ * is where a state machine is coming from which may be different
+ * than what the transition source is.
+ *
+ * @return the source state
+ */
+ State getSource();
+
+ /**
+ * Gets the tarter state of this context. Generally target
+ * is where a state machine going to which may be different
+ * than what the transition target is.
+ *
+ * @return the target state
+ */
+ State getTarget();
+
+ /**
+ * Gets the exception associated with a context.
+ *
+ * @return the exception
+ */
+ Exception getException();
+
}
diff --git a/spring-statemachine-core/src/main/java/org/springframework/statemachine/annotation/ExtendedStateVariable.java b/spring-statemachine-core/src/main/java/org/springframework/statemachine/annotation/ExtendedStateVariable.java
new file mode 100644
index 00000000..58c7289d
--- /dev/null
+++ b/spring-statemachine-core/src/main/java/org/springframework/statemachine/annotation/ExtendedStateVariable.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2015 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.annotation;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import org.springframework.core.annotation.AliasFor;
+
+@Target(ElementType.PARAMETER)
+@Retention(RetentionPolicy.RUNTIME)
+@Documented
+public @interface ExtendedStateVariable {
+
+ @AliasFor("key")
+ String value() default "";
+
+ @AliasFor("value")
+ String key() default "";
+
+}
diff --git a/spring-statemachine-core/src/main/java/org/springframework/statemachine/annotation/OnEventNotAccepted.java b/spring-statemachine-core/src/main/java/org/springframework/statemachine/annotation/OnEventNotAccepted.java
new file mode 100644
index 00000000..849908db
--- /dev/null
+++ b/spring-statemachine-core/src/main/java/org/springframework/statemachine/annotation/OnEventNotAccepted.java
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2015 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.annotation;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+import java.util.Map;
+
+import org.springframework.statemachine.ExtendedState;
+
+/**
+ * Indicates that a method is candidate to be called when event
+ * is not accepted by a state machine.
+ *
+ * A method annotated with @OnEventNotAccepted may accept a parameter of type
+ * {@link ExtendedState} or {@link Map} if map argument is itself is annotated
+ * with {@link EventHeaders}.
+ *
+ * Return value can be anything and is effectively discarded.
+ *
+ * @author Janne Valkealahti
+ *
+ */
+@Target({ ElementType.TYPE, ElementType.METHOD })
+@Retention(RetentionPolicy.RUNTIME)
+@Inherited
+@Documented
+public @interface OnEventNotAccepted {
+
+ /**
+ * The events.
+ *
+ * @return the events
+ */
+ String[] event() default {};
+
+}
diff --git a/spring-statemachine-core/src/main/java/org/springframework/statemachine/annotation/OnExtendedStateChanged.java b/spring-statemachine-core/src/main/java/org/springframework/statemachine/annotation/OnExtendedStateChanged.java
new file mode 100644
index 00000000..5a3d5928
--- /dev/null
+++ b/spring-statemachine-core/src/main/java/org/springframework/statemachine/annotation/OnExtendedStateChanged.java
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2015 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.annotation;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import org.springframework.statemachine.ExtendedState;
+
+/**
+ * Indicates that a method is candidate to be called when {@link ExtendedState}
+ * is changed.
+ *
+ * Return value can be anything and is effectively discarded.
+ *
+ * @author Janne Valkealahti
+ *
+ */
+@Target({ ElementType.METHOD })
+@Retention(RetentionPolicy.RUNTIME)
+@Inherited
+@Documented
+public @interface OnExtendedStateChanged {
+
+ /**
+ * The extended state variable keys.
+ *
+ * @return The extended state variable keys
+ */
+ String[] key() default {};
+
+}
diff --git a/spring-statemachine-core/src/main/java/org/springframework/statemachine/annotation/OnStateChanged.java b/spring-statemachine-core/src/main/java/org/springframework/statemachine/annotation/OnStateChanged.java
new file mode 100644
index 00000000..43e88bb7
--- /dev/null
+++ b/spring-statemachine-core/src/main/java/org/springframework/statemachine/annotation/OnStateChanged.java
@@ -0,0 +1,62 @@
+/*
+ * Copyright 2015 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.annotation;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+import java.util.Map;
+
+import org.springframework.statemachine.ExtendedState;
+import org.springframework.statemachine.state.State;
+
+/**
+ * Indicates that a method is candidate to be called when {@link State}
+ * is changed.
+ *
+ * A method annotated with @OnStateChanged may accept a parameter of type
+ * {@link ExtendedState} or {@link Map} if map argument is itself is annotated
+ * with {@link EventHeaders}.
+ *
+ * Return value can be anything and is effectively discarded.
+ *
+ * @author Janne Valkealahti
+ *
+ */
+@Target({ ElementType.TYPE, ElementType.METHOD })
+@Retention(RetentionPolicy.RUNTIME)
+@Inherited
+@Documented
+public @interface OnStateChanged {
+
+ /**
+ * The source states.
+ *
+ * @return the source states.
+ */
+ String[] source() default {};
+
+ /**
+ * The target states.
+ *
+ * @return the target states.
+ */
+ String[] target() default {};
+
+}
diff --git a/spring-statemachine-core/src/main/java/org/springframework/statemachine/annotation/OnStateEntry.java b/spring-statemachine-core/src/main/java/org/springframework/statemachine/annotation/OnStateEntry.java
new file mode 100644
index 00000000..2482db09
--- /dev/null
+++ b/spring-statemachine-core/src/main/java/org/springframework/statemachine/annotation/OnStateEntry.java
@@ -0,0 +1,62 @@
+/*
+ * Copyright 2015 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.annotation;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+import java.util.Map;
+
+import org.springframework.statemachine.ExtendedState;
+import org.springframework.statemachine.state.State;
+
+/**
+ * Indicates that a method is candidate to be called when {@link State}
+ * is entered.
+ *
+ * A method annotated with @OnStateChanged may accept a parameter of type
+ * {@link ExtendedState} or {@link Map} if map argument is itself is annotated
+ * with {@link EventHeaders}.
+ *
+ * Return value can be anything and is effectively discarded.
+ *
+ * @author Janne Valkealahti
+ *
+ */
+@Target({ ElementType.TYPE, ElementType.METHOD })
+@Retention(RetentionPolicy.RUNTIME)
+@Inherited
+@Documented
+public @interface OnStateEntry {
+
+ /**
+ * The source states.
+ *
+ * @return the source states.
+ */
+ String[] source() default {};
+
+ /**
+ * The target states.
+ *
+ * @return the target states.
+ */
+ String[] target() default {};
+
+}
diff --git a/spring-statemachine-core/src/main/java/org/springframework/statemachine/annotation/OnStateExit.java b/spring-statemachine-core/src/main/java/org/springframework/statemachine/annotation/OnStateExit.java
new file mode 100644
index 00000000..3add82b1
--- /dev/null
+++ b/spring-statemachine-core/src/main/java/org/springframework/statemachine/annotation/OnStateExit.java
@@ -0,0 +1,62 @@
+/*
+ * Copyright 2015 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.annotation;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+import java.util.Map;
+
+import org.springframework.statemachine.ExtendedState;
+import org.springframework.statemachine.state.State;
+
+/**
+ * Indicates that a method is candidate to be called when {@link State}
+ * is exited.
+ *
+ * A method annotated with @OnStateChanged may accept a parameter of type
+ * {@link ExtendedState} or {@link Map} if map argument is itself is annotated
+ * with {@link EventHeaders}.
+ *
+ * Return value can be anything and is effectively discarded.
+ *
+ * @author Janne Valkealahti
+ *
+ */
+@Target({ ElementType.TYPE, ElementType.METHOD })
+@Retention(RetentionPolicy.RUNTIME)
+@Inherited
+@Documented
+public @interface OnStateExit {
+
+ /**
+ * The source states.
+ *
+ * @return the source states.
+ */
+ String[] source() default {};
+
+ /**
+ * The target states.
+ *
+ * @return the target states.
+ */
+ String[] target() default {};
+
+}
diff --git a/spring-statemachine-core/src/main/java/org/springframework/statemachine/annotation/OnStateMachineError.java b/spring-statemachine-core/src/main/java/org/springframework/statemachine/annotation/OnStateMachineError.java
new file mode 100644
index 00000000..040eee37
--- /dev/null
+++ b/spring-statemachine-core/src/main/java/org/springframework/statemachine/annotation/OnStateMachineError.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2015 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.annotation;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+import java.util.Map;
+
+import org.springframework.statemachine.ExtendedState;
+
+/**
+ * Indicates that a method is candidate to be called when state machine
+ * has been entered in error it cannot recover.
+ *
+ * A method annotated with @OnStateMachineError may accept a parameter of type
+ * {@link ExtendedState} or {@link Map} if map argument is itself is annotated
+ * with {@link EventHeaders}.
+ *
+ * Return value can be anything and is effectively discarded.
+ *
+ * @author Janne Valkealahti
+ *
+ */
+@Target({ ElementType.TYPE, ElementType.METHOD })
+@Retention(RetentionPolicy.RUNTIME)
+@Inherited
+@Documented
+public @interface OnStateMachineError {
+}
diff --git a/spring-statemachine-core/src/main/java/org/springframework/statemachine/annotation/OnStateMachineStart.java b/spring-statemachine-core/src/main/java/org/springframework/statemachine/annotation/OnStateMachineStart.java
new file mode 100644
index 00000000..e0a41488
--- /dev/null
+++ b/spring-statemachine-core/src/main/java/org/springframework/statemachine/annotation/OnStateMachineStart.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2015 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.annotation;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import org.springframework.statemachine.StateMachine;
+
+/**
+ * Indicates that a method is a candidate to be called when state machine
+ * is started.
+ *
+ * A method annotated with @OnStateMachineStart may accept a parameter of type
+ * {@link StateMachine}.
+ *
+ * Return value can be anything and is effectively discarded.
+ *
+ * @author Janne Valkealahti
+ *
+ */
+@Target({ ElementType.TYPE, ElementType.METHOD })
+@Retention(RetentionPolicy.RUNTIME)
+@Inherited
+@Documented
+public @interface OnStateMachineStart {
+}
diff --git a/spring-statemachine-core/src/main/java/org/springframework/statemachine/annotation/OnStateMachineStop.java b/spring-statemachine-core/src/main/java/org/springframework/statemachine/annotation/OnStateMachineStop.java
new file mode 100644
index 00000000..1c92ad40
--- /dev/null
+++ b/spring-statemachine-core/src/main/java/org/springframework/statemachine/annotation/OnStateMachineStop.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2015 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.annotation;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Indicates that a method is a candidate to be called when state machine
+ * is stopped.
+ *
+ * Return value can be anything and is effectively discarded.
+ *
+ * @author Janne Valkealahti
+ *
+ */
+@Target({ ElementType.TYPE, ElementType.METHOD })
+@Retention(RetentionPolicy.RUNTIME)
+@Inherited
+@Documented
+public @interface OnStateMachineStop {
+}
diff --git a/spring-statemachine-core/src/main/java/org/springframework/statemachine/annotation/OnTransition.java b/spring-statemachine-core/src/main/java/org/springframework/statemachine/annotation/OnTransition.java
index e9badec1..3b60de59 100644
--- a/spring-statemachine-core/src/main/java/org/springframework/statemachine/annotation/OnTransition.java
+++ b/spring-statemachine-core/src/main/java/org/springframework/statemachine/annotation/OnTransition.java
@@ -21,15 +21,41 @@ import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
+import java.util.Map;
+import org.springframework.statemachine.ExtendedState;
+import org.springframework.statemachine.transition.Transition;
+
+/**
+ * Indicates that a method is candidate to be called with a {@link Transition}.
+ *
+ * A method annotated with @OnTransition may accept a parameter of type
+ * {@link ExtendedState} or {@link Map} if map argument is itself is annotated
+ * with {@link EventHeaders}.
+ *
+ * Return value can be anything and is effectively discarded.
+ *
+ * @author Janne Valkealahti
+ *
+ */
@Target({ ElementType.TYPE, ElementType.METHOD })
@Retention(RetentionPolicy.RUNTIME)
@Inherited
@Documented
public @interface OnTransition {
+ /**
+ * The source states.
+ *
+ * @return the source states.
+ */
String[] source() default {};
+ /**
+ * The target states.
+ *
+ * @return the target states.
+ */
String[] target() default {};
}
diff --git a/spring-statemachine-core/src/main/java/org/springframework/statemachine/annotation/OnTransitionEnd.java b/spring-statemachine-core/src/main/java/org/springframework/statemachine/annotation/OnTransitionEnd.java
new file mode 100644
index 00000000..6bbb2992
--- /dev/null
+++ b/spring-statemachine-core/src/main/java/org/springframework/statemachine/annotation/OnTransitionEnd.java
@@ -0,0 +1,61 @@
+/*
+ * Copyright 2015 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.annotation;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+import java.util.Map;
+
+import org.springframework.statemachine.ExtendedState;
+import org.springframework.statemachine.transition.Transition;
+
+/**
+ * Indicates that a method is candidate to be called with a {@link Transition}.
+ *
+ * A method annotated with @OnTransitionEnd may accept a parameter of type
+ * {@link ExtendedState} or {@link Map} if map argument is itself is annotated
+ * with {@link EventHeaders}.
+ *
+ * Return value can be anything and is effectively discarded.
+ *
+ * @author Janne Valkealahti
+ *
+ */
+@Target({ ElementType.TYPE, ElementType.METHOD })
+@Retention(RetentionPolicy.RUNTIME)
+@Inherited
+@Documented
+public @interface OnTransitionEnd {
+
+ /**
+ * The source states.
+ *
+ * @return the source states.
+ */
+ String[] source() default {};
+
+ /**
+ * The target states.
+ *
+ * @return the target states.
+ */
+ String[] target() default {};
+
+}
diff --git a/spring-statemachine-core/src/main/java/org/springframework/statemachine/annotation/OnTransitionStart.java b/spring-statemachine-core/src/main/java/org/springframework/statemachine/annotation/OnTransitionStart.java
new file mode 100644
index 00000000..97951e3d
--- /dev/null
+++ b/spring-statemachine-core/src/main/java/org/springframework/statemachine/annotation/OnTransitionStart.java
@@ -0,0 +1,61 @@
+/*
+ * Copyright 2015 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.annotation;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+import java.util.Map;
+
+import org.springframework.statemachine.ExtendedState;
+import org.springframework.statemachine.transition.Transition;
+
+/**
+ * Indicates that a method is candidate to be called with a {@link Transition}.
+ *
+ * A method annotated with @OnTransitionStart may accept a parameter of type
+ * {@link ExtendedState} or {@link Map} if map argument is itself is annotated
+ * with {@link EventHeaders}.
+ *
+ * Return value can be anything and is effectively discarded.
+ *
+ * @author Janne Valkealahti
+ *
+ */
+@Target({ ElementType.TYPE, ElementType.METHOD })
+@Retention(RetentionPolicy.RUNTIME)
+@Inherited
+@Documented
+public @interface OnTransitionStart {
+
+ /**
+ * The source states.
+ *
+ * @return the source states.
+ */
+ String[] source() default {};
+
+ /**
+ * The target states.
+ *
+ * @return the target states.
+ */
+ String[] target() default {};
+
+}
diff --git a/spring-statemachine-core/src/main/java/org/springframework/statemachine/processor/StateMachineActivatorAnnotationPostProcessor.java b/spring-statemachine-core/src/main/java/org/springframework/statemachine/processor/StateMachineActivatorAnnotationPostProcessor.java
index b6018fc3..7792fcac 100644
--- a/spring-statemachine-core/src/main/java/org/springframework/statemachine/processor/StateMachineActivatorAnnotationPostProcessor.java
+++ b/spring-statemachine-core/src/main/java/org/springframework/statemachine/processor/StateMachineActivatorAnnotationPostProcessor.java
@@ -23,15 +23,8 @@ import org.springframework.beans.factory.ListableBeanFactory;
import org.springframework.core.annotation.AnnotationUtils;
import org.springframework.core.annotation.Order;
import org.springframework.core.annotation.OrderUtils;
-import org.springframework.statemachine.annotation.OnTransition;
-/**
- * Post-processor for Methods annotated with {@link OnTransition}.
- *
- * @author Janne Valkealahti
- *
- */
-public class StateMachineActivatorAnnotationPostProcessor implements MethodAnnotationPostProcessor{
+public class StateMachineActivatorAnnotationPostProcessor implements MethodAnnotationPostProcessor{
protected final BeanFactory beanFactory;
@@ -40,8 +33,8 @@ public class StateMachineActivatorAnnotationPostProcessor implements MethodAnnot
}
@Override
- public Object postProcess(Class> beanClass, Object bean, String beanName, Method method, OnTransition metaAnnotation, Annotation annotation) {
- StateMachineHandler