Author: niklas
Date: Mon Nov 5 22:25:43 2007
New Revision: 592302
URL: http://svn.apache.org/viewvc?rev=592302&view=rev
Log:
DIRMINA-463: Created MINA specific versions of StateMachineFactory for
IoHandler and IoFilter state machines.
Added:
mina/trunk/statemachine/src/main/java/org/apache/mina/statemachine/IoFilterStateMachineFactory.java
(with props)
mina/trunk/statemachine/src/main/java/org/apache/mina/statemachine/IoHandlerStateMachineFactory.java
(with props)
Modified:
mina/trunk/example/src/main/java/org/apache/mina/example/tapedeck/Main.java
mina/trunk/statemachine/src/main/java/org/apache/mina/statemachine/StateMachineFactory.java
mina/trunk/statemachine/src/main/java/org/apache/mina/statemachine/event/IoFilterEvents.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=592302&r1=592301&r2=592302&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 22:25:43 2007
@@ -24,8 +24,8 @@
import org.apache.mina.common.IoHandler;
import org.apache.mina.filter.codec.ProtocolCodecFilter;
import org.apache.mina.filter.codec.textline.TextLineEncoder;
+import org.apache.mina.statemachine.IoHandlerStateMachineFactory;
import org.apache.mina.statemachine.StateMachine;
-import org.apache.mina.statemachine.StateMachineFactory;
import org.apache.mina.statemachine.StateMachineProxyFactory;
import org.apache.mina.statemachine.context.IoSessionStateContextLookup;
import org.apache.mina.statemachine.context.StateContext;
@@ -45,7 +45,7 @@
private static final int PORT = 12345;
private static IoHandler createIoHandler() {
- StateMachine sm =
StateMachineFactory.createForIoHandler(TapeDeckServer.EMPTY, new
TapeDeckServer());
+ StateMachine sm =
IoHandlerStateMachineFactory.create(TapeDeckServer.EMPTY, new TapeDeckServer());
return (IoHandler) StateMachineProxyFactory.create(IoHandler.class,
sm,
new IoSessionStateContextLookup(new StateContextFactory() {
Added:
mina/trunk/statemachine/src/main/java/org/apache/mina/statemachine/IoFilterStateMachineFactory.java
URL:
http://svn.apache.org/viewvc/mina/trunk/statemachine/src/main/java/org/apache/mina/statemachine/IoFilterStateMachineFactory.java?rev=592302&view=auto
==============================================================================
---
mina/trunk/statemachine/src/main/java/org/apache/mina/statemachine/IoFilterStateMachineFactory.java
(added)
+++
mina/trunk/statemachine/src/main/java/org/apache/mina/statemachine/IoFilterStateMachineFactory.java
Mon Nov 5 22:25:43 2007
@@ -0,0 +1,96 @@
+/*
+ * 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;
+
+import org.apache.mina.common.IoHandler;
+import org.apache.mina.statemachine.annotation.IoFilterTransition;
+import org.apache.mina.statemachine.annotation.IoFilterTransitions;
+
+/**
+ * Creates [EMAIL PROTECTED] StateMachine}s by reading [EMAIL PROTECTED]
org.apache.mina.statemachine.annotation.State},
+ * [EMAIL PROTECTED] IoFilterTransition} and [EMAIL PROTECTED]
IoFilterTransitions} annotations
+ * from one or more arbitrary objects. This should be used instead of
+ * [EMAIL PROTECTED] StateMachineFactory} when creating [EMAIL PROTECTED]
StateMachine}s for MINA's
+ * [EMAIL PROTECTED] IoHandler} interface.
+ *
+ *
+ * @author The Apache MINA Project ([EMAIL PROTECTED])
+ * @version $Rev$, $Date$
+ */
+public class IoFilterStateMachineFactory {
+
+ private IoFilterStateMachineFactory() {
+ }
+
+ /**
+ * Creates a new [EMAIL PROTECTED] StateMachine} from the specified
handler object and
+ * using a start state with id <code>start</code>.
+ *
+ * @param handler the object containing the annotations describing the
+ * state machine.
+ * @return the [EMAIL PROTECTED] StateMachine} object.
+ */
+ public static StateMachine create(Object handler) {
+ return create(handler, new Object[0]);
+ }
+
+ /**
+ * Creates a new [EMAIL PROTECTED] StateMachine} from the specified
handler object and
+ * using the [EMAIL PROTECTED] State} with the specified id as start state.
+ *
+ * @param start the id of the start [EMAIL PROTECTED] State} to use.
+ * @param handler the object containing the annotations describing the
+ * state machine.
+ * @return the [EMAIL PROTECTED] StateMachine} object.
+ */
+ public static StateMachine create(String start, Object handler) {
+ return create(start, handler, new Object[0]);
+ }
+
+ /**
+ * Creates a new [EMAIL PROTECTED] StateMachine} from the specified
handler objects and
+ * using a start state with id <code>start</code>.
+ *
+ * @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 [EMAIL PROTECTED] StateMachine} object.
+ */
+ public static StateMachine create(Object handler, Object... handlers) {
+ return create("start", handler, handlers);
+ }
+
+ /**
+ * Creates a new [EMAIL PROTECTED] StateMachine} from the specified
handler objects and
+ * using the [EMAIL PROTECTED] State} with the specified id as start state.
+ *
+ * @param start the id of the start [EMAIL PROTECTED] 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 [EMAIL PROTECTED] StateMachine} object.
+ */
+ public static StateMachine create(String start, Object handler, Object...
handlers) {
+ return StateMachineFactory.create(IoFilterTransition.class,
IoFilterTransitions.class, start, handler, handlers);
+ }
+
+}
Propchange:
mina/trunk/statemachine/src/main/java/org/apache/mina/statemachine/IoFilterStateMachineFactory.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
mina/trunk/statemachine/src/main/java/org/apache/mina/statemachine/IoFilterStateMachineFactory.java
------------------------------------------------------------------------------
svn:keywords = Rev Date Id
Added:
mina/trunk/statemachine/src/main/java/org/apache/mina/statemachine/IoHandlerStateMachineFactory.java
URL:
http://svn.apache.org/viewvc/mina/trunk/statemachine/src/main/java/org/apache/mina/statemachine/IoHandlerStateMachineFactory.java?rev=592302&view=auto
==============================================================================
---
mina/trunk/statemachine/src/main/java/org/apache/mina/statemachine/IoHandlerStateMachineFactory.java
(added)
+++
mina/trunk/statemachine/src/main/java/org/apache/mina/statemachine/IoHandlerStateMachineFactory.java
Mon Nov 5 22:25:43 2007
@@ -0,0 +1,96 @@
+/*
+ * 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;
+
+import org.apache.mina.common.IoHandler;
+import org.apache.mina.statemachine.annotation.IoHandlerTransition;
+import org.apache.mina.statemachine.annotation.IoHandlerTransitions;
+
+/**
+ * Creates [EMAIL PROTECTED] StateMachine}s by reading [EMAIL PROTECTED]
org.apache.mina.statemachine.annotation.State},
+ * [EMAIL PROTECTED] IoHandlerTransition} and [EMAIL PROTECTED]
IoHandlerTransitions} annotations
+ * from one or more arbitrary objects. This should be used instead of
+ * [EMAIL PROTECTED] StateMachineFactory} when creating [EMAIL PROTECTED]
StateMachine}s for MINA's
+ * [EMAIL PROTECTED] IoHandler} interface.
+ *
+ *
+ * @author The Apache MINA Project ([EMAIL PROTECTED])
+ * @version $Rev$, $Date$
+ */
+public class IoHandlerStateMachineFactory {
+
+ private IoHandlerStateMachineFactory() {
+ }
+
+ /**
+ * Creates a new [EMAIL PROTECTED] StateMachine} from the specified
handler object and
+ * using a start state with id <code>start</code>.
+ *
+ * @param handler the object containing the annotations describing the
+ * state machine.
+ * @return the [EMAIL PROTECTED] StateMachine} object.
+ */
+ public static StateMachine create(Object handler) {
+ return create(handler, new Object[0]);
+ }
+
+ /**
+ * Creates a new [EMAIL PROTECTED] StateMachine} from the specified
handler object and
+ * using the [EMAIL PROTECTED] State} with the specified id as start state.
+ *
+ * @param start the id of the start [EMAIL PROTECTED] State} to use.
+ * @param handler the object containing the annotations describing the
+ * state machine.
+ * @return the [EMAIL PROTECTED] StateMachine} object.
+ */
+ public static StateMachine create(String start, Object handler) {
+ return create(start, handler, new Object[0]);
+ }
+
+ /**
+ * Creates a new [EMAIL PROTECTED] StateMachine} from the specified
handler objects and
+ * using a start state with id <code>start</code>.
+ *
+ * @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 [EMAIL PROTECTED] StateMachine} object.
+ */
+ public static StateMachine create(Object handler, Object... handlers) {
+ return create("start", handler, handlers);
+ }
+
+ /**
+ * Creates a new [EMAIL PROTECTED] StateMachine} from the specified
handler objects and
+ * using the [EMAIL PROTECTED] State} with the specified id as start state.
+ *
+ * @param start the id of the start [EMAIL PROTECTED] 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 [EMAIL PROTECTED] StateMachine} object.
+ */
+ public static StateMachine create(String start, Object handler, Object...
handlers) {
+ return StateMachineFactory.create(IoHandlerTransition.class,
IoHandlerTransitions.class, start, handler, handlers);
+ }
+
+}
Propchange:
mina/trunk/statemachine/src/main/java/org/apache/mina/statemachine/IoHandlerStateMachineFactory.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
mina/trunk/statemachine/src/main/java/org/apache/mina/statemachine/IoHandlerStateMachineFactory.java
------------------------------------------------------------------------------
svn:keywords = Rev Date Id
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=592302&r1=592301&r2=592302&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 22:25:43 2007
@@ -32,10 +32,6 @@
import java.util.List;
import java.util.Map;
-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;
@@ -108,40 +104,6 @@
*/
public static StateMachine create(String start, Object handler, Object...
handlers) {
return create(Transition.class, Transitions.class, start, handler,
handlers);
- }
-
- /**
- * Creates a new [EMAIL PROTECTED] StateMachine} from the specified
handler objects and
- * using the [EMAIL PROTECTED] State} with the specified id as start
state. This method
- * should be used when using the [EMAIL PROTECTED] IoHandlerTransition} and
- * [EMAIL PROTECTED] IoHandlerTransitions} annotations.
- *
- * @param start the id of the start [EMAIL PROTECTED] 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 [EMAIL PROTECTED] StateMachine} object.
- */
- public static StateMachine createForIoHandler(String start, Object
handler, Object... handlers) {
- return create(IoHandlerTransition.class, IoHandlerTransitions.class,
start, handler, handlers);
- }
-
- /**
- * Creates a new [EMAIL PROTECTED] StateMachine} from the specified
handler objects and
- * using the [EMAIL PROTECTED] State} with the specified id as start
state. This method
- * should be used when using the [EMAIL PROTECTED] IoFilterTransition} and
- * [EMAIL PROTECTED] IoFilterTransitions} annotations.
- *
- * @param start the id of the start [EMAIL PROTECTED] 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 [EMAIL PROTECTED] StateMachine} object.
- */
- public static StateMachine createForIoFilter(String start, Object handler,
Object... handlers) {
- return create(IoFilterTransition.class, IoFilterTransitions.class,
start, handler, handlers);
}
/**
Modified:
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=592302&r1=592301&r2=592302&view=diff
==============================================================================
---
mina/trunk/statemachine/src/main/java/org/apache/mina/statemachine/event/IoFilterEvents.java
(original)
+++
mina/trunk/statemachine/src/main/java/org/apache/mina/statemachine/event/IoFilterEvents.java
Mon Nov 5 22:25:43 2007
@@ -37,10 +37,10 @@
SESSION_IDLE("sessionIdle"),
MESSAGE_RECEIVED("messageReceived"),
MESSAGE_SENT("messageSent"),
- FILTER_CLOSE("filterClose"),
- FILTER_WRITE("filterWrite"),
- FILTER_SET_TRAFFIC_MASK("filterSetTrafficMask"),
- EXCEPTION_CAUGHT("exceptionCaught");
+ EXCEPTION_CAUGHT("exceptionCaught"),
+ CLOSE("filterClose"),
+ WRITE("filterWrite"),
+ SET_TRAFFIC_MASK("filterSetTrafficMask");
private final String value;