river-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gtra...@apache.org
Subject [38/40] Hierarchical State Machine is now broken out to its own module (river-hsm) and clears almost all findbugs/pmd/etc checks.
Date Mon, 13 Jan 2014 03:35:45 GMT
http://git-wip-us.apache.org/repos/asf/river-container/blob/3e29cd2d/river-container-core/src/main/java/org/apache/river/container/hsm/Transition.java
----------------------------------------------------------------------
diff --git a/river-container-core/src/main/java/org/apache/river/container/hsm/Transition.java b/river-container-core/src/main/java/org/apache/river/container/hsm/Transition.java
deleted file mode 100644
index 75348f4..0000000
--- a/river-container-core/src/main/java/org/apache/river/container/hsm/Transition.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * 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.river.container.hsm;
-
-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;
-
-/**
- * Annotation type to indicate an unconditional  transition that is applied after an
- * event method is executed.  
- */
-@Documented
-@Retention(RetentionPolicy.RUNTIME)
-@Target(ElementType.METHOD)
-public @interface Transition {
-
-    /**
-     * An array of state classes that reflect the target states for this
-     * state variable.
-     *
-     * @return
-     */
-    Class[] value();
-}

http://git-wip-us.apache.org/repos/asf/river-container/blob/3e29cd2d/river-container-core/src/main/java/org/apache/river/container/hsm/TransitionOnSubstate.java
----------------------------------------------------------------------
diff --git a/river-container-core/src/main/java/org/apache/river/container/hsm/TransitionOnSubstate.java b/river-container-core/src/main/java/org/apache/river/container/hsm/TransitionOnSubstate.java
deleted file mode 100644
index 8fdd426..0000000
--- a/river-container-core/src/main/java/org/apache/river/container/hsm/TransitionOnSubstate.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * 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.river.container.hsm;
-
-/**
- * Holds a transition on a substate.
- */
-public class TransitionOnSubstate {
-    
-    // package access, so the executor can use it directly.
-    SubstateInfo substate;
-
-    /**
-     * Create an instance specifying the target metastate for the given
-     * substate.
-     * 
-     * @param substate
-     * @param targetMetaState 
-     */
-    public TransitionOnSubstate(SubstateInfo substate, MetaState targetMetaState) {
-        this.substate = substate;
-        this.targetMetaState = targetMetaState;
-    }
-
-    public SubstateInfo getSubstate() {
-        return substate;
-    }
-
-
-    public MetaState getTargetMetaState() {
-        return targetMetaState;
-    }
-    
-    // package access, so the executor can use it directly.
-    MetaState targetMetaState;
-    
-    
-}

http://git-wip-us.apache.org/repos/asf/river-container/blob/3e29cd2d/river-container-core/src/main/resources/org/apache/river/container/hsm/Messages.properties
----------------------------------------------------------------------
diff --git a/river-container-core/src/main/resources/org/apache/river/container/hsm/Messages.properties b/river-container-core/src/main/resources/org/apache/river/container/hsm/Messages.properties
deleted file mode 100644
index 32f94c5..0000000
--- a/river-container-core/src/main/resources/org/apache/river/container/hsm/Messages.properties
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * 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.
- */
-
-applyingEventToState=Applying event {0} to state {1} instance {2}.
-beginningCompile=Begginning state machine compilation on {0}.
-compileCompleted=Completed compile on {0}.
-cantResolveTransitionsForClass=Can''t find any valid targets for transition ''{1}'' from the context of state class ''{0}''.
-entryMethodIsntVoid=Methods annotated with @OnEntry need to return void.  Method {0} returns {1}.
-errorApplyingTransition=Got an error while applying a transition: {0}.
-errorCreatingProxy=Error Creating Proxy.
-errorInvokingTargetMethod=Error invoking target method on state instance.
-errorInstantiating=Error while instantiating the state machine: {0}.
-exitMethodIsntVoid=Methods annotated with @OnExit need to return void.  Method {0} returns {1}.
-guardMethodDoesntReturnBoolean=Methods annotated with @Guard need to return a boolean value.  Method {0} returns {1}.
-metaStateWasInstantiated=MetaState for {0} was instantiated as {1}.
-multipleExceptionsThrown=Execution of the event threw multiple exceptions.
-noParentInstance=Couldn''t find a parent instance for {0} starting at state class {1}.
-queuedTransition=Queued transition to {0} on {1}.
-runningGuardOnState=Running guard method {0} on state {1} instance {2}.
-runningGuardTransitions=Guard method {0} on state {1} instance {2} returned true - running transitions.
-settingFieldTo=Setting field {0} on {1} to {2}.
-settingInitialSubstate=Setting initial substate field {0} on state {1}.
-storingException=Storing exception {2} thrown while executing {1} on {0}.

http://git-wip-us.apache.org/repos/asf/river-container/blob/3e29cd2d/river-container-core/src/test/java/org/apache/river/container/hsm/HSMTestSuite.java
----------------------------------------------------------------------
diff --git a/river-container-core/src/test/java/org/apache/river/container/hsm/HSMTestSuite.java b/river-container-core/src/test/java/org/apache/river/container/hsm/HSMTestSuite.java
deleted file mode 100644
index e21e0fc..0000000
--- a/river-container-core/src/test/java/org/apache/river/container/hsm/HSMTestSuite.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright 2001-2005 The Apache Software Foundation.
- *
- * 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.apache.river.container.hsm;
-
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-
-/**
- *
- * @author trasukg
- */
-@RunWith(Suite.class)
-@Suite.SuiteClasses({LoggingTest.class, ReturnTypeTest.class, InitializedMachineTest.class, StateMachineCompilerTest.class, PlainMachineExecutorTest.class})
-public class HSMTestSuite {
-
-    @BeforeClass
-    public static void setUpClass() throws Exception {
-    }
-
-    @AfterClass
-    public static void tearDownClass() throws Exception {
-    }
-
-    @Before
-    public void setUp() throws Exception {
-    }
-
-    @After
-    public void tearDown() throws Exception {
-    }
-    
-}

http://git-wip-us.apache.org/repos/asf/river-container/blob/3e29cd2d/river-container-core/src/test/java/org/apache/river/container/hsm/InitializedMachineTest.java
----------------------------------------------------------------------
diff --git a/river-container-core/src/test/java/org/apache/river/container/hsm/InitializedMachineTest.java b/river-container-core/src/test/java/org/apache/river/container/hsm/InitializedMachineTest.java
deleted file mode 100644
index 47149fe..0000000
--- a/river-container-core/src/test/java/org/apache/river/container/hsm/InitializedMachineTest.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * 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.river.container.hsm;
-
-import java.util.logging.Level;
-import java.util.logging.Logger;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import static org.junit.Assert.*;
-
-/**
- *
- * @author trasukg
- */
-public class InitializedMachineTest {
-
-    public InitializedMachineTest() {
-    }
-
-    @BeforeClass
-    public static void setUpClass() {
-        Logger.getLogger("org.apache.river.container.hsm").setLevel(Level.FINEST);
-    }
-
-    @AfterClass
-    public static void tearDownClass() {
-    }
-
-    @Before
-    public void setUp() throws Exception {
-        UUT=new InitializedTestSM();
-        UUTI=(InitializedTestSMInterface) PlainStateMachineExecutor.createProxy(UUT);
-    }
-
-    @After
-    public void tearDown() {
-    }
-
-    InitializedTestSMInterface UUTI=null;
-    InitializedTestSM UUT=null;
-    
-    @Test(expected=IllegalStateException.class)
-    public void testLockedException() throws Exception {
-        UUTI.setValue(20);
-    }
-    
-    /**
-     * If we transition to unlocked, then that means the @Transition tag
-     * was interpreted and executed correctly.
-     */
-    @Test
-    public void testUnlocking() {
-        UUTI.unlock();
-        assertTrue("lockedState is not instance of Unlocked", UUT.lockedState instanceof InitializedTestSM.Unlocked);
-        UUTI.setValue(20);
-    }
-    
-    /**
-     * The "Armed" state subclasses Locked, so the unlocking should continue to
-     * work.
-     */
-    @Test
-    public void testArming() {
-        UUTI.arm();
-        assertTrue("lockedState is not instance of Armed", UUT.lockedState instanceof InitializedTestSM.Armed);
-        
-        UUTI.unlock();
-        assertTrue("lockedState is not instance of Unlocked", UUT.lockedState instanceof InitializedTestSM.Unlocked);
-        UUTI.setValue(20);
-        
-    }
-    
-    /**
-     * Test that the methods are executing against the same instance that we
-     * created.
-     */
-    @Test
-    public void testSameInstance() {
-        UUTI.unlock();
-        UUTI.setValue(20);
-        assertEquals("Value through local instance", 20, UUT.getValue());
-    }
-}

http://git-wip-us.apache.org/repos/asf/river-container/blob/3e29cd2d/river-container-core/src/test/java/org/apache/river/container/hsm/InitializedTestSM.java
----------------------------------------------------------------------
diff --git a/river-container-core/src/test/java/org/apache/river/container/hsm/InitializedTestSM.java b/river-container-core/src/test/java/org/apache/river/container/hsm/InitializedTestSM.java
deleted file mode 100644
index 4a3a80a..0000000
--- a/river-container-core/src/test/java/org/apache/river/container/hsm/InitializedTestSM.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * 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.river.container.hsm;
-
-/**
- * State machine to test whether the state machine correctly uses the supplied
- * root state object.
- */
-@RootState(InitializedTestSMInterface.class)
-public class InitializedTestSM {
-
-    private int value = 0;
-
-    @State({Locked.class, Unlocked.class, Armed.class})
-    @Initial(Locked.class)
-    Object lockedState;
-
-    public int getValue() {
-        return value;
-    }
-
-    public class Locked {
-
-        @Transition(Unlocked.class)
-        public void unlock() {
-            System.out.println("Locked.unlock()");
-        }
-
-        public void setValue(int v) {
-            throw new IllegalStateException("Locked!");
-        }
-
-        @Transition(Armed.class)
-        public void arm() {
-        }
-    }
-
-    public class Armed extends Locked {
-    }
-
-    public class Unlocked {
-
-        @Transition(Locked.class)
-        public void lock() {
-            System.out.println("Unlocked.lock()");
-        }
-
-        public void setValue(int v) {
-            value = v;
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/river-container/blob/3e29cd2d/river-container-core/src/test/java/org/apache/river/container/hsm/InitializedTestSMInterface.java
----------------------------------------------------------------------
diff --git a/river-container-core/src/test/java/org/apache/river/container/hsm/InitializedTestSMInterface.java b/river-container-core/src/test/java/org/apache/river/container/hsm/InitializedTestSMInterface.java
deleted file mode 100644
index a1c50a5..0000000
--- a/river-container-core/src/test/java/org/apache/river/container/hsm/InitializedTestSMInterface.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * 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.river.container.hsm;
-
-/**
- *
- * Interface for test of initialized state machine.
- */
-public interface InitializedTestSMInterface {
-    public void lock();
-    
-    public void unlock();
-    
-    public void arm();
-    
-    public void setValue(int x);
-    
-    public int getValue();
-}

http://git-wip-us.apache.org/repos/asf/river-container/blob/3e29cd2d/river-container-core/src/test/java/org/apache/river/container/hsm/LoggingTest.java
----------------------------------------------------------------------
diff --git a/river-container-core/src/test/java/org/apache/river/container/hsm/LoggingTest.java b/river-container-core/src/test/java/org/apache/river/container/hsm/LoggingTest.java
deleted file mode 100644
index 8380458..0000000
--- a/river-container-core/src/test/java/org/apache/river/container/hsm/LoggingTest.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Copyright 2001-2005 The Apache Software Foundation.
- *
- * 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.apache.river.container.hsm;
-
-import java.util.logging.Level;
-import java.util.logging.Logger;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import static org.junit.Assert.*;
-
-/**
- *
- * @author trasukg
- */
-public class LoggingTest {
-
-    Logger log=Logger.getLogger(LoggingTest.class.getName());
-    
-    public LoggingTest() {
-    }
-
-    @BeforeClass
-    public static void setUpClass() throws Exception {
-        Logger.getLogger("org.apache.river.container.hsm").setLevel(Level.FINER);
-        System.setProperty("java.util.logging.ConsoleHandler.level", "FINER");
-    }
-   
-
-    @AfterClass
-    public static void tearDownClass() {
-    }
-
-    @Before
-    public void setUp() {
-    }
-
-    @After
-    public void tearDown() {
-    }
-    
-    @Test
-    public void testLogging() {
-        System.out.println("Should be seeing some logging...");
-        
-        
-        log.log(Level.FINEST, "Finest");
-        log.log(Level.FINER, "Finer");
-        log.log(Level.FINE, "Fine");
-        log.log(Level.INFO, "Info");
-        log.log(Level.WARNING, "Warning");
-        log.log(Level.SEVERE, "Severe");
-    }
-}

http://git-wip-us.apache.org/repos/asf/river-container/blob/3e29cd2d/river-container-core/src/test/java/org/apache/river/container/hsm/PlainMachineExecutorTest.java
----------------------------------------------------------------------
diff --git a/river-container-core/src/test/java/org/apache/river/container/hsm/PlainMachineExecutorTest.java b/river-container-core/src/test/java/org/apache/river/container/hsm/PlainMachineExecutorTest.java
deleted file mode 100644
index ff5eae0..0000000
--- a/river-container-core/src/test/java/org/apache/river/container/hsm/PlainMachineExecutorTest.java
+++ /dev/null
@@ -1,238 +0,0 @@
-/*
- * 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.river.container.hsm;
-
-import java.util.List;
-import java.lang.reflect.InvocationTargetException;
-import java.util.logging.Logger;
-import java.lang.reflect.Field;
-import java.util.logging.Level;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-/**
- *
- * @author trasukg
- */
-public class PlainMachineExecutorTest {
-
-    private static final Logger log =
-            Logger.getLogger(PlainMachineExecutorTest.class.getName());
-
-    public PlainMachineExecutorTest() throws InstantiationException, IllegalAccessException,
-            NoSuchMethodException, InvocationTargetException {
-    }
-
-    @BeforeClass
-    public static void setUpClass() throws Exception {
-        Logger.getLogger("org.apache.river.container.hsm").setLevel(Level.FINER);
-    }
-
-    @AfterClass
-    public static void tearDownClass() throws Exception {
-    }
-
-    @Before
-    public void setUp() {
-    }
-
-    @After
-    public void tearDown() {
-    }
-    TestSMInterface UUT = (TestSMInterface) PlainStateMachineExecutor.createProxy(TestSM.class);
-
-    @Test
-    /**
-     * Verify that the list of active states is correct at beginning.
-     *
-     */
-    public void testActiveStates() {
-
-        assertEquals(3, UUT.getActiveStates().size());
-        assertTrue("activeStates should contain root state.",
-                UUT.getActiveStates().contains(TestSM.class));
-        assertTrue("activeStates should contain A.",
-                UUT.getActiveStates().contains(TestSM.A.class));
-        assertTrue("activeStates should contain A1.",
-                UUT.getActiveStates().contains(TestSM.A.A1.class));
-    }
-
-    @Test
-    /**
-     * Test that the top-level (state-invariant) sayHelloConstant() method
-     * returns the correct value. Verifies that the top-level proxy is
-     * functioning correctly.
-     */
-    public void testStateMachine() throws InstantiationException, IllegalAccessException {
-        assertEquals("Hello", UUT.sayConstantHello());
-    }
-
-    @Test
-    /**
-     * Test that the top-level (state-invariant) sayHelloConstant() method
-     * returns the correct value. Verifies that the top-level proxy is
-     * functioning correctly.
-     */
-    public void testNullReturn() throws InstantiationException, IllegalAccessException {
-        assertEquals(null, UUT.returnNull());
-    }
-
-    @Test
-    /**
-     * <p> Verify that transitions from state A to B work, and that the
-     * behaviour varies with state. </p>
-     *
-     * <p> First call to sayHello() should return "Hello", second call should
-     * return "There". </p>
-     *
-     */
-    public void testSimpleTransition() throws InstantiationException, IllegalAccessException {
-        assertTrue("activeStates should contain A.",
-                UUT.getActiveStates().contains(TestSM.A.class));
-        log.info("\n\nCalling hello()\n\n");
-        assertEquals("Hello", UUT.sayHello());
-        log.info("\n\n...done\n\n");
-        List<Class> activeStates = UUT.getActiveStates();
-        assertTrue("activeStates should contain B after transition.",
-                activeStates.contains(TestSM.B.class));
-        log.info("TestSM.B appears to have been active.");
-        assertFalse("activeStates should not contain A after transition.",
-                activeStates.contains(TestSM.A.class));
-        assertEquals("There", UUT.sayHello());
-    }
-
-    @Test
-    /**
-     * When we enter a state, the entry method should be called.
-     */
-    public void testEntryMethodExecution() {
-        assertEquals(1, UUT.getAEntryCount());
-        UUT.sayHello();
-        assertEquals(1, UUT.getAExitCount());
-    }
-
-    @Test
-    /**
-     * When we transition to a state but we are already in that state, the
-     * onEntry method should not be run.
-     */
-    public void testNullTransition() {
-        UUT.nullTransition();
-        UUT.nullTransition();
-        UUT.nullTransition();
-        assertEquals(1, UUT.getNullTransitionEntryCount());
-    }
-
-    @Test
-    /**
-     * Make sure that the gotoA() and gotoB() methods cause the appropriate
-     * transitions.
-     */
-    public void testABTransitions() {
-        UUT.gotoA();
-        assertTrue("activeStates should contain A.",
-                UUT.getActiveStates().contains(TestSM.A.class));
-        assertFalse("activeStates should not contain B.",
-                UUT.getActiveStates().contains(TestSM.B.class));
-        UUT.gotoB();
-
-        assertFalse("activeStates should not contain A.",
-                UUT.getActiveStates().contains(TestSM.A.class));
-        assertTrue("activeStates should contain B.",
-                UUT.getActiveStates().contains(TestSM.B.class));
-
-        UUT.gotoA();
-        assertTrue("activeStates should contain A.",
-                UUT.getActiveStates().contains(TestSM.A.class));
-        assertFalse("activeStates should not contain B.",
-                UUT.getActiveStates().contains(TestSM.B.class));
-    }
-
-    @Test
-    /**
-     * @Retained annotations should be respected, and states should be
-     * initialized on entry if the
-     * @Retained is not there.
-     */
-    public void testStateInitialization() {
-        UUT.gotoA();
-        assertTrue("activeStates should contain A.",
-                UUT.getActiveStates().contains(TestSM.A.class));
-        assertFalse("activeStates should not contain B.",
-                UUT.getActiveStates().contains(TestSM.B.class));
-        UUT.gotoB();
-
-        assertFalse("activeStates should not contain A.",
-                UUT.getActiveStates().contains(TestSM.A.class));
-        assertTrue("activeStates should contain B.",
-                UUT.getActiveStates().contains(TestSM.B.class));
-        assertTrue("activeStates should contain B1.",
-                UUT.getActiveStates().contains(TestSM.B1.class));
-
-        UUT.moveSubstateOfB();
-        assertTrue("activeStates should contain B2.",
-                UUT.getActiveStates().contains(TestSM.B2.class));
-        UUT.gotoA();
-        /* the substate isn't marked @Retained, so should reset to initial
-         on gotoB().
-         */
-        UUT.gotoB();
-        assertTrue("activeStates should contain B1.",
-                UUT.getActiveStates().contains(TestSM.B1.class));
-
-
-    }
-
-    @Test
-    /**
-     * <p> Verify that the second interface is on the proxy and effective. </p>
-     *
-     * <p> After call to doSecondInterfaceAction(), call to sayHello() should
-     * return "HelloFromC". </p>
-     *
-     */
-    public void testSecondInterface() throws InstantiationException, IllegalAccessException {
-        log.info("\n\nCalling doSecondInterfaceAction()\n\n");
-        TestSMSecondInterface UUT2=(TestSMSecondInterface) UUT;
-        UUT2.doSecondInterfaceAction();
-        log.info("\n\n...done\n\n");
-        List<Class> activeStates = UUT.getActiveStates();
-        assertTrue("activeStates should contain C after transition.",
-                activeStates.contains(TestSM.C.class));
-        log.info("TestSM.C appears to have been active.");
-        assertFalse("activeStates should not contain A after transition.",
-                activeStates.contains(TestSM.A.class));
-        assertEquals("HelloFromC", UUT.sayHello());
-    }
-    
-    
-    /**
-     * Calling an event method that isn't implemented in the current state
-     * should throw an IllegalStateException.
-     */
-    @Test(expected = IllegalStateException.class)
-    public void testUnimplementedMethod() {
-        UUT.unimplementedMethod();
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/river-container/blob/3e29cd2d/river-container-core/src/test/java/org/apache/river/container/hsm/ReturnTypeTest.java
----------------------------------------------------------------------
diff --git a/river-container-core/src/test/java/org/apache/river/container/hsm/ReturnTypeTest.java b/river-container-core/src/test/java/org/apache/river/container/hsm/ReturnTypeTest.java
deleted file mode 100644
index 82b29f2..0000000
--- a/river-container-core/src/test/java/org/apache/river/container/hsm/ReturnTypeTest.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright 2001-2005 The Apache Software Foundation.
- *
- * 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.apache.river.container.hsm;
-
-import java.lang.reflect.Method;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import static org.junit.Assert.*;
-/**
- *
- * @author trasukg
- */
-public class ReturnTypeTest {
-    
-    public ReturnTypeTest() {
-    }
-    
-    @BeforeClass
-    public static void setUpClass() {
-    }
-    
-    @AfterClass
-    public static void tearDownClass() {
-    }
-    
-    @Before
-    public void setUp() {
-    }
-    
-    @After
-    public void tearDown() {
-    }
-    
-    /**
-     * Expectation is that if a method is declared to return 'void', then the
-     * 'Method.getReturnType()' value should be null;
-     */
-    @Test
-    public void testVoidReturnType() throws Exception {
-        Method m=this.getClass().getMethod("testVoidReturnType", new Class[0]);
-        assertEquals("return type wasn't void", void.class, m.getReturnType());
-        
-    }
-}

http://git-wip-us.apache.org/repos/asf/river-container/blob/3e29cd2d/river-container-core/src/test/java/org/apache/river/container/hsm/StateMachineCompilerTest.java
----------------------------------------------------------------------
diff --git a/river-container-core/src/test/java/org/apache/river/container/hsm/StateMachineCompilerTest.java b/river-container-core/src/test/java/org/apache/river/container/hsm/StateMachineCompilerTest.java
deleted file mode 100644
index f6cbc0b..0000000
--- a/river-container-core/src/test/java/org/apache/river/container/hsm/StateMachineCompilerTest.java
+++ /dev/null
@@ -1,146 +0,0 @@
-/*
- * 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.river.container.hsm;
-
-import java.lang.reflect.Method;
-import java.util.Collection;
-import java.util.List;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import static org.junit.Assert.*;
-
-/**
- * Test the State Machine Compiler
- *
- */
-public class StateMachineCompilerTest {
-
-    public StateMachineCompilerTest() {
-    }
-
-    @BeforeClass
-    public static void setUpClass() {
-    }
-
-    @AfterClass
-    public static void tearDownClass() {
-    }
-
-    @Before
-    public void setUp() {
-    }
-
-    @After
-    public void tearDown() {
-    }
-    StateMachineCompiler compiler = new StateMachineCompiler();
-
-    @Test
-    public void testCompileReturnsMetaState() throws Exception {
-        MetaState stateMachine = compiler.compile(TestSM.class);
-        assertTrue(stateMachine + " isn't a MetaState", stateMachine instanceof MetaState);
-    }
-
-    @Test
-    public void testSampleActiveStates() throws Exception {
-        MetaState stateMachine = compiler.compile(TestSM.class);
-        List<Class> activeStates = stateMachine.getActiveStates();
-        checkContains(activeStates, TestSM.class);
-        checkContains(activeStates, TestSM.A.class);
-        checkContains(activeStates, TestSM.A.A1.class);
-    }
-
-    /**
-     * MetaState for TestSM should have event methods for sayHello and
-     * nullTransition, but nothing else.
-     *
-     * @throws Exception
-     */
-    @Test
-    public void testEventMethods() throws Exception {
-        MetaState stateMachine = compiler.compile(TestSM.class);
-        Collection<Method> methods = stateMachine.eventMethods.keySet();
-        Method sayHello = TestSMInterface.class.getMethod("sayHello");
-        assertNotNull("Didn't find sayHello() method in interface", sayHello);
-        checkContains(methods, sayHello);
-    }
-
-    /**
-     * A method annotated with
-     *
-     * @Guard should be reflected by a guarded transition operation.
-     * @throws Exception
-     */
-    @Test
-    public void testGuardMethod() throws Exception {
-        MetaState rootState = compiler.compile(TestSM.class);
-        assertEquals("Number of guard methods on root metastate", 1, rootState.guardMethods.size());
-
-    }
-
-    private void checkContains(Collection<?> collection, Object requiredObject) {
-        assertTrue(collection + " doesn't include " + requiredObject, collection.contains(requiredObject));
-    }
-
-    /**
-     * A method annotated with
-     *
-     * @Entry should be reflected by an invoke operation in the metastate.
-     * @throws Exception
-     */
-    @Test
-    public void testEntryMethod() throws Exception {
-        MetaState rootState = compiler.compile(TestSM.class);
-        MetaState metaStateA = findMetaState(rootState, TestSM.A.class);
-        assertEquals("Count of onEntry methods for A", 1, metaStateA.entryMethods.size());
-    }
-
-    /**
-     * A method annotated with
-     *
-     * @Entry should be reflected by an invoke operation in the metastate.
-     * @throws Exception
-     */
-    @Test
-    public void testExitMethod() throws Exception {
-        MetaState rootState = compiler.compile(TestSM.class);
-        MetaState metaStateA = findMetaState(rootState, TestSM.A.class);
-        assertEquals("Count of onExit methods for A", 1, metaStateA.exitMethods.size());
-    }
-
-    MetaState findMetaState(MetaState metaState, Class stateClass) {
-        for (SubstateInfo ssi : metaState.substates) {
-            for (MetaState ms : ssi.getPossibleMetaStates()) {
-                if (ms.stateClass == stateClass) {
-                    return ms;
-                }
-            }
-        }
-        return null;
-    }
-
-    @Test
-    public void testStructure() throws Exception {
-        MetaState rootState = compiler.compile(TestSM.class);
-        String expectedStructure = "TestSM(state(A(state(A1 ) B(state(B1 B2 B3 ) ) ";
-        String actualStructure = rootState.getStateStructure();
-    }
-}

http://git-wip-us.apache.org/repos/asf/river-container/blob/3e29cd2d/river-container-core/src/test/java/org/apache/river/container/hsm/TestSM.java
----------------------------------------------------------------------
diff --git a/river-container-core/src/test/java/org/apache/river/container/hsm/TestSM.java b/river-container-core/src/test/java/org/apache/river/container/hsm/TestSM.java
deleted file mode 100644
index 2bfeada..0000000
--- a/river-container-core/src/test/java/org/apache/river/container/hsm/TestSM.java
+++ /dev/null
@@ -1,150 +0,0 @@
-/*
- * 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.river.container.hsm;
-
-import java.util.List;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- *
- * @author trasukg
- */
-@RootState({TestSMInterface.class, TestSMSecondInterface.class})
-public class TestSM {
-
-    @State({A.class, B.class, C.class})
-    @Initial(A.class)
-    @Retained
-    public Object state;
-    
-    /* Really shouldn't need to be public - we'll fix shortly. */
-    @Controller
-    public StateMachineInfo controller;
-    int nullTransitionEntryCount = 0;
-    int aEntryCount = 0, aExitCount = 0;
-
-    public Object returnNull() {
-        return null;
-    }
-    
-    public List<Class> getActiveStates() {
-        try {
-            return controller.getActiveStates();
-        } catch (IllegalArgumentException ex) {
-            Logger.getLogger(TestSM.class.getName()).log(Level.SEVERE, null, ex);
-            throw new RuntimeException(ex);
-        } 
-    }
-
-    @Transition(A.class)
-    public void gotoA() {
-        //controller.transition(A.class);
-    }
-
-    @Transition(B.class)
-    public void gotoB() {
-        //controller.transition(B.class);
-    }
-
-    @Transition(C.class)
-    public void doSecondInterfaceAction() { }
-    
-    public int getAEntryCount() {
-        return aEntryCount;
-    }
-
-    public int getAExitCount() {
-        return aExitCount;
-    }
-
-    public int getNullTransitionEntryCount() {
-        return nullTransitionEntryCount;
-    }
-
-    public String sayConstantHello() {
-        return "Hello";
-    }
-
-    @Guard(A.class)
-    public boolean beFalse() {
-        return false;
-    }
-    
-    public class A {
-
-        @State({A1.class})
-        @Initial(A1.class)
-        public Object state;
-        
-        @Transition(B.class)
-        public String sayHello() {
-            //controller.transition(B.class);
-            return "Hello";
-        }
-
-        @Transition(A.class)
-        public void nullTransition() {
-            //controller.transition(A.class);
-        }
-
-        @OnEntry
-        public void onEntry() {
-            aEntryCount++;
-            nullTransitionEntryCount++;
-        }
-
-        @OnExit
-        public void onExit() {
-            aExitCount++;
-        }
-        
-        public class A1 {}
-    }
-
-    public class B {
-
-        @State({B1.class, B2.class, B3.class})
-        @Initial(B1.class)
-        Object state;
-
-        public String sayHello() {
-            return "There";
-        }
-    }
-
-    public class B1 {
-
-        @Transition(B2.class)
-        public void moveSubstateOfB() {
-            
-        }
-    }
-
-    public class B2 {
-    }
-
-    public class B3 {
-    }
-    
-    public class C {
-        public String sayHello() {
-            return "HelloFromC";
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/river-container/blob/3e29cd2d/river-container-core/src/test/java/org/apache/river/container/hsm/TestSMInterface.java
----------------------------------------------------------------------
diff --git a/river-container-core/src/test/java/org/apache/river/container/hsm/TestSMInterface.java b/river-container-core/src/test/java/org/apache/river/container/hsm/TestSMInterface.java
deleted file mode 100644
index 639a74e..0000000
--- a/river-container-core/src/test/java/org/apache/river/container/hsm/TestSMInterface.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * 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.river.container.hsm;
-
-import java.util.List;
-
-/**
- *
- * @author trasukg
- */
-public interface TestSMInterface {
-
-    public String sayHello();
-
-    public String sayConstantHello();
-
-    public Object returnNull();
-
-    public int getNullTransitionEntryCount();
-
-    public void nullTransition();
-
-    public int getAEntryCount();
-
-    public int getAExitCount();
-
-    public void moveSubstateOfB();
-
-    public void gotoA();
-    public void gotoB();
-
-    List<Class> getActiveStates();
-    
-    public void unimplementedMethod();
-}

http://git-wip-us.apache.org/repos/asf/river-container/blob/3e29cd2d/river-container-core/src/test/java/org/apache/river/container/hsm/TestSMSecondInterface.java
----------------------------------------------------------------------
diff --git a/river-container-core/src/test/java/org/apache/river/container/hsm/TestSMSecondInterface.java b/river-container-core/src/test/java/org/apache/river/container/hsm/TestSMSecondInterface.java
deleted file mode 100644
index 8f82ae1..0000000
--- a/river-container-core/src/test/java/org/apache/river/container/hsm/TestSMSecondInterface.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * 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.river.container.hsm;
-
-import java.util.List;
-
-/**
- *
- * @author trasukg
- */
-public interface TestSMSecondInterface {
-
-    public void doSecondInterfaceAction();
-}

http://git-wip-us.apache.org/repos/asf/river-container/blob/3e29cd2d/river-hsm/pom.xml
----------------------------------------------------------------------
diff --git a/river-hsm/pom.xml b/river-hsm/pom.xml
new file mode 100644
index 0000000..bddb668
--- /dev/null
+++ b/river-hsm/pom.xml
@@ -0,0 +1,94 @@
+<?xml version="1.0"?>
+<!--
+ 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.
+
+-->
+<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.apache.river.container</groupId>
+        <artifactId>river-container</artifactId>
+        <version>1.0-SNAPSHOT</version>
+    </parent>
+    <groupId>org.apache.river.container</groupId>
+    <artifactId>river-hsm</artifactId>
+    <version>1.0-SNAPSHOT</version>
+    <name>river-hsm</name>
+    <url>http://maven.apache.org</url>
+    <properties>
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+    </properties>
+    <dependencies>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <version>4.11</version>
+            <scope>test</scope>
+        </dependency>
+    </dependencies>
+  
+    <reporting>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-pmd-plugin</artifactId>
+                <version>3.0.1</version>
+            </plugin>
+
+            <plugin>
+                <groupId>org.codehaus.mojo</groupId>
+                <artifactId>cobertura-maven-plugin</artifactId>
+                <version>2.6</version>
+            </plugin>
+
+            <plugin>
+                <groupId>org.codehaus.mojo</groupId>
+                <artifactId>findbugs-maven-plugin</artifactId>
+                <version>2.5.3</version>
+            </plugin>
+            
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-javadoc-plugin</artifactId>
+                <version>2.9.1</version>
+                <configuration>
+                  
+                </configuration>
+            </plugin>
+            
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-checkstyle-plugin</artifactId>
+                <version>2.11</version>
+                <reportSets>
+                    <reportSet>
+                        <reports>
+                            <report>checkstyle</report>
+                        </reports>
+                    </reportSet>
+                </reportSets>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-surefire-report-plugin</artifactId>
+                <version>2.16</version>
+            </plugin>
+        </plugins>
+    </reporting>
+
+</project>

http://git-wip-us.apache.org/repos/asf/river-container/blob/3e29cd2d/river-hsm/src/main/java/org/apache/river/container/hsm/Controller.java
----------------------------------------------------------------------
diff --git a/river-hsm/src/main/java/org/apache/river/container/hsm/Controller.java b/river-hsm/src/main/java/org/apache/river/container/hsm/Controller.java
new file mode 100644
index 0000000..4e8d546
--- /dev/null
+++ b/river-hsm/src/main/java/org/apache/river/container/hsm/Controller.java
@@ -0,0 +1,36 @@
+/*
+ * 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.river.container.hsm;
+
+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;
+
+/**
+ *
+ * @author trasukg
+ */
+@Documented
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.FIELD)
+public @interface Controller {
+
+}

http://git-wip-us.apache.org/repos/asf/river-container/blob/3e29cd2d/river-hsm/src/main/java/org/apache/river/container/hsm/Guard.java
----------------------------------------------------------------------
diff --git a/river-hsm/src/main/java/org/apache/river/container/hsm/Guard.java b/river-hsm/src/main/java/org/apache/river/container/hsm/Guard.java
new file mode 100644
index 0000000..f495f51
--- /dev/null
+++ b/river-hsm/src/main/java/org/apache/river/container/hsm/Guard.java
@@ -0,0 +1,43 @@
+/*
+ * 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.river.container.hsm;
+
+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;
+
+/**
+ * Annotation type to indicate a guard method.  The annotated method must return
+ * a boolean value.  The method is run after the action events are run.  If the
+ * method returns true, the indicated transition is taken.
+ */
+@Documented
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.METHOD)
+public @interface Guard {
+
+    /**
+     * An array of state classes that reflect the target states for this
+     * state variable.
+     *
+     * @return
+     */
+    Class[] value();
+}

http://git-wip-us.apache.org/repos/asf/river-container/blob/3e29cd2d/river-hsm/src/main/java/org/apache/river/container/hsm/Initial.java
----------------------------------------------------------------------
diff --git a/river-hsm/src/main/java/org/apache/river/container/hsm/Initial.java b/river-hsm/src/main/java/org/apache/river/container/hsm/Initial.java
new file mode 100644
index 0000000..4d59888
--- /dev/null
+++ b/river-hsm/src/main/java/org/apache/river/container/hsm/Initial.java
@@ -0,0 +1,40 @@
+/*
+ * 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.river.container.hsm;
+
+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;
+
+/**
+ Annotation to indicate the initial value of a field annotated with @State.
+ * @author trasukg
+ */
+@Documented
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.FIELD)
+public @interface Initial {
+    /**
+     The initial state value to be assigned to the state upon machine setup.
+     @return
+     */
+    Class value();
+}

http://git-wip-us.apache.org/repos/asf/river-container/blob/3e29cd2d/river-hsm/src/main/java/org/apache/river/container/hsm/InvokeAndTransitionOperation.java
----------------------------------------------------------------------
diff --git a/river-hsm/src/main/java/org/apache/river/container/hsm/InvokeAndTransitionOperation.java b/river-hsm/src/main/java/org/apache/river/container/hsm/InvokeAndTransitionOperation.java
new file mode 100644
index 0000000..ad008f2
--- /dev/null
+++ b/river-hsm/src/main/java/org/apache/river/container/hsm/InvokeAndTransitionOperation.java
@@ -0,0 +1,80 @@
+/*
+ * 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.river.container.hsm;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ * State machine operation that invokes a method on the target instance
+ * and then queues a transition (or set of transitions).
+ */
+class InvokeAndTransitionOperation implements Operation {
+
+    private static final Logger log=
+            Logger.getLogger(InvokeAndTransitionOperation.class.getName(),MessageNames.BUNDLE_NAME);
+    
+    
+    Method targetMethod;
+
+    /**
+     * Create an instance that executes an event method that returns a value, but
+     * does not include any transitions.
+     * @param targetMetaState
+     * @param targetMethod 
+     */
+    public InvokeAndTransitionOperation(MetaState targetMetaState, Method targetMethod) {
+        this(targetMetaState, targetMethod, new TransitionOnSubstate[0]);
+    }
+    
+    public InvokeAndTransitionOperation(MetaState targetMetaState, Method targetMethod,  TransitionOnSubstate[] transitions) {
+        this.targetMethod = targetMethod;
+        this.targetMetaState = targetMetaState;
+        this.transitions = transitions;
+    }
+    MetaState targetMetaState;
+    TransitionOnSubstate[] transitions;
+    
+    @Override
+    public void eval(StateMachineExecutor exec, Object[] args) {
+        try {
+            if (log.isLoggable(Level.FINER)) {
+                log.log(Level.FINER, MessageNames.APPLYING_EVENT_TO_STATE,
+                        new Object[]{targetMethod.getName(),
+                            targetMetaState.stateClass.getSimpleName(),
+                            targetMetaState.stateInstance});
+            }
+            exec.output(targetMethod.invoke(targetMetaState.stateInstance, args));
+        } catch(InvocationTargetException e) {
+            exec.exception(targetMetaState, targetMethod, e.getCause());
+        } catch (Exception ex) {
+            log.log(Level.SEVERE, MessageNames.APPLYING_EVENT_TO_STATE,
+                    new Object[]{targetMethod.getName(),
+                            targetMetaState.stateClass.getSimpleName(),
+                            targetMetaState.stateInstance});
+            log.log(Level.SEVERE, MessageNames.ERROR_INVOKING_TARGET_METHOD, ex);
+        }
+        // Execute the transitions
+        for (TransitionOnSubstate t:transitions) {
+            exec.queueTransition(t);
+        }
+    }
+    
+}

http://git-wip-us.apache.org/repos/asf/river-container/blob/3e29cd2d/river-hsm/src/main/java/org/apache/river/container/hsm/InvokeGuardOperation.java
----------------------------------------------------------------------
diff --git a/river-hsm/src/main/java/org/apache/river/container/hsm/InvokeGuardOperation.java b/river-hsm/src/main/java/org/apache/river/container/hsm/InvokeGuardOperation.java
new file mode 100644
index 0000000..1eb7fc0
--- /dev/null
+++ b/river-hsm/src/main/java/org/apache/river/container/hsm/InvokeGuardOperation.java
@@ -0,0 +1,87 @@
+/*
+ * 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.river.container.hsm;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ * State machine operation that invokes a method on the target instance and then
+ * queues a transition (or set of transitions).
+ */
+class InvokeGuardOperation implements Operation {
+
+    private static final Logger log =
+            Logger.getLogger(InvokeGuardOperation.class.getName(), MessageNames.BUNDLE_NAME);
+    Method targetMethod;
+
+    /**
+     * Create an instance that executes an event method that returns a value,
+     * but does not include any transitions.
+     *
+     * @param targetMetaState
+     * @param targetMethod
+     */
+    public InvokeGuardOperation(MetaState targetMetaState, Method targetMethod) {
+        this(targetMetaState, targetMethod, new TransitionOnSubstate[0]);
+    }
+
+    public InvokeGuardOperation(MetaState targetMetaState, Method targetMethod, TransitionOnSubstate[] transitions) {
+        this.targetMethod = targetMethod;
+        this.targetMetaState = targetMetaState;
+        this.transitions = transitions;
+    }
+    MetaState targetMetaState;
+    TransitionOnSubstate[] transitions;
+
+    @Override
+    public void eval(StateMachineExecutor exec, Object[] args) {
+        try {
+            if (log.isLoggable(Level.FINER)) {
+                log.log(Level.FINER, MessageNames.RUNNING_GUARD_ON_STATE,
+                        new Object[]{targetMethod.getName(),
+                            targetMetaState.stateClass.getSimpleName(),
+                            targetMetaState.stateInstance});
+            }
+            Boolean b = (Boolean) targetMethod.invoke(targetMetaState.stateInstance, args);
+            if (b.booleanValue()) {
+                // Execute the transitions
+                if (log.isLoggable(Level.FINER)) {
+                    log.log(Level.FINER, MessageNames.RUNNING_GUARD_TRANSITIONS,
+                            new Object[]{targetMethod.getName(),
+                                targetMetaState.stateClass.getSimpleName(),
+                                targetMetaState.stateInstance});
+                }
+
+                for (TransitionOnSubstate t : transitions) {
+                    exec.queueTransition(t);
+                }
+            }
+        } catch (InvocationTargetException e) {
+            exec.exception(targetMetaState, targetMethod, e.getCause());
+        } catch (Exception ex) {
+            log.log(Level.SEVERE, MessageNames.RUNNING_GUARD_ON_STATE,
+                    new Object[]{targetMethod.getName(),
+                        targetMetaState.stateClass.getSimpleName(),
+                        targetMetaState.stateInstance});
+            log.log(Level.SEVERE, MessageNames.ERROR_INVOKING_TARGET_METHOD, ex);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/river-container/blob/3e29cd2d/river-hsm/src/main/java/org/apache/river/container/hsm/InvokeVoidAndTransitionOperation.java
----------------------------------------------------------------------
diff --git a/river-hsm/src/main/java/org/apache/river/container/hsm/InvokeVoidAndTransitionOperation.java b/river-hsm/src/main/java/org/apache/river/container/hsm/InvokeVoidAndTransitionOperation.java
new file mode 100644
index 0000000..5fc3e3f
--- /dev/null
+++ b/river-hsm/src/main/java/org/apache/river/container/hsm/InvokeVoidAndTransitionOperation.java
@@ -0,0 +1,80 @@
+/*
+ * 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.river.container.hsm;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ * State machine operation that invokes a method on the target instance
+ * and then queues a transition (or set of transitions).
+ */
+class InvokeVoidAndTransitionOperation implements Operation {
+
+    private static final Logger log=
+            Logger.getLogger(InvokeVoidAndTransitionOperation.class.getName(),MessageNames.BUNDLE_NAME);
+    
+    
+    Method targetMethod;
+
+    /**
+     * Create an instance that executes an event method that returns a value, but
+     * does not include any transitions.
+     * @param targetMetaState
+     * @param targetMethod 
+     */
+    public InvokeVoidAndTransitionOperation(MetaState targetMetaState, Method targetMethod) {
+        this(targetMetaState, targetMethod, new TransitionOnSubstate[0]);
+    }
+    
+    public InvokeVoidAndTransitionOperation(MetaState targetMetaState, Method targetMethod,  TransitionOnSubstate[] transitions) {
+        this.targetMethod = targetMethod;
+        this.targetMetaState = targetMetaState;
+        this.transitions = transitions;
+    }
+    MetaState targetMetaState;
+    TransitionOnSubstate[] transitions;
+    
+    @Override
+    public void eval(StateMachineExecutor exec, Object[] args) {
+        try {
+            if (log.isLoggable(Level.FINER)) {
+                log.log(Level.FINER, MessageNames.APPLYING_EVENT_TO_STATE,
+                        new Object[]{targetMethod.getName(),
+                            targetMetaState.stateClass.getSimpleName(),
+                            targetMetaState.stateInstance});
+            }
+            targetMethod.invoke(targetMetaState.stateInstance, args);
+        } catch(InvocationTargetException e) {
+            exec.exception(targetMetaState, targetMethod, e.getCause());
+        } catch (Exception ex) {
+            log.log(Level.SEVERE, MessageNames.APPLYING_EVENT_TO_STATE,
+                    new Object[]{targetMethod.getName(),
+                            targetMetaState.stateClass.getSimpleName(),
+                            targetMetaState.stateInstance});
+            log.log(Level.SEVERE, MessageNames.ERROR_INVOKING_TARGET_METHOD, ex);
+        }
+        // Execute the transitions
+        for (TransitionOnSubstate t:transitions) {
+            exec.queueTransition(t);
+        }
+    }
+    
+}

http://git-wip-us.apache.org/repos/asf/river-container/blob/3e29cd2d/river-hsm/src/main/java/org/apache/river/container/hsm/MessageNames.java
----------------------------------------------------------------------
diff --git a/river-hsm/src/main/java/org/apache/river/container/hsm/MessageNames.java b/river-hsm/src/main/java/org/apache/river/container/hsm/MessageNames.java
new file mode 100644
index 0000000..76114cc
--- /dev/null
+++ b/river-hsm/src/main/java/org/apache/river/container/hsm/MessageNames.java
@@ -0,0 +1,47 @@
+/*
+ * 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.river.container.hsm;
+
+/**
+ * Message names for the state machine implementation's logging.
+ */
+public class MessageNames {
+
+    public static final String BUNDLE_NAME = "org.apache.river.container.hsm.Messages";
+    public static final String APPLYING_EVENT_TO_STATE = "applyingEventToState",
+            BEGINNING_COMPILE="beginningCompile",
+            CANT_RESOLVE_TRANSITIONS_FOR_CLASS = "cantResolveTransitionsForClass",
+            COMPILE_COMPLETED="compileCompleted",
+            ENTRY_METHOD_ISNT_VOID = "entryMethodIsntVoid",
+            ERROR_APPLYING_TRANSITION="errorApplyingTransition",
+            ERROR_CREATING_PROXY="errorCreatingProxy",
+            ERROR_INCOMPATIBLE_OUTPUT="errorIncompatibleOutput",
+            ERROR_INSTANTIATING="errorInstantiating",
+            ERROR_INVOKING_TARGET_METHOD = "errorInvokingTargetMethod",
+            EXIT_METHOD_ISNT_VOID = "exitMethodIsntVoid",
+            GUARD_METHOD_DOESNT_RETURN_BOOLEAN = "guardMethodDoesntReturnBoolean",
+            METASTATE_WAS_INSTANTIATED="metaStateWasInstantiated",
+            MULTIPLE_EXCEPTIONS_THROWN="multipleExceptionsThrown",
+            NO_PARENT_INSTANCE="noParentInstance",
+            QUEUED_TRANSITION="queuedTransition",
+            RUNNING_GUARD_ON_STATE = "runningGuardOnState",
+            RUNNING_GUARD_TRANSITIONS="runningGuardTransitions",
+            SETTING_INITIAL_SUBSTATE="settingInitialSubstate",
+            SETTING_FIELD_TO="settingFieldTo",
+            STORING_EXCEPTION="storingException";
+}

http://git-wip-us.apache.org/repos/asf/river-container/blob/3e29cd2d/river-hsm/src/main/java/org/apache/river/container/hsm/MetaState.java
----------------------------------------------------------------------
diff --git a/river-hsm/src/main/java/org/apache/river/container/hsm/MetaState.java b/river-hsm/src/main/java/org/apache/river/container/hsm/MetaState.java
new file mode 100644
index 0000000..1c88137
--- /dev/null
+++ b/river-hsm/src/main/java/org/apache/river/container/hsm/MetaState.java
@@ -0,0 +1,106 @@
+/*
+ * 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.river.container.hsm;
+
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * An object that corresponds to a state instance.
+ */
+public class MetaState {
+    
+    Object stateInstance=null;
+    Class stateClass=null;
+    MetaState parent=null;
+    
+    public List<MetaState> getActiveMetaStates() {
+        List<MetaState> activeStates=new ArrayList<MetaState>();
+        getActiveMetaStates(activeStates);
+        return activeStates;
+    }
+    
+    public void getActiveMetaStates(List<MetaState> activeStates) {
+        /* Add my stateInstance's class. */
+        activeStates.add(this);
+        /* Iterate down for each substate. */
+        for(SubstateInfo substate: substates) {
+            substate.getActiveMetaState().getActiveMetaStates(activeStates);
+        }
+    }
+    
+    public List<Class> getActiveStates() {
+        List<MetaState> activeStates=getActiveMetaStates();
+        List<Class> activeStateClasses=new ArrayList(activeStates.size());
+        for(MetaState ms: activeStates) {
+            activeStateClasses.add(ms.stateClass);
+        }
+        return activeStateClasses;
+    }
+    List<SubstateInfo> substates=new ArrayList<SubstateInfo>();
+    
+    Map<Method, Operation> eventMethods=new HashMap<Method, Operation>();
+    
+    public void visitAll(MetaStateVisitor visitor) {
+        visitor.visit(this);
+        for (SubstateInfo substateInfo: substates) {
+            for (MetaState ms: substateInfo.getPossibleMetaStates()) {
+                ms.visitAll(visitor);
+            }
+        }
+    }
+    
+    List<Operation> guardMethods=new ArrayList<Operation>();
+
+    List<Operation> entryMethods=new ArrayList<Operation>();
+    
+    List<Operation> exitMethods=new ArrayList<Operation>();
+    
+    List<TransitionOnSubstate> entryTransitions=new ArrayList<TransitionOnSubstate>();
+    
+    public String toString() {
+        return stateClass==null?"Uninitialized metastate":"Meta-" + stateClass.getName();
+    }
+    
+    /**
+     * Return a string representation of the possible state structure.  Mainly for unit-testing.
+     * @return 
+     */
+    public String getStateStructure() {
+        StringBuilder sb=new StringBuilder();
+        sb.append(stateClass.getSimpleName());
+        if (substates.size() != 0) {
+            sb.append("(");
+            for (SubstateInfo si:substates) {
+                sb.append(si.getField().getName());
+                sb.append("(");
+                for (MetaState ms: si.getPossibleMetaStates()) {
+                    sb.append(ms.getStateStructure());
+                    sb.append(" ");
+                }
+                sb.append(") ");
+            }
+            sb.append(") ");
+        }
+        return sb.toString();
+    }
+}

http://git-wip-us.apache.org/repos/asf/river-container/blob/3e29cd2d/river-hsm/src/main/java/org/apache/river/container/hsm/MetaStateVisitor.java
----------------------------------------------------------------------
diff --git a/river-hsm/src/main/java/org/apache/river/container/hsm/MetaStateVisitor.java b/river-hsm/src/main/java/org/apache/river/container/hsm/MetaStateVisitor.java
new file mode 100644
index 0000000..cf90681
--- /dev/null
+++ b/river-hsm/src/main/java/org/apache/river/container/hsm/MetaStateVisitor.java
@@ -0,0 +1,26 @@
+/*
+ * 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.river.container.hsm;
+
+/**
+ *
+ * @author trasukg
+ */
+public interface MetaStateVisitor {
+    void visit(MetaState metaState);
+}

http://git-wip-us.apache.org/repos/asf/river-container/blob/3e29cd2d/river-hsm/src/main/java/org/apache/river/container/hsm/OnEntry.java
----------------------------------------------------------------------
diff --git a/river-hsm/src/main/java/org/apache/river/container/hsm/OnEntry.java b/river-hsm/src/main/java/org/apache/river/container/hsm/OnEntry.java
new file mode 100644
index 0000000..179b2fb
--- /dev/null
+++ b/river-hsm/src/main/java/org/apache/river/container/hsm/OnEntry.java
@@ -0,0 +1,39 @@
+/*
+ * 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.river.container.hsm;
+
+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;
+
+/**
+ Indicates that the annotated method should be invoked whenever the state is
+ entered.  There is no guarantee on the order of execution of @OnEntry methods,
+ only that the exit methods are invoked before the entry methods for the next
+ state.
+ * @author trasukg
+ */
+@Documented
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.METHOD)
+public @interface OnEntry {
+
+}

http://git-wip-us.apache.org/repos/asf/river-container/blob/3e29cd2d/river-hsm/src/main/java/org/apache/river/container/hsm/OnExit.java
----------------------------------------------------------------------
diff --git a/river-hsm/src/main/java/org/apache/river/container/hsm/OnExit.java b/river-hsm/src/main/java/org/apache/river/container/hsm/OnExit.java
new file mode 100644
index 0000000..7a3de76
--- /dev/null
+++ b/river-hsm/src/main/java/org/apache/river/container/hsm/OnExit.java
@@ -0,0 +1,39 @@
+/*
+ * 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.river.container.hsm;
+
+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;
+
+/**
+ Indicates that the annotated method should be invoked whenever the state is
+ exited.  There is no guarantee on the order of execution of @OnExit methods,
+ only that the exit methods are invoked before the entry methods for the next
+ state.
+ * @author trasukg
+ */
+@Documented
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.METHOD)
+public @interface OnExit {
+
+}

http://git-wip-us.apache.org/repos/asf/river-container/blob/3e29cd2d/river-hsm/src/main/java/org/apache/river/container/hsm/Operation.java
----------------------------------------------------------------------
diff --git a/river-hsm/src/main/java/org/apache/river/container/hsm/Operation.java b/river-hsm/src/main/java/org/apache/river/container/hsm/Operation.java
new file mode 100644
index 0000000..ece298e
--- /dev/null
+++ b/river-hsm/src/main/java/org/apache/river/container/hsm/Operation.java
@@ -0,0 +1,34 @@
+/*
+ * 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.river.container.hsm;
+
+/**
+ Interface for an object that evaluates "something" against a set of arguments.
+ * @author trasukg
+ */
+interface Operation {
+
+    /**
+     Run the operation against a set of arguments.
+     @param args
+     @return
+     */
+    void eval(StateMachineExecutor exec, Object[] args);
+
+}


Mime
View raw message