You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mina.apache.org by ni...@apache.org on 2007/11/05 20:10:34 UTC
svn commit: r592122 - in /mina/trunk:
example/src/main/java/org/apache/mina/example/tapedeck/
statemachine/src/main/java/org/apache/mina/statemachine/
statemachine/src/main/java/org/apache/mina/statemachine/annotation/
statemachine/src/main/java/org/ap...
Author: niklas
Date: Mon Nov 5 11:10:32 2007
New Revision: 592122
URL: http://svn.apache.org/viewvc?rev=592122&view=rev
Log:
Resolved DIRMINA-463: Introduced IoHandler and IoFilter specific transition annotations and enums which enumerates the possible IoHandler and IoFilter events.
Added:
mina/trunk/statemachine/src/main/java/org/apache/mina/statemachine/annotation/IoFilterTransition.java (with props)
mina/trunk/statemachine/src/main/java/org/apache/mina/statemachine/annotation/IoFilterTransitions.java (with props)
mina/trunk/statemachine/src/main/java/org/apache/mina/statemachine/annotation/IoHandlerTransition.java (with props)
mina/trunk/statemachine/src/main/java/org/apache/mina/statemachine/annotation/IoHandlerTransitions.java (with props)
mina/trunk/statemachine/src/main/java/org/apache/mina/statemachine/annotation/Transition.java
- copied, changed from r592107, mina/trunk/statemachine/src/main/java/org/apache/mina/statemachine/annotation/Handler.java
mina/trunk/statemachine/src/main/java/org/apache/mina/statemachine/annotation/Transitions.java
- copied, changed from r592107, mina/trunk/statemachine/src/main/java/org/apache/mina/statemachine/annotation/Handlers.java
mina/trunk/statemachine/src/main/java/org/apache/mina/statemachine/event/IoFilterEvents.java (with props)
mina/trunk/statemachine/src/main/java/org/apache/mina/statemachine/event/IoHandlerEvents.java
- copied, changed from r592107, mina/trunk/statemachine/src/main/java/org/apache/mina/statemachine/event/IoSessionEvents.java
Removed:
mina/trunk/statemachine/src/main/java/org/apache/mina/statemachine/annotation/Handler.java
mina/trunk/statemachine/src/main/java/org/apache/mina/statemachine/annotation/Handlers.java
mina/trunk/statemachine/src/main/java/org/apache/mina/statemachine/event/IoSessionEvents.java
Modified:
mina/trunk/example/src/main/java/org/apache/mina/example/tapedeck/Main.java
mina/trunk/example/src/main/java/org/apache/mina/example/tapedeck/TapeDeckServer.java
mina/trunk/statemachine/src/main/java/org/apache/mina/statemachine/StateControl.java
mina/trunk/statemachine/src/main/java/org/apache/mina/statemachine/StateMachineFactory.java
mina/trunk/statemachine/src/main/java/org/apache/mina/statemachine/transition/MethodTransition.java
mina/trunk/statemachine/src/test/java/org/apache/mina/statemachine/StateMachineFactoryTest.java
mina/trunk/statemachine/src/test/java/org/apache/mina/statemachine/StateMachineProxyFactoryTest.java
mina/trunk/statemachine/src/test/java/org/apache/mina/statemachine/StateTest.java
Modified: mina/trunk/example/src/main/java/org/apache/mina/example/tapedeck/Main.java
URL: http://svn.apache.org/viewvc/mina/trunk/example/src/main/java/org/apache/mina/example/tapedeck/Main.java?rev=592122&r1=592121&r2=592122&view=diff
==============================================================================
--- mina/trunk/example/src/main/java/org/apache/mina/example/tapedeck/Main.java (original)
+++ mina/trunk/example/src/main/java/org/apache/mina/example/tapedeck/Main.java Mon Nov 5 11:10:32 2007
@@ -45,7 +45,7 @@
private static final int PORT = 12345;
private static IoHandler createIoHandler() {
- StateMachine sm = StateMachineFactory.create(TapeDeckServer.EMPTY, new TapeDeckServer());
+ StateMachine sm = StateMachineFactory.createForIoHandler(TapeDeckServer.EMPTY, new TapeDeckServer());
return (IoHandler) StateMachineProxyFactory.create(IoHandler.class, sm,
new IoSessionStateContextLookup(new StateContextFactory() {
Modified: mina/trunk/example/src/main/java/org/apache/mina/example/tapedeck/TapeDeckServer.java
URL: http://svn.apache.org/viewvc/mina/trunk/example/src/main/java/org/apache/mina/example/tapedeck/TapeDeckServer.java?rev=592122&r1=592121&r2=592122&view=diff
==============================================================================
--- mina/trunk/example/src/main/java/org/apache/mina/example/tapedeck/TapeDeckServer.java (original)
+++ mina/trunk/example/src/main/java/org/apache/mina/example/tapedeck/TapeDeckServer.java Mon Nov 5 11:10:32 2007
@@ -19,13 +19,13 @@
*/
package org.apache.mina.example.tapedeck;
-import static org.apache.mina.statemachine.event.IoSessionEvents.*;
+import static org.apache.mina.statemachine.event.IoHandlerEvents.*;
import org.apache.mina.common.IoFutureListener;
import org.apache.mina.common.IoSession;
import org.apache.mina.statemachine.StateControl;
-import org.apache.mina.statemachine.annotation.Handler;
-import org.apache.mina.statemachine.annotation.Handlers;
+import org.apache.mina.statemachine.annotation.IoHandlerTransition;
+import org.apache.mina.statemachine.annotation.IoHandlerTransitions;
import org.apache.mina.statemachine.annotation.State;
import org.apache.mina.statemachine.context.AbstractStateContext;
import org.apache.mina.statemachine.context.StateContext;
@@ -53,12 +53,12 @@
public String tapeName;
}
- @Handler(on = SESSION_OPENED, in = EMPTY)
+ @IoHandlerTransition(on = SESSION_OPENED, in = EMPTY)
public void connect(IoSession session) {
session.write("+ Greetings from your tape deck!");
}
- @Handler(on = MESSAGE_RECEIVED, in = EMPTY, next = LOADED)
+ @IoHandlerTransition(on = MESSAGE_RECEIVED, in = EMPTY, next = LOADED)
public void loadTape(TapeDeckContext context, IoSession session, LoadCommand cmd) {
if (cmd.getTapeNumber() < 1 || cmd.getTapeNumber() > tapes.length) {
session.write("- Unknown tape number: " + cmd.getTapeNumber());
@@ -69,31 +69,31 @@
}
}
- @Handlers({
- @Handler(on = MESSAGE_RECEIVED, in = LOADED, next = PLAYING),
- @Handler(on = MESSAGE_RECEIVED, in = PAUSED, next = PLAYING)
+ @IoHandlerTransitions({
+ @IoHandlerTransition(on = MESSAGE_RECEIVED, in = LOADED, next = PLAYING),
+ @IoHandlerTransition(on = MESSAGE_RECEIVED, in = PAUSED, next = PLAYING)
})
public void playTape(TapeDeckContext context, IoSession session, PlayCommand cmd) {
session.write("+ Playing \"" + context.tapeName + "\"");
}
- @Handler(on = MESSAGE_RECEIVED, in = PLAYING, next = PAUSED)
+ @IoHandlerTransition(on = MESSAGE_RECEIVED, in = PLAYING, next = PAUSED)
public void pauseTape(TapeDeckContext context, IoSession session, PauseCommand cmd) {
session.write("+ \"" + context.tapeName + "\" paused");
}
- @Handler(on = MESSAGE_RECEIVED, in = PLAYING, next = LOADED)
+ @IoHandlerTransition(on = MESSAGE_RECEIVED, in = PLAYING, next = LOADED)
public void stopTape(TapeDeckContext context, IoSession session, StopCommand cmd) {
session.write("+ \"" + context.tapeName + "\" stopped");
}
- @Handler(on = MESSAGE_RECEIVED, in = LOADED, next = EMPTY)
+ @IoHandlerTransition(on = MESSAGE_RECEIVED, in = LOADED, next = EMPTY)
public void ejectTape(TapeDeckContext context, IoSession session, EjectCommand cmd) {
session.write("+ \"" + context.tapeName + "\" ejected");
context.tapeName = null;
}
- @Handler(on = MESSAGE_RECEIVED, in = ROOT)
+ @IoHandlerTransition(on = MESSAGE_RECEIVED, in = ROOT)
public void listTapes(IoSession session, ListCommand cmd) {
StringBuilder response = new StringBuilder("+ (");
for (int i = 0; i < tapes.length; i++) {
@@ -107,7 +107,7 @@
session.write(response);
}
- @Handler(on = MESSAGE_RECEIVED, in = ROOT)
+ @IoHandlerTransition(on = MESSAGE_RECEIVED, in = ROOT)
public void info(TapeDeckContext context, IoSession session, InfoCommand cmd) {
String state = context.getCurrentState().getId().toLowerCase();
if (context.tapeName == null) {
@@ -118,29 +118,29 @@
}
}
- @Handler(on = MESSAGE_RECEIVED, in = ROOT)
+ @IoHandlerTransition(on = MESSAGE_RECEIVED, in = ROOT)
public void quit(TapeDeckContext context, IoSession session, QuitCommand cmd) {
session.write("+ Bye! Please come back!").addListener(IoFutureListener.CLOSE);
}
- @Handler(on = MESSAGE_RECEIVED, in = ROOT, weight = 10)
+ @IoHandlerTransition(on = MESSAGE_RECEIVED, in = ROOT, weight = 10)
public void error(Event event, StateContext context, IoSession session, Command cmd) {
session.write("- Cannot " + cmd.getName()
+ " while " + context.getCurrentState().getId().toLowerCase());
}
- @Handler(on = EXCEPTION_CAUGHT, in = ROOT)
+ @IoHandlerTransition(on = EXCEPTION_CAUGHT, in = ROOT)
public void commandSyntaxError(IoSession session, CommandSyntaxException e) {
session.write("- " + e.getMessage());
}
- @Handler(on = EXCEPTION_CAUGHT, in = ROOT, weight = 10)
+ @IoHandlerTransition(on = EXCEPTION_CAUGHT, in = ROOT, weight = 10)
public void exceptionCaught(IoSession session, Exception e) {
e.printStackTrace();
session.close();
}
- @Handler(in = ROOT, weight = 100)
+ @IoHandlerTransition(in = ROOT, weight = 100)
public void unhandledEvent() {
}
Modified: mina/trunk/statemachine/src/main/java/org/apache/mina/statemachine/StateControl.java
URL: http://svn.apache.org/viewvc/mina/trunk/statemachine/src/main/java/org/apache/mina/statemachine/StateControl.java?rev=592122&r1=592121&r2=592122&view=diff
==============================================================================
--- mina/trunk/statemachine/src/main/java/org/apache/mina/statemachine/StateControl.java (original)
+++ mina/trunk/statemachine/src/main/java/org/apache/mina/statemachine/StateControl.java Mon Nov 5 11:10:32 2007
@@ -19,7 +19,6 @@
*/
package org.apache.mina.statemachine;
-import org.apache.mina.statemachine.annotation.Handler;
import org.apache.mina.statemachine.event.Event;
import org.apache.mina.statemachine.transition.Transition;
@@ -30,7 +29,7 @@
* immediately and let the new {@link State} handle the current {@link Event}.
* The <code>*Next()</code> family on the other hand let the new {@link State}
* handle the next {@link Event} which is generated which make these method the
- * programmatic equivalent of using the {@link Handler} annotation.
+ * programmatic equivalent of using the {@link org.apache.mina.statemachine.annotation.Transition} annotation.
* </p>
* <p>
* Using the <code>breakAndCall*()</code> and <code>breakAndReturn*</code> methods one
@@ -68,7 +67,7 @@
* Breaks the execution of the current {@link Transition} and lets the
* {@link State} with the specified id handle the <strong>next</strong> {@link Event}.
* Using this method is the programmatic equivalent of using the
- * {@link Handler} annotation.
+ * {@link org.apache.mina.statemachine.annotation.Transition} annotation.
*
* @param state the id of the {@link State} to go to.
*/
Modified: mina/trunk/statemachine/src/main/java/org/apache/mina/statemachine/StateMachineFactory.java
URL: http://svn.apache.org/viewvc/mina/trunk/statemachine/src/main/java/org/apache/mina/statemachine/StateMachineFactory.java?rev=592122&r1=592121&r2=592122&view=diff
==============================================================================
--- mina/trunk/statemachine/src/main/java/org/apache/mina/statemachine/StateMachineFactory.java (original)
+++ mina/trunk/statemachine/src/main/java/org/apache/mina/statemachine/StateMachineFactory.java Mon Nov 5 11:10:32 2007
@@ -32,16 +32,19 @@
import java.util.List;
import java.util.Map;
-import org.apache.mina.statemachine.annotation.Handler;
-import org.apache.mina.statemachine.annotation.Handlers;
+import org.apache.mina.statemachine.annotation.IoFilterTransition;
+import org.apache.mina.statemachine.annotation.IoFilterTransitions;
+import org.apache.mina.statemachine.annotation.IoHandlerTransition;
+import org.apache.mina.statemachine.annotation.IoHandlerTransitions;
+import org.apache.mina.statemachine.annotation.Transition;
+import org.apache.mina.statemachine.annotation.Transitions;
import org.apache.mina.statemachine.event.Event;
import org.apache.mina.statemachine.transition.MethodTransition;
-import org.apache.mina.statemachine.transition.Transition;
/**
* Creates {@link StateMachine}s by reading {@link org.apache.mina.statemachine.annotation.State},
- * {@link Handler} and {@link Handlers} annotations from one or more arbitrary
+ * {@link Transition} and {@link Transitions} annotations from one or more arbitrary
* objects.
*
*
@@ -104,20 +107,54 @@
* @return the {@link StateMachine} object.
*/
public static StateMachine create(String start, Object handler, Object... handlers) {
- return create(Handler.class, Handlers.class, start, handler, handlers);
+ return create(Transition.class, Transitions.class, start, handler, handlers);
+ }
+
+ /**
+ * Creates a new {@link StateMachine} from the specified handler objects and
+ * using the {@link State} with the specified id as start state. This method
+ * should be used when using the {@link IoHandlerTransition} and
+ * {@link IoHandlerTransitions} annotations.
+ *
+ * @param start the id of the start {@link State} to use.
+ * @param handler the first object containing the annotations describing the
+ * state machine.
+ * @param handlers zero or more additional objects containing the
+ * annotations describing the state machine.
+ * @return the {@link StateMachine} object.
+ */
+ public static StateMachine createForIoHandler(String start, Object handler, Object... handlers) {
+ return create(IoHandlerTransition.class, IoHandlerTransitions.class, start, handler, handlers);
+ }
+
+ /**
+ * Creates a new {@link StateMachine} from the specified handler objects and
+ * using the {@link State} with the specified id as start state. This method
+ * should be used when using the {@link IoFilterTransition} and
+ * {@link IoFilterTransitions} annotations.
+ *
+ * @param start the id of the start {@link State} to use.
+ * @param handler the first object containing the annotations describing the
+ * state machine.
+ * @param handlers zero or more additional objects containing the
+ * annotations describing the state machine.
+ * @return the {@link StateMachine} object.
+ */
+ public static StateMachine createForIoFilter(String start, Object handler, Object... handlers) {
+ return create(IoFilterTransition.class, IoFilterTransitions.class, start, handler, handlers);
}
/**
* Creates a new {@link StateMachine} from the specified handler objects and
* using the {@link State} with the specified id as start state. Use this
- * method if you want to use your own alternatives to the {@link Handler}
- * and {@link Handlers} annotations.
+ * method if you want to use your own alternatives to the {@link Transition}
+ * and {@link Transitions} annotations.
*
- * @param handlerAnnotation the annotation to use instead of {@link Handler}.
- * The annotation must have the same parameters as {@link Handler}
+ * @param transitionAnnotation the annotation to use instead of {@link Transition}.
+ * The annotation must have the same parameters as {@link Transition}
* but the <code>on</code> parameter may be of an enum type instead of string.
- * @param handlersAnnotation the annotation to use instead of {@link Handlers}.
- * The annotation must have the same parameters as {@link Handlers}.
+ * @param transitionsAnnotation the annotation to use instead of {@link Transitions}.
+ * The annotation must have the same parameters as {@link Transitions}.
* @param start the id of the start {@link State} to use.
* @param handler the first object containing the annotations describing the
* state machine.
@@ -125,8 +162,8 @@
* annotations describing the state machine.
* @return the {@link StateMachine} object.
*/
- public static StateMachine create(Class<? extends Annotation> handlerAnnotation,
- Class<? extends Annotation> handlersAnnotation,
+ public static StateMachine create(Class<? extends Annotation> transitionAnnotation,
+ Class<? extends Annotation> transitionsAnnotation,
String start, Object handler, Object... handlers) {
Map<String, State> states = new HashMap<String, State>();
@@ -146,20 +183,20 @@
throw new StateMachineCreationException("Start state '" + start + "' not found.");
}
- setupTransitions(handlerAnnotation, handlersAnnotation, states, handlersList);
+ setupTransitions(transitionAnnotation, transitionsAnnotation, states, handlersList);
return new StateMachine(states.values(), start);
}
- private static void setupTransitions(Class<? extends Annotation> handlerAnnotation,
- Class<? extends Annotation> handlersAnnotation, Map<String, State> states, List<Object> handlers) {
+ private static void setupTransitions(Class<? extends Annotation> transitionAnnotation,
+ Class<? extends Annotation> transitionsAnnotation, Map<String, State> states, List<Object> handlers) {
for (Object handler : handlers) {
- setupTransitions(handlerAnnotation, handlersAnnotation, states, handler);
+ setupTransitions(transitionAnnotation, transitionsAnnotation, states, handler);
}
}
- private static void setupTransitions(Class<? extends Annotation> handlerAnnotation,
- Class<? extends Annotation> handlersAnnotation, Map<String, State> states, Object handler) {
+ private static void setupTransitions(Class<? extends Annotation> transitionAnnotation,
+ Class<? extends Annotation> transitionsAnnotation, Map<String, State> states, Object handler) {
Method[] methods = handler.getClass().getDeclaredMethods();
Arrays.sort(methods, new Comparator<Method>() {
@@ -169,20 +206,20 @@
});
for (Method m : methods) {
- List<HandlerWrapper> handlerAnnotations = new ArrayList<HandlerWrapper>();
- if (m.isAnnotationPresent(handlerAnnotation)) {
- handlerAnnotations.add(new HandlerWrapper(handlerAnnotation, m.getAnnotation(handlerAnnotation)));
- }
- if (m.isAnnotationPresent(handlersAnnotation)) {
- handlerAnnotations.addAll(Arrays.asList(new HandlersWrapper(handlerAnnotation,
- handlersAnnotation, m.getAnnotation(handlersAnnotation)).value()));
+ List<TransitionWrapper> transitionAnnotations = new ArrayList<TransitionWrapper>();
+ if (m.isAnnotationPresent(transitionAnnotation)) {
+ transitionAnnotations.add(new TransitionWrapper(transitionAnnotation, m.getAnnotation(transitionAnnotation)));
+ }
+ if (m.isAnnotationPresent(transitionsAnnotation)) {
+ transitionAnnotations.addAll(Arrays.asList(new TransitionsWrapper(transitionAnnotation,
+ transitionsAnnotation, m.getAnnotation(transitionsAnnotation)).value()));
}
- if (handlerAnnotations.isEmpty()) {
+ if (transitionAnnotations.isEmpty()) {
continue;
}
- for (HandlerWrapper annotation : handlerAnnotations) {
+ for (TransitionWrapper annotation : transitionAnnotations) {
Object[] eventIds = annotation.on();
if (eventIds.length == 0) {
throw new StateMachineCreationException("Error encountered "
@@ -196,7 +233,7 @@
}
State next = null;
- if (!annotation.next().equals(Handler.SELF)) {
+ if (!annotation.next().equals(Transition.SELF)) {
next = states.get(annotation.next());
if (next == null) {
throw new StateMachineCreationException("Error encountered "
@@ -209,6 +246,9 @@
if (event == null) {
event = Event.WILDCARD_EVENT_ID;
}
+ if (!(event instanceof String)) {
+ event = event.toString();
+ }
for (String in : annotation.in()) {
State state = states.get(in);
if (state == null) {
@@ -217,8 +257,7 @@
+ m + ". Unknown state: " + in + ".");
}
- Transition t = new MethodTransition(event, next, m, handler);
- state.addTransition(t, annotation.weight());
+ state.addTransition(new MethodTransition(event, next, m, handler), annotation.weight());
}
}
}
@@ -297,11 +336,11 @@
return states.values().toArray(new State[0]);
}
- private static class HandlerWrapper {
- private final Class<? extends Annotation> handlerClazz;
+ private static class TransitionWrapper {
+ private final Class<? extends Annotation> transitionClazz;
private final Annotation annotation;
- public HandlerWrapper(Class<? extends Annotation> handlerClazz, Annotation annotation) {
- this.handlerClazz = handlerClazz;
+ public TransitionWrapper(Class<? extends Annotation> transitionClazz, Annotation annotation) {
+ this.transitionClazz = transitionClazz;
this.annotation = annotation;
}
Object[] on() {
@@ -319,47 +358,47 @@
@SuppressWarnings("unchecked")
private <T> T getParameter(String name, Class<T> returnType) {
try {
- Method m = handlerClazz.getMethod(name);
+ Method m = transitionClazz.getMethod(name);
if (!returnType.isAssignableFrom(m.getReturnType())) {
throw new NoSuchMethodException();
}
return (T) m.invoke(annotation);
} catch (Throwable t) {
throw new StateMachineCreationException("Could not get parameter '"
- + name + "' from Handler annotation " + handlerClazz);
+ + name + "' from Transition annotation " + transitionClazz);
}
}
}
- private static class HandlersWrapper {
- private final Class<? extends Annotation> handlersclazz;
- private final Class<? extends Annotation> handlerClazz;
+ private static class TransitionsWrapper {
+ private final Class<? extends Annotation> transitionsclazz;
+ private final Class<? extends Annotation> transitionClazz;
private final Annotation annotation;
- public HandlersWrapper(Class<? extends Annotation> handlerClazz,
- Class<? extends Annotation> handlersclazz, Annotation annotation) {
- this.handlerClazz = handlerClazz;
- this.handlersclazz = handlersclazz;
+ public TransitionsWrapper(Class<? extends Annotation> transitionClazz,
+ Class<? extends Annotation> transitionsclazz, Annotation annotation) {
+ this.transitionClazz = transitionClazz;
+ this.transitionsclazz = transitionsclazz;
this.annotation = annotation;
}
- HandlerWrapper[] value() {
+ TransitionWrapper[] value() {
Annotation[] annos = getParameter("value", Annotation[].class);
- HandlerWrapper[] wrappers = new HandlerWrapper[annos.length];
+ TransitionWrapper[] wrappers = new TransitionWrapper[annos.length];
for (int i = 0; i < annos.length; i++) {
- wrappers[i] = new HandlerWrapper(handlerClazz, annos[i]);
+ wrappers[i] = new TransitionWrapper(transitionClazz, annos[i]);
}
return wrappers;
}
@SuppressWarnings("unchecked")
private <T> T getParameter(String name, Class<T> returnType) {
try {
- Method m = handlersclazz.getMethod(name);
+ Method m = transitionsclazz.getMethod(name);
if (!returnType.isAssignableFrom(m.getReturnType())) {
throw new NoSuchMethodException();
}
return (T) m.invoke(annotation);
} catch (Throwable t) {
throw new StateMachineCreationException("Could not get parameter '"
- + name + "' from Handlers annotation " + handlersclazz);
+ + name + "' from Transitions annotation " + transitionsclazz);
}
}
}
Added: mina/trunk/statemachine/src/main/java/org/apache/mina/statemachine/annotation/IoFilterTransition.java
URL: http://svn.apache.org/viewvc/mina/trunk/statemachine/src/main/java/org/apache/mina/statemachine/annotation/IoFilterTransition.java?rev=592122&view=auto
==============================================================================
--- mina/trunk/statemachine/src/main/java/org/apache/mina/statemachine/annotation/IoFilterTransition.java (added)
+++ mina/trunk/statemachine/src/main/java/org/apache/mina/statemachine/annotation/IoFilterTransition.java Mon Nov 5 11:10:32 2007
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.mina.statemachine.annotation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import org.apache.mina.common.IoFilter;
+import org.apache.mina.statemachine.StateMachine;
+import org.apache.mina.statemachine.event.IoFilterEvents;
+
+/**
+ * Annotation used on methods to indicate that the method handles a specific
+ * kind of {@link IoFilterEvents} event when in a specific state. This should
+ * be used when creating {@link StateMachine}s for MINA's {@link IoFilter}
+ * interface.
+ *
+ * @author The Apache MINA Project (dev@mina.apache.org)
+ * @version $Rev$, $Date$
+ */
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.METHOD)
+public @interface IoFilterTransition {
+ public static final String SELF = "__self__";
+
+ /**
+ * Specifies the ids of one or more events handled by the annotated method. If
+ * not specified the handler method will be executed for any event.
+ */
+ IoFilterEvents[] on() default IoFilterEvents.ANY;
+
+ /**
+ * The id of the state or states that this handler applies to. Must be
+ * specified.
+ */
+ String[] in();
+
+ /**
+ * The id of the state the {@link StateMachine} should move to next after
+ * executing the annotated method. If not specified the {@link StateMachine}
+ * will remain in the same state.
+ */
+ String next() default SELF;
+
+ /**
+ * The weight used to order handler annotations which match the same event
+ * in the same state. Transitions with lower weight will be matched first. The
+ * default weight is 0.
+ */
+ int weight() default 0;
+}
Propchange: mina/trunk/statemachine/src/main/java/org/apache/mina/statemachine/annotation/IoFilterTransition.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: mina/trunk/statemachine/src/main/java/org/apache/mina/statemachine/annotation/IoFilterTransition.java
------------------------------------------------------------------------------
svn:keywords = Rev Date Id
Added: mina/trunk/statemachine/src/main/java/org/apache/mina/statemachine/annotation/IoFilterTransitions.java
URL: http://svn.apache.org/viewvc/mina/trunk/statemachine/src/main/java/org/apache/mina/statemachine/annotation/IoFilterTransitions.java?rev=592122&view=auto
==============================================================================
--- mina/trunk/statemachine/src/main/java/org/apache/mina/statemachine/annotation/IoFilterTransitions.java (added)
+++ mina/trunk/statemachine/src/main/java/org/apache/mina/statemachine/annotation/IoFilterTransitions.java Mon Nov 5 11:10:32 2007
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.mina.statemachine.annotation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import org.apache.mina.common.IoFilter;
+import org.apache.mina.statemachine.StateMachine;
+
+/**
+ * Annotation used to annotate a method with several {@link IoFilterTransition}s.
+ * This should be used when creating {@link StateMachine}s for MINA's
+ * {@link IoFilter} interface.
+ *
+ * @author The Apache MINA Project (dev@mina.apache.org)
+ * @version $Rev$, $Date$
+ */
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.METHOD)
+public @interface IoFilterTransitions {
+ IoFilterTransition[] value();
+}
Propchange: mina/trunk/statemachine/src/main/java/org/apache/mina/statemachine/annotation/IoFilterTransitions.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: mina/trunk/statemachine/src/main/java/org/apache/mina/statemachine/annotation/IoFilterTransitions.java
------------------------------------------------------------------------------
svn:keywords = Rev Date Id
Added: mina/trunk/statemachine/src/main/java/org/apache/mina/statemachine/annotation/IoHandlerTransition.java
URL: http://svn.apache.org/viewvc/mina/trunk/statemachine/src/main/java/org/apache/mina/statemachine/annotation/IoHandlerTransition.java?rev=592122&view=auto
==============================================================================
--- mina/trunk/statemachine/src/main/java/org/apache/mina/statemachine/annotation/IoHandlerTransition.java (added)
+++ mina/trunk/statemachine/src/main/java/org/apache/mina/statemachine/annotation/IoHandlerTransition.java Mon Nov 5 11:10:32 2007
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.mina.statemachine.annotation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import org.apache.mina.common.IoHandler;
+import org.apache.mina.statemachine.StateMachine;
+import org.apache.mina.statemachine.event.IoHandlerEvents;
+
+/**
+ * Annotation used on methods to indicate that the method handles a specific
+ * kind of {@link IoHandlerEvents} event when in a specific state. This should
+ * be used when creating {@link StateMachine}s for MINA's {@link IoHandler}
+ * interface.
+ *
+ * @author The Apache MINA Project (dev@mina.apache.org)
+ * @version $Rev$, $Date$
+ */
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.METHOD)
+public @interface IoHandlerTransition {
+ public static final String SELF = "__self__";
+
+ /**
+ * Specifies the ids of one or more events handled by the annotated method. If
+ * not specified the handler method will be executed for any event.
+ */
+ IoHandlerEvents[] on() default IoHandlerEvents.ANY;
+
+ /**
+ * The id of the state or states that this handler applies to. Must be
+ * specified.
+ */
+ String[] in();
+
+ /**
+ * The id of the state the {@link StateMachine} should move to next after
+ * executing the annotated method. If not specified the {@link StateMachine}
+ * will remain in the same state.
+ */
+ String next() default SELF;
+
+ /**
+ * The weight used to order handler annotations which match the same event
+ * in the same state. Transitions with lower weight will be matched first. The
+ * default weight is 0.
+ */
+ int weight() default 0;
+}
Propchange: mina/trunk/statemachine/src/main/java/org/apache/mina/statemachine/annotation/IoHandlerTransition.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: mina/trunk/statemachine/src/main/java/org/apache/mina/statemachine/annotation/IoHandlerTransition.java
------------------------------------------------------------------------------
svn:keywords = Rev Date Id
Added: mina/trunk/statemachine/src/main/java/org/apache/mina/statemachine/annotation/IoHandlerTransitions.java
URL: http://svn.apache.org/viewvc/mina/trunk/statemachine/src/main/java/org/apache/mina/statemachine/annotation/IoHandlerTransitions.java?rev=592122&view=auto
==============================================================================
--- mina/trunk/statemachine/src/main/java/org/apache/mina/statemachine/annotation/IoHandlerTransitions.java (added)
+++ mina/trunk/statemachine/src/main/java/org/apache/mina/statemachine/annotation/IoHandlerTransitions.java Mon Nov 5 11:10:32 2007
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.mina.statemachine.annotation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import org.apache.mina.common.IoHandler;
+import org.apache.mina.statemachine.StateMachine;
+
+/**
+ * Annotation used to annotate a method with several {@link IoHandlerTransition}s.
+ * This should be used when creating {@link StateMachine}s for MINA's
+ * {@link IoHandler} interface.
+ *
+ * @author The Apache MINA Project (dev@mina.apache.org)
+ * @version $Rev$, $Date$
+ */
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.METHOD)
+public @interface IoHandlerTransitions {
+ IoHandlerTransition[] value();
+}
Propchange: mina/trunk/statemachine/src/main/java/org/apache/mina/statemachine/annotation/IoHandlerTransitions.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: mina/trunk/statemachine/src/main/java/org/apache/mina/statemachine/annotation/IoHandlerTransitions.java
------------------------------------------------------------------------------
svn:keywords = Rev Date Id
Copied: mina/trunk/statemachine/src/main/java/org/apache/mina/statemachine/annotation/Transition.java (from r592107, mina/trunk/statemachine/src/main/java/org/apache/mina/statemachine/annotation/Handler.java)
URL: http://svn.apache.org/viewvc/mina/trunk/statemachine/src/main/java/org/apache/mina/statemachine/annotation/Transition.java?p2=mina/trunk/statemachine/src/main/java/org/apache/mina/statemachine/annotation/Transition.java&p1=mina/trunk/statemachine/src/main/java/org/apache/mina/statemachine/annotation/Handler.java&r1=592107&r2=592122&rev=592122&view=diff
==============================================================================
--- mina/trunk/statemachine/src/main/java/org/apache/mina/statemachine/annotation/Handler.java (original)
+++ mina/trunk/statemachine/src/main/java/org/apache/mina/statemachine/annotation/Transition.java Mon Nov 5 11:10:32 2007
@@ -36,7 +36,7 @@
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
-public @interface Handler {
+public @interface Transition {
public static final String SELF = "__self__";
/**
@@ -60,7 +60,7 @@
/**
* The weight used to order handler annotations which match the same event
- * in the same state. Handlers with lower weight will be matched first. The
+ * in the same state. Transitions with lower weight will be matched first. The
* default weight is 0.
*/
int weight() default 0;
Copied: mina/trunk/statemachine/src/main/java/org/apache/mina/statemachine/annotation/Transitions.java (from r592107, mina/trunk/statemachine/src/main/java/org/apache/mina/statemachine/annotation/Handlers.java)
URL: http://svn.apache.org/viewvc/mina/trunk/statemachine/src/main/java/org/apache/mina/statemachine/annotation/Transitions.java?p2=mina/trunk/statemachine/src/main/java/org/apache/mina/statemachine/annotation/Transitions.java&p1=mina/trunk/statemachine/src/main/java/org/apache/mina/statemachine/annotation/Handlers.java&r1=592107&r2=592122&rev=592122&view=diff
==============================================================================
--- mina/trunk/statemachine/src/main/java/org/apache/mina/statemachine/annotation/Handlers.java (original)
+++ mina/trunk/statemachine/src/main/java/org/apache/mina/statemachine/annotation/Transitions.java Mon Nov 5 11:10:32 2007
@@ -25,13 +25,13 @@
import java.lang.annotation.Target;
/**
- * Annotation used to annotate a method with several {@link Handler}s.
+ * Annotation used to annotate a method with several {@link Transition}s.
*
* @author The Apache MINA Project (dev@mina.apache.org)
* @version $Rev$, $Date$
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
-public @interface Handlers {
- Handler[] value();
+public @interface Transitions {
+ Transition[] value();
}
Added: mina/trunk/statemachine/src/main/java/org/apache/mina/statemachine/event/IoFilterEvents.java
URL: http://svn.apache.org/viewvc/mina/trunk/statemachine/src/main/java/org/apache/mina/statemachine/event/IoFilterEvents.java?rev=592122&view=auto
==============================================================================
--- mina/trunk/statemachine/src/main/java/org/apache/mina/statemachine/event/IoFilterEvents.java (added)
+++ mina/trunk/statemachine/src/main/java/org/apache/mina/statemachine/event/IoFilterEvents.java Mon Nov 5 11:10:32 2007
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.mina.statemachine.event;
+
+import org.apache.mina.common.IoFilter;
+import org.apache.mina.statemachine.annotation.IoFilterTransition;
+
+/**
+ * Defines all possible MINA {@link IoFilter} events for use in {@link IoFilterTransition}
+ * annotations.
+ *
+ * @author The Apache MINA Project (dev@mina.apache.org)
+ * @version $Rev$, $Date$
+ */
+public enum IoFilterEvents {
+ ANY(Event.WILDCARD_EVENT_ID),
+ SESSION_CREATED("sessionCreated"),
+ SESSION_OPENED("sessionOpened"),
+ SESSION_CLOSED("sessionClosed"),
+ SESSION_IDLE("sessionIdle"),
+ MESSAGE_RECEIVED("messageReceived"),
+ MESSAGE_SENT("messageSent"),
+ FILTER_CLOSE("filterClose"),
+ FILTER_WRITE("filterWrite"),
+ FILTER_SET_TRAFFIC_MASK("filterSetTrafficMask"),
+ EXCEPTION_CAUGHT("exceptionCaught");
+
+ private final String value;
+
+ private IoFilterEvents(String value) {
+ this.value = value;
+ }
+
+ @Override
+ public String toString() {
+ return value;
+ }
+}
Propchange: mina/trunk/statemachine/src/main/java/org/apache/mina/statemachine/event/IoFilterEvents.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: mina/trunk/statemachine/src/main/java/org/apache/mina/statemachine/event/IoFilterEvents.java
------------------------------------------------------------------------------
svn:keywords = Rev Date Id
Copied: mina/trunk/statemachine/src/main/java/org/apache/mina/statemachine/event/IoHandlerEvents.java (from r592107, mina/trunk/statemachine/src/main/java/org/apache/mina/statemachine/event/IoSessionEvents.java)
URL: http://svn.apache.org/viewvc/mina/trunk/statemachine/src/main/java/org/apache/mina/statemachine/event/IoHandlerEvents.java?p2=mina/trunk/statemachine/src/main/java/org/apache/mina/statemachine/event/IoHandlerEvents.java&p1=mina/trunk/statemachine/src/main/java/org/apache/mina/statemachine/event/IoSessionEvents.java&r1=592107&r2=592122&rev=592122&view=diff
==============================================================================
--- mina/trunk/statemachine/src/main/java/org/apache/mina/statemachine/event/IoSessionEvents.java (original)
+++ mina/trunk/statemachine/src/main/java/org/apache/mina/statemachine/event/IoHandlerEvents.java Mon Nov 5 11:10:32 2007
@@ -20,30 +20,33 @@
package org.apache.mina.statemachine.event;
import org.apache.mina.common.IoHandler;
-import org.apache.mina.statemachine.annotation.Handler;
+import org.apache.mina.statemachine.annotation.IoHandlerTransition;
/**
- * Defines all possible MINA {@link IoHandler} events for use in {@link Handler}
+ * Defines all possible MINA {@link IoHandler} events for use in {@link IoHandlerTransition}
* annotations.
*
* @author The Apache MINA Project (dev@mina.apache.org)
* @version $Rev$, $Date$
*/
-public final class IoSessionEvents {
- public static final String SESSION_CREATED = "sessionCreated";
-
- public static final String SESSION_OPENED = "sessionOpened";
-
- public static final String SESSION_CLOSED = "sessionClosed";
-
- public static final String SESSION_IDLE = "sessionIdle";
-
- public static final String MESSAGE_RECEIVED = "messageReceived";
-
- public static final String MESSAGE_SENT = "messageSent";
-
- public static final String EXCEPTION_CAUGHT = "exceptionCaught";
-
- private IoSessionEvents() {
+public enum IoHandlerEvents {
+ ANY(Event.WILDCARD_EVENT_ID),
+ SESSION_CREATED("sessionCreated"),
+ SESSION_OPENED("sessionOpened"),
+ SESSION_CLOSED("sessionClosed"),
+ SESSION_IDLE("sessionIdle"),
+ MESSAGE_RECEIVED("messageReceived"),
+ MESSAGE_SENT("messageSent"),
+ EXCEPTION_CAUGHT("exceptionCaught");
+
+ private final String value;
+
+ private IoHandlerEvents(String value) {
+ this.value = value;
+ }
+
+ @Override
+ public String toString() {
+ return value;
}
}
Modified: mina/trunk/statemachine/src/main/java/org/apache/mina/statemachine/transition/MethodTransition.java
URL: http://svn.apache.org/viewvc/mina/trunk/statemachine/src/main/java/org/apache/mina/statemachine/transition/MethodTransition.java?rev=592122&r1=592121&r2=592122&view=diff
==============================================================================
--- mina/trunk/statemachine/src/main/java/org/apache/mina/statemachine/transition/MethodTransition.java (original)
+++ mina/trunk/statemachine/src/main/java/org/apache/mina/statemachine/transition/MethodTransition.java Mon Nov 5 11:10:32 2007
@@ -29,7 +29,7 @@
import org.apache.mina.statemachine.State;
import org.apache.mina.statemachine.StateMachine;
import org.apache.mina.statemachine.StateMachineFactory;
-import org.apache.mina.statemachine.annotation.Handler;
+import org.apache.mina.statemachine.annotation.Transition;
import org.apache.mina.statemachine.context.StateContext;
import org.apache.mina.statemachine.event.Event;
import org.slf4j.Logger;
@@ -50,7 +50,7 @@
* </p>
* <p>
* Normally you wouldn't create instances of this class directly but rather use the
- * {@link Handler} annotation to define the methods which should be used as
+ * {@link Transition} annotation to define the methods which should be used as
* transitions in your state machine and then let {@link StateMachineFactory} create a
* {@link StateMachine} for you.
* </p>
Modified: mina/trunk/statemachine/src/test/java/org/apache/mina/statemachine/StateMachineFactoryTest.java
URL: http://svn.apache.org/viewvc/mina/trunk/statemachine/src/test/java/org/apache/mina/statemachine/StateMachineFactoryTest.java?rev=592122&r1=592121&r2=592122&view=diff
==============================================================================
--- mina/trunk/statemachine/src/test/java/org/apache/mina/statemachine/StateMachineFactoryTest.java (original)
+++ mina/trunk/statemachine/src/test/java/org/apache/mina/statemachine/StateMachineFactoryTest.java Mon Nov 5 11:10:32 2007
@@ -28,10 +28,9 @@
import org.apache.mina.statemachine.StateMachine;
import org.apache.mina.statemachine.StateMachineCreationException;
import org.apache.mina.statemachine.StateMachineFactory;
-import org.apache.mina.statemachine.annotation.Handler;
-import org.apache.mina.statemachine.annotation.Handlers;
+import org.apache.mina.statemachine.annotation.Transition;
+import org.apache.mina.statemachine.annotation.Transitions;
import org.apache.mina.statemachine.transition.MethodTransition;
-import org.apache.mina.statemachine.transition.Transition;
/**
* Tests {@link StateMachineFactory}.
@@ -74,7 +73,7 @@
assertEquals(States.D, d.getId());
assertSame(a, d.getParent());
- List<Transition> trans = null;
+ List<org.apache.mina.statemachine.transition.Transition> trans = null;
trans = a.getTransitions();
assertEquals(3, trans.size());
@@ -127,27 +126,27 @@
@org.apache.mina.statemachine.annotation.State(A)
protected static final String D = "d";
- @Handler(on = "bar", in = A)
+ @Transition(on = "bar", in = A)
protected void barInA() {
}
- @Handler(on = "bar", in = C, next = A)
+ @Transition(on = "bar", in = C, next = A)
protected void barInC() {
}
- @Handler(in = A)
+ @Transition(in = A)
protected void error() {
}
- @Handler(on = "foo", in = A, next = B)
+ @Transition(on = "foo", in = A, next = B)
protected void fooInA() {
}
- @Handler(on = "foo", in = B, next = C)
+ @Transition(on = "foo", in = B, next = C)
protected void fooInB() {
}
- @Handlers( { @Handler(on = { "foo", "bar" }, in = C, next = D), @Handler(on = "foo", in = D) })
+ @Transitions( { @Transition(on = { "foo", "bar" }, in = C, next = D), @Transition(on = "foo", in = D) })
protected void fooOrBarInCOrFooInD() {
}
Modified: mina/trunk/statemachine/src/test/java/org/apache/mina/statemachine/StateMachineProxyFactoryTest.java
URL: http://svn.apache.org/viewvc/mina/trunk/statemachine/src/test/java/org/apache/mina/statemachine/StateMachineProxyFactoryTest.java?rev=592122&r1=592121&r2=592122&view=diff
==============================================================================
--- mina/trunk/statemachine/src/test/java/org/apache/mina/statemachine/StateMachineProxyFactoryTest.java (original)
+++ mina/trunk/statemachine/src/test/java/org/apache/mina/statemachine/StateMachineProxyFactoryTest.java Mon Nov 5 11:10:32 2007
@@ -27,8 +27,8 @@
import org.apache.mina.statemachine.StateMachine;
import org.apache.mina.statemachine.StateMachineFactory;
import org.apache.mina.statemachine.StateMachineProxyFactory;
-import org.apache.mina.statemachine.annotation.Handler;
-import org.apache.mina.statemachine.annotation.Handlers;
+import org.apache.mina.statemachine.annotation.Transition;
+import org.apache.mina.statemachine.annotation.Transitions;
import org.apache.mina.statemachine.event.Event;
import org.apache.mina.statemachine.transition.MethodTransition;
@@ -162,33 +162,33 @@
private LinkedList<String> messages = new LinkedList<String>();
- @Handler(on = "insert", in = "s1", next = "s2")
+ @Transition(on = "insert", in = "s1", next = "s2")
public void inserted(String name) {
messages.add("Tape '" + name + "' inserted");
}
- @Handler(on = "eject", in = "s4", next = "s1")
+ @Transition(on = "eject", in = "s4", next = "s1")
public void ejected() {
messages.add("Tape ejected");
}
- @Handlers({@Handler( on = "start", in = "s2", next = "s3" ),
- @Handler( on = "pause", in = "s5", next = "s3" )})
+ @Transitions({@Transition( on = "start", in = "s2", next = "s3" ),
+ @Transition( on = "pause", in = "s5", next = "s3" )})
public void playing() {
messages.add("Playing");
}
- @Handler(on = "pause", in = "s3", next = "s5")
+ @Transition(on = "pause", in = "s3", next = "s5")
public void paused() {
messages.add("Paused");
}
- @Handler(on = "stop", in = "s3", next = "s4")
+ @Transition(on = "stop", in = "s3", next = "s4")
public void stopped() {
messages.add("Stopped");
}
- @Handler(on = "*", in = "parent")
+ @Transition(on = "*", in = "parent")
public void error(Event event) {
messages.add("Error: Cannot " + event.getId() + " at this time");
}
Modified: mina/trunk/statemachine/src/test/java/org/apache/mina/statemachine/StateTest.java
URL: http://svn.apache.org/viewvc/mina/trunk/statemachine/src/test/java/org/apache/mina/statemachine/StateTest.java?rev=592122&r1=592121&r2=592122&view=diff
==============================================================================
--- mina/trunk/statemachine/src/test/java/org/apache/mina/statemachine/StateTest.java (original)
+++ mina/trunk/statemachine/src/test/java/org/apache/mina/statemachine/StateTest.java Mon Nov 5 11:10:32 2007
@@ -25,7 +25,7 @@
import com.agical.rmock.extension.junit.RMockTestCase;
/**
- * Tests {@link FsmState}.
+ * Tests {@link State}.
*
* @author The Apache MINA Project (dev@mina.apache.org)
* @version $Rev$, $Date$