Package org.apache.mina.statemachine.transition

Examples of org.apache.mina.statemachine.transition.MethodTransition


                        if (state == null) {
                            throw new StateMachineCreationException("Error encountered " + "when processing method "
                                    + m + ". Unknown state: " + in + ".");
                        }

                        state.addTransition(new MethodTransition(event, next, m, handler), annotation.weight());
                    }
                }
            }
        }
    }
View Full Code Here


        State s1 = new State("s1");
        State s2 = new State("s2");
        State s3 = new State("s3");

        s1.addTransition(new MethodTransition("call1", s2, handler));
        s2.addTransition(new MethodTransition("call2", s3, handler));
        s3.addTransition(new MethodTransition("call3", handler));

        StateMachine sm = new StateMachine(new State[] { s1, s2, s3 }, "s1");
        Reentrant reentrant = new StateMachineProxyBuilder().create(Reentrant.class, sm);
        reentrant.call1(reentrant);
        assertTrue(handler.finished);
View Full Code Here

        State s2 = new State("s2", parent);
        State s3 = new State("s3", parent);
        State s4 = new State("s4", parent);
        State s5 = new State("s5", parent);

        parent.addTransition(new MethodTransition("*", "error", handler));
        s1.addTransition(new MethodTransition("insert", s2, "inserted", handler));
        s2.addTransition(new MethodTransition("start", s3, "playing", handler));
        s3.addTransition(new MethodTransition("stop", s4, "stopped", handler));
        s3.addTransition(new MethodTransition("pause", s5, "paused", handler));
        s4.addTransition(new MethodTransition("eject", s1, "ejected", handler));
        s5.addTransition(new MethodTransition("pause", s3, "playing", handler));

        s2.addOnEntrySelfTransaction(new MethodSelfTransition("onEntryS2", handler));
        s2.addOnExitSelfTransaction(new MethodSelfTransition("onExitS2", handler));

        s3.addOnEntrySelfTransaction(new MethodSelfTransition("onEntryS3", handler));
View Full Code Here

        List<org.apache.mina.statemachine.transition.Transition> trans = null;

        trans = a.getTransitions();
        assertEquals(3, trans.size());
        assertEquals(new MethodTransition("bar", barInA, states), trans.get(0));
        assertEquals(new MethodTransition("*", error, states), trans.get(1));
        assertEquals(new MethodTransition("foo", b, fooInA, states), trans.get(2));

        trans = b.getTransitions();
        assertEquals(1, trans.size());
        assertEquals(new MethodTransition("foo", c, fooInB, states), trans.get(0));

        trans = c.getTransitions();
        assertEquals(3, trans.size());
        assertEquals(new MethodTransition("bar", a, barInC, states), trans.get(0));
        assertEquals(new MethodTransition("foo", d, fooOrBarInCOrFooInD, states), trans.get(1));
        assertEquals(new MethodTransition("bar", d, fooOrBarInCOrFooInD, states), trans.get(2));

        trans = d.getTransitions();
        assertEquals(1, trans.size());
        assertEquals(new MethodTransition("foo", fooOrBarInCOrFooInD, states), trans.get(0));
    }
View Full Code Here

    }

    public void testExecuteSubsetAllArgsMethod1OnArgsEvent() throws Exception {
        target.subsetAllArgs(context, (B) args[1], (A) args[2], ((Integer) args[3]).intValue());
        startVerification();
        MethodTransition t = new MethodTransition("event", nextState, subsetAllArgsMethod1, target);
        assertTrue(t.execute(argsEvent));
    }
View Full Code Here

    }

    public void testExecuteSubsetAllArgsMethod2OnArgsEvent() throws Exception {
        target.subsetAllArgs(argsEvent, (B) args[1], (B) args[2], ((Boolean) args[4]).booleanValue());
        startVerification();
        MethodTransition t = new MethodTransition("event", nextState, subsetAllArgsMethod2, target);
        assertTrue(t.execute(argsEvent));
    }
View Full Code Here

        argsEvent = new Event("event", context, args);
    }

    public void testExecuteWrongEventId() throws Exception {
        startVerification();
        MethodTransition t = new MethodTransition("otherEvent", nextState, "noArgs", target);
        assertFalse(t.execute(noArgsEvent));
    }
View Full Code Here

    }

    public void testExecuteNoArgsMethodOnNoArgsEvent() throws Exception {
        target.noArgs();
        startVerification();
        MethodTransition t = new MethodTransition("event", nextState, "noArgs", target);
        assertTrue(t.execute(noArgsEvent));
    }
View Full Code Here

    }

    public void testExecuteNoArgsMethodOnArgsEvent() throws Exception {
        target.noArgs();
        startVerification();
        MethodTransition t = new MethodTransition("event", nextState, "noArgs", target);
        assertTrue(t.execute(argsEvent));
    }
View Full Code Here

        assertTrue(t.execute(argsEvent));
    }

    public void testExecuteExactArgsMethodOnNoArgsEvent() throws Exception {
        startVerification();
        MethodTransition t = new MethodTransition("event", nextState, "exactArgs", target);
        assertFalse(t.execute(noArgsEvent));
    }
View Full Code Here

TOP

Related Classes of org.apache.mina.statemachine.transition.MethodTransition

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.