Package org.apache.mina.statemachine

Examples of org.apache.mina.statemachine.StateMachine


public class Main {
    /** Choose your favorite port number. */
    private static final int PORT = 12345;
   
    private static IoHandler createIoHandler() {
        StateMachine sm = StateMachineFactory.getInstance(
                IoHandlerTransition.class).create(TapeDeckServer.EMPTY,
                new TapeDeckServer());

        return new StateMachineProxyBuilder().setStateContextLookup(
                new IoSessionStateContextLookup(new StateContextFactory() {
View Full Code Here


                    }
                })).create(IoHandler.class, sm);
    }
   
    private static IoFilter createAuthenticationIoFilter() {
        StateMachine sm = StateMachineFactory.getInstance(
                IoFilterTransition.class).create(AuthenticationHandler.START,
                new AuthenticationHandler());

        return new StateMachineProxyBuilder().setStateContextLookup(
                new IoSessionStateContextLookup(new StateContextFactory() {
View Full Code Here

        fooOrBarInCOrFooInD = States.class.getDeclaredMethod("fooOrBarInCOrFooInD", new Class[0]);
    }

    public void testCreate() throws Exception {
        States states = new States();
        StateMachine sm = StateMachineFactory.getInstance(Transition.class).create(States.A, states);

        State a = sm.getState(States.A);
        State b = sm.getState(States.B);
        State c = sm.getState(States.C);
        State d = sm.getState(States.D);

        assertEquals(States.A, a.getId());
        assertNull(a.getParent());
        assertEquals(States.B, b.getId());
        assertSame(a, b.getParent());
View Full Code Here

        fooOrBarInCOrFooInD = States.class.getDeclaredMethod("fooOrBarInCOrFooInD", new Class[0]);
    }

    public void testCreate() throws Exception {
        States states = new States();
        StateMachine sm = StateMachineFactory.getInstance(Transition.class).create(States.A, states);

        State a = sm.getState(States.A);
        State b = sm.getState(States.B);
        State c = sm.getState(States.C);
        State d = sm.getState(States.D);

        assertEquals(States.A, a.getId());
        assertNull(a.getParent());
        assertEquals(States.B, b.getId());
        assertSame(a, b.getParent());
View Full Code Here

        State s1 = new State("s1");
        s1.addTransition(new BreakAndContinueTransition("foo"));
        s1.addTransition(new SuccessTransition("foo"));

        StateContext context = new DefaultStateContext();
        StateMachine sm = new StateMachine(new State[] { s1 }, "s1");
        sm.handle(new Event("foo", context));
        assertEquals(true, context.getAttribute("success"));
    }
View Full Code Here

        State s2 = new State("s2");
        s1.addTransition(new BreakAndGotoNowTransition("foo", "s2"));
        s2.addTransition(new SuccessTransition("foo"));

        StateContext context = new DefaultStateContext();
        StateMachine sm = new StateMachine(new State[] { s1, s2 }, "s1");
        sm.handle(new Event("foo", context));
        assertEquals(true, context.getAttribute("success"));
    }
View Full Code Here

        State s2 = new State("s2");
        s1.addTransition(new BreakAndGotoNextTransition("foo", "s2"));
        s2.addTransition(new SuccessTransition("foo"));

        StateContext context = new DefaultStateContext();
        StateMachine sm = new StateMachine(new State[] { s1, s2 }, "s1");
        sm.handle(new Event("foo", context));
        assertSame(s2, context.getCurrentState());
        sm.handle(new Event("foo", context));
        assertEquals(true, context.getAttribute("success"));
    }
View Full Code Here

        State s1 = new State("s1");
        s1.addTransition(new BreakAndContinueTransition("foo"));
        s1.addTransition(new SuccessTransition("foo"));

        StateContext context = new DefaultStateContext();
        StateMachine sm = new StateMachine(new State[] { s1 }, "s1");
        sm.handle(new Event("foo", context));
        assertEquals(true, context.getAttribute("success"));
    }
View Full Code Here

        State s2 = new State("s2");
        s1.addTransition(new BreakAndGotoNowTransition("foo", "s2"));
        s2.addTransition(new SuccessTransition("foo"));

        StateContext context = new DefaultStateContext();
        StateMachine sm = new StateMachine(new State[] { s1, s2 }, "s1");
        sm.handle(new Event("foo", context));
        assertEquals(true, context.getAttribute("success"));
    }
View Full Code Here

        State s2 = new State("s2");
        s1.addTransition(new BreakAndGotoNextTransition("foo", "s2"));
        s2.addTransition(new SuccessTransition("foo"));

        StateContext context = new DefaultStateContext();
        StateMachine sm = new StateMachine(new State[] { s1, s2 }, "s1");
        sm.handle(new Event("foo", context));
        assertSame(s2, context.getCurrentState());
        sm.handle(new Event("foo", context));
        assertEquals(true, context.getAttribute("success"));
    }
View Full Code Here

TOP

Related Classes of org.apache.mina.statemachine.StateMachine

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.