You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@river.apache.org by gt...@apache.org on 2013/01/16 00:48:46 UTC

svn commit: r1433744 - in /river/jtsk/skunk/surrogate: ./ nbproject/ src/org/apache/river/container/deployer/ src/org/apache/river/container/hsm/ test/org/apache/river/container/hsm/ testfiles/ testfiles/testroot/

Author: gtrasuk
Date: Tue Jan 15 23:48:46 2013
New Revision: 1433744

URL: http://svn.apache.org/viewvc?rev=1433744&view=rev
Log:
New hierarchical state machine implementation complete and working.  Ready to implement application deployment controller.

Added:
    river/jtsk/skunk/surrogate/src/org/apache/river/container/hsm/StateMachineInfo.java
    river/jtsk/skunk/surrogate/testfiles/testroot/test.log
Removed:
    river/jtsk/skunk/surrogate/src/org/apache/river/container/hsm/ClassInfo.java
    river/jtsk/skunk/surrogate/src/org/apache/river/container/hsm/Evaluator.java
    river/jtsk/skunk/surrogate/src/org/apache/river/container/hsm/InvokeAndTransitionEvaluator.java
    river/jtsk/skunk/surrogate/src/org/apache/river/container/hsm/InvokeEvaluator.java
    river/jtsk/skunk/surrogate/src/org/apache/river/container/hsm/InvokeVoidAndTransitionEvaluator.java
    river/jtsk/skunk/surrogate/src/org/apache/river/container/hsm/InvokeVoidEvaluator.java
    river/jtsk/skunk/surrogate/src/org/apache/river/container/hsm/ListEvaluator.java
    river/jtsk/skunk/surrogate/src/org/apache/river/container/hsm/NopEvaluator.java
    river/jtsk/skunk/surrogate/src/org/apache/river/container/hsm/SetFieldEvaluator.java
    river/jtsk/skunk/surrogate/src/org/apache/river/container/hsm/StateEventEvaluator.java
    river/jtsk/skunk/surrogate/src/org/apache/river/container/hsm/StateMachine.java
    river/jtsk/skunk/surrogate/src/org/apache/river/container/hsm/StateMachineFactory.java
    river/jtsk/skunk/surrogate/src/org/apache/river/container/hsm/StateMachineImpl.java
    river/jtsk/skunk/surrogate/src/org/apache/river/container/hsm/StateMachineInvocationHandler.java
    river/jtsk/skunk/surrogate/test/org/apache/river/container/hsm/SimpleMachineTest.java
Modified:
    river/jtsk/skunk/surrogate/README
    river/jtsk/skunk/surrogate/nbproject/project.properties
    river/jtsk/skunk/surrogate/src/org/apache/river/container/deployer/StarterServiceLifeCycleSM.java
    river/jtsk/skunk/surrogate/src/org/apache/river/container/hsm/InvokeAndTransitionOperation.java
    river/jtsk/skunk/surrogate/src/org/apache/river/container/hsm/InvokeGuardOperation.java
    river/jtsk/skunk/surrogate/src/org/apache/river/container/hsm/InvokeVoidAndTransitionOperation.java
    river/jtsk/skunk/surrogate/src/org/apache/river/container/hsm/MessageNames.java
    river/jtsk/skunk/surrogate/src/org/apache/river/container/hsm/Messages.properties
    river/jtsk/skunk/surrogate/src/org/apache/river/container/hsm/MetaState.java
    river/jtsk/skunk/surrogate/src/org/apache/river/container/hsm/PlainStateMachineExecutor.java
    river/jtsk/skunk/surrogate/src/org/apache/river/container/hsm/StateMachineCompiler.java
    river/jtsk/skunk/surrogate/src/org/apache/river/container/hsm/StateMachineExecutor.java
    river/jtsk/skunk/surrogate/test/org/apache/river/container/hsm/InitializedMachineTest.java
    river/jtsk/skunk/surrogate/test/org/apache/river/container/hsm/PlainMachineExecutorTest.java
    river/jtsk/skunk/surrogate/test/org/apache/river/container/hsm/StateMachineCompilerTest.java
    river/jtsk/skunk/surrogate/test/org/apache/river/container/hsm/TestSM.java
    river/jtsk/skunk/surrogate/testfiles/logging.properties

Modified: river/jtsk/skunk/surrogate/README
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/surrogate/README?rev=1433744&r1=1433743&r2=1433744&view=diff
==============================================================================
--- river/jtsk/skunk/surrogate/README (original)
+++ river/jtsk/skunk/surrogate/README Tue Jan 15 23:48:46 2013
@@ -45,3 +45,6 @@ the tool to a convenient location, then 
 The configuration file schema is bound using JAXB.  It may be necessary to ensure
 that Netbeans has the JAXB libraries defined.
 
+Also, once you load the project, check on the runtime setup for the "working directory" in 
+the Project Properties --> Run panel.  It should be set to "build/testroot", but may not 
+carry over to the runtime environment properly through version control.

Modified: river/jtsk/skunk/surrogate/nbproject/project.properties
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/surrogate/nbproject/project.properties?rev=1433744&r1=1433743&r2=1433744&view=diff
==============================================================================
--- river/jtsk/skunk/surrogate/nbproject/project.properties (original)
+++ river/jtsk/skunk/surrogate/nbproject/project.properties Tue Jan 15 23:48:46 2013
@@ -1,98 +1,98 @@
-annotation.processing.enabled=true
-annotation.processing.enabled.in.editor=false
-annotation.processing.processors.list=
-annotation.processing.run.all.processors=true
-annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
-application.title=surrogate
-application.vendor=trasukg
-build.classes.dir=${build.dir}/classes
-build.classes.excludes=**/*.java,**/*.form
-# This directory is removed when the project is cleaned:
-build.dir=build
-build.generated.dir=${build.dir}/generated
-build.generated.sources.dir=${build.dir}/generated-sources
-# Only compile against the classpath explicitly listed here:
-build.sysclasspath=ignore
-build.test.classes.dir=${build.dir}/test/classes
-build.test.results.dir=${build.dir}/test/results
-# Uncomment to specify the preferred debugger connection transport:
-#debug.transport=dt_socket
-debug.classpath=\
-    ${run.classpath}
-debug.test.classpath=\
-    ${run.test.classpath}
-# This directory is removed when the project is cleaned:
-dist.dir=dist
-dist.jar=${dist.dir}/RiverSurrogate.jar
-dist.javadoc.dir=${dist.dir}/javadoc
-endorsed.classpath=
-#endorsed.classpath=\
-#    ${libs.JAXB-ENDORSED.classpath}
-excludes=
-includes=**
-jar.archive.disabled=${jnlp.enabled}
-jar.compress=false
-jar.index=${jnlp.enabled}
-javac.classpath=\
-    ${libs.ApacheCommonsLogging-1_1_1.classpath}:\
-    ${libs.ApacheCommonsVFS-1_0.classpath}:\
-    ${libs.ApacheRiverLib.classpath}:\
-    ${libs.ApacheRiverServices.classpath}:\
-    ${libs.ApacheRiverPlatform.classpath}
-# Space-separated list of extra javac options
-javac.compilerargs=
-javac.deprecation=false
-javac.processorpath=\
-    ${javac.classpath}:\
-    ${libs.JavaCC.classpath}:\
-    ${libs.jaxb.classpath}
-javac.source=1.6
-javac.target=1.6
-javac.test.classpath=\
-    ${javac.classpath}:\
-    ${build.classes.dir}:\
-    ${libs.junit_4.classpath}
-javac.test.processorpath=\
-    ${javac.test.classpath}
-javadoc.additionalparam=
-javadoc.author=false
-javadoc.encoding=${source.encoding}
-javadoc.noindex=false
-javadoc.nonavbar=false
-javadoc.notree=false
-javadoc.private=false
-javadoc.splitindex=true
-javadoc.use=true
-javadoc.version=false
-javadoc.windowtitle=
-jaxbwiz.gensrc.classpath=${libs.jaxb.classpath}
-jaxbwiz.xjcdef.classpath=${libs.jaxb.classpath}
-jaxbwiz.xjcrun.classpath=${libs.jaxb.classpath}
-jnlp.codebase.type=web
-jnlp.codebase.url=$$$$codebase
-jnlp.descriptor=application
-jnlp.enabled=false
-jnlp.mixed.code=default
-jnlp.offline-allowed=false
-jnlp.signed=false
-jnlp.signing=
-jnlp.signing.alias=
-jnlp.signing.keystore=
-main.class=org.apache.river.container.Bootstrap
-manifest.file=manifest.mf
-meta.inf.dir=${src.dir}/META-INF
-mkdist.disabled=false
-platform.active=default_platform
-run.classpath=\
-    ${build.classes.dir}:\
-    ${javac.classpath}
-# Space-separated list of JVM arguments used when running the project
-# (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value
-# or test-sys-prop.name=value to set system properties for unit tests):
-run.jvmargs=-classpath lib/RiverSurrogate.jar -Djava.util.logging.config.file=../../testfiles/logging.properties
-run.test.classpath=\
-    ${javac.test.classpath}:\
-    ${build.test.classes.dir}
-source.encoding=UTF-8
-src.dir=src
-test.src.dir=test
+annotation.processing.enabled=true
+annotation.processing.enabled.in.editor=false
+annotation.processing.processors.list=
+annotation.processing.run.all.processors=true
+annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
+application.title=surrogate
+application.vendor=trasukg
+build.classes.dir=${build.dir}/classes
+build.classes.excludes=**/*.java,**/*.form
+# This directory is removed when the project is cleaned:
+build.dir=build
+build.generated.dir=${build.dir}/generated
+build.generated.sources.dir=${build.dir}/generated-sources
+# Only compile against the classpath explicitly listed here:
+build.sysclasspath=ignore
+build.test.classes.dir=${build.dir}/test/classes
+build.test.results.dir=${build.dir}/test/results
+# Uncomment to specify the preferred debugger connection transport:
+#debug.transport=dt_socket
+debug.classpath=\
+    ${run.classpath}
+debug.test.classpath=\
+    ${run.test.classpath}
+# This directory is removed when the project is cleaned:
+dist.dir=dist
+dist.jar=${dist.dir}/RiverSurrogate.jar
+dist.javadoc.dir=${dist.dir}/javadoc
+endorsed.classpath=
+#endorsed.classpath=\
+#    ${libs.JAXB-ENDORSED.classpath}
+excludes=
+includes=**
+jar.archive.disabled=${jnlp.enabled}
+jar.compress=false
+jar.index=${jnlp.enabled}
+javac.classpath=\
+    ${libs.ApacheCommonsLogging-1_1_1.classpath}:\
+    ${libs.ApacheCommonsVFS-1_0.classpath}:\
+    ${libs.ApacheRiverLib.classpath}:\
+    ${libs.ApacheRiverServices.classpath}:\
+    ${libs.ApacheRiverPlatform.classpath}
+# Space-separated list of extra javac options
+javac.compilerargs=
+javac.deprecation=false
+javac.processorpath=\
+    ${javac.classpath}:\
+    ${libs.JavaCC.classpath}:\
+    ${libs.jaxb.classpath}
+javac.source=1.6
+javac.target=1.6
+javac.test.classpath=\
+    ${javac.classpath}:\
+    ${build.classes.dir}:\
+    ${libs.junit_4.classpath}
+javac.test.processorpath=\
+    ${javac.test.classpath}
+javadoc.additionalparam=
+javadoc.author=false
+javadoc.encoding=${source.encoding}
+javadoc.noindex=false
+javadoc.nonavbar=false
+javadoc.notree=false
+javadoc.private=false
+javadoc.splitindex=true
+javadoc.use=true
+javadoc.version=false
+javadoc.windowtitle=
+jaxbwiz.gensrc.classpath=${libs.jaxb.classpath}
+jaxbwiz.xjcdef.classpath=${libs.jaxb.classpath}
+jaxbwiz.xjcrun.classpath=${libs.jaxb.classpath}
+jnlp.codebase.type=web
+jnlp.codebase.url=$$$$codebase
+jnlp.descriptor=application
+jnlp.enabled=false
+jnlp.mixed.code=default
+jnlp.offline-allowed=false
+jnlp.signed=false
+jnlp.signing=
+jnlp.signing.alias=
+jnlp.signing.keystore=
+main.class=org.apache.river.container.Bootstrap
+manifest.file=manifest.mf
+meta.inf.dir=${src.dir}/META-INF
+mkdist.disabled=false
+platform.active=default_platform
+run.classpath=\
+    ${build.classes.dir}:\
+    ${javac.classpath}
+# Space-separated list of JVM arguments used when running the project
+# (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value
+# or test-sys-prop.name=value to set system properties for unit tests):
+run.jvmargs=-classpath lib/RiverSurrogate.jar -Djava.util.logging.config.file=../../testfiles/logging.properties
+run.test.classpath=\
+    ${javac.test.classpath}:\
+    ${build.test.classes.dir}
+source.encoding=UTF-8
+src.dir=src
+test.src.dir=test

Modified: river/jtsk/skunk/surrogate/src/org/apache/river/container/deployer/StarterServiceLifeCycleSM.java
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/surrogate/src/org/apache/river/container/deployer/StarterServiceLifeCycleSM.java?rev=1433744&r1=1433743&r2=1433744&view=diff
==============================================================================
--- river/jtsk/skunk/surrogate/src/org/apache/river/container/deployer/StarterServiceLifeCycleSM.java (original)
+++ river/jtsk/skunk/surrogate/src/org/apache/river/container/deployer/StarterServiceLifeCycleSM.java Tue Jan 15 23:48:46 2013
@@ -23,7 +23,7 @@ import org.apache.river.container.hsm.Co
 import org.apache.river.container.hsm.Initial;
 import org.apache.river.container.hsm.RootState;
 import org.apache.river.container.hsm.State;
-import org.apache.river.container.hsm.StateMachine;
+import org.apache.river.container.hsm.StateMachineInfo;
 
 /**
  * Life cycle controller for "service-starter" services.
@@ -49,7 +49,7 @@ public class StarterServiceLifeCycleSM i
     private Object state;
     
     @Controller
-    private StateMachine controller;
+    private StateMachineInfo controller;
 
     @Override
     public void start() {

Modified: river/jtsk/skunk/surrogate/src/org/apache/river/container/hsm/InvokeAndTransitionOperation.java
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/surrogate/src/org/apache/river/container/hsm/InvokeAndTransitionOperation.java?rev=1433744&r1=1433743&r2=1433744&view=diff
==============================================================================
--- river/jtsk/skunk/surrogate/src/org/apache/river/container/hsm/InvokeAndTransitionOperation.java (original)
+++ river/jtsk/skunk/surrogate/src/org/apache/river/container/hsm/InvokeAndTransitionOperation.java Tue Jan 15 23:48:46 2013
@@ -63,7 +63,7 @@ public class InvokeAndTransitionOperatio
             }
             exec.output(targetMethod.invoke(targetMetaState.stateInstance, args));
         } catch(InvocationTargetException e) {
-            exec.exception(e.getCause());
+            exec.exception(targetMetaState, targetMethod, e.getCause());
         } catch (Exception ex) {
             log.log(Level.SEVERE, MessageNames.APPLYING_EVENT_TO_STATE,
                     new Object[]{targetMethod.getName(),

Modified: river/jtsk/skunk/surrogate/src/org/apache/river/container/hsm/InvokeGuardOperation.java
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/surrogate/src/org/apache/river/container/hsm/InvokeGuardOperation.java?rev=1433744&r1=1433743&r2=1433744&view=diff
==============================================================================
--- river/jtsk/skunk/surrogate/src/org/apache/river/container/hsm/InvokeGuardOperation.java (original)
+++ river/jtsk/skunk/surrogate/src/org/apache/river/container/hsm/InvokeGuardOperation.java Tue Jan 15 23:48:46 2013
@@ -63,12 +63,19 @@ public class InvokeGuardOperation implem
             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(e.getCause());
+            exec.exception(targetMetaState, targetMethod, e.getCause());
         } catch (Exception ex) {
             log.log(Level.SEVERE, MessageNames.RUNNING_GUARD_ON_STATE,
                     new Object[]{targetMethod.getName(),
@@ -76,9 +83,5 @@ public class InvokeGuardOperation implem
                         targetMetaState.stateInstance});
             log.log(Level.SEVERE, MessageNames.ERROR_INVOKING_TARGET_METHOD, ex);
         }
-        // Execute the transitions
-        for (TransitionOnSubstate t : transitions) {
-            exec.queueTransition(t);
-        }
     }
 }

Modified: river/jtsk/skunk/surrogate/src/org/apache/river/container/hsm/InvokeVoidAndTransitionOperation.java
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/surrogate/src/org/apache/river/container/hsm/InvokeVoidAndTransitionOperation.java?rev=1433744&r1=1433743&r2=1433744&view=diff
==============================================================================
--- river/jtsk/skunk/surrogate/src/org/apache/river/container/hsm/InvokeVoidAndTransitionOperation.java (original)
+++ river/jtsk/skunk/surrogate/src/org/apache/river/container/hsm/InvokeVoidAndTransitionOperation.java Tue Jan 15 23:48:46 2013
@@ -63,7 +63,7 @@ public class InvokeVoidAndTransitionOper
             }
             targetMethod.invoke(targetMetaState.stateInstance, args);
         } catch(InvocationTargetException e) {
-            exec.exception(e.getCause());
+            exec.exception(targetMetaState, targetMethod, e.getCause());
         } catch (Exception ex) {
             log.log(Level.SEVERE, MessageNames.APPLYING_EVENT_TO_STATE,
                     new Object[]{targetMethod.getName(),

Modified: river/jtsk/skunk/surrogate/src/org/apache/river/container/hsm/MessageNames.java
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/surrogate/src/org/apache/river/container/hsm/MessageNames.java?rev=1433744&r1=1433743&r2=1433744&view=diff
==============================================================================
--- river/jtsk/skunk/surrogate/src/org/apache/river/container/hsm/MessageNames.java (original)
+++ river/jtsk/skunk/surrogate/src/org/apache/river/container/hsm/MessageNames.java Tue Jan 15 23:48:46 2013
@@ -24,7 +24,9 @@ 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",
@@ -32,8 +34,13 @@ public class MessageNames {
             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",
-            SETTING_INITIAL_SUBSTATE="settingInitialSubstate";
+            RUNNING_GUARD_TRANSITIONS="runningGuardTransitions",
+            SETTING_INITIAL_SUBSTATE="settingInitialSubstate",
+            SETTING_FIELD_TO="settingFieldTo",
+            STORING_EXCEPTION="storingException";
 }

Modified: river/jtsk/skunk/surrogate/src/org/apache/river/container/hsm/Messages.properties
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/surrogate/src/org/apache/river/container/hsm/Messages.properties?rev=1433744&r1=1433743&r2=1433744&view=diff
==============================================================================
--- river/jtsk/skunk/surrogate/src/org/apache/river/container/hsm/Messages.properties (original)
+++ river/jtsk/skunk/surrogate/src/org/apache/river/container/hsm/Messages.properties Tue Jan 15 23:48:46 2013
@@ -17,15 +17,22 @@
  */
 
 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.
+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}.

Modified: river/jtsk/skunk/surrogate/src/org/apache/river/container/hsm/MetaState.java
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/surrogate/src/org/apache/river/container/hsm/MetaState.java?rev=1433744&r1=1433743&r2=1433744&view=diff
==============================================================================
--- river/jtsk/skunk/surrogate/src/org/apache/river/container/hsm/MetaState.java (original)
+++ river/jtsk/skunk/surrogate/src/org/apache/river/container/hsm/MetaState.java Tue Jan 15 23:48:46 2013
@@ -27,34 +27,35 @@ import java.util.Map;
 /**
  * An object that corresponds to a state instance.
  */
-public class MetaState implements StateMachine {
+public class MetaState {
     
     Object stateInstance=null;
     Class stateClass=null;
     MetaState parent=null;
     
-    /** This definition will disappear when we banish the transition() method. */
-    @Override
-    public void transition(Class targetState) {
-        throw new UnsupportedOperationException("Not supported yet.");
-    }
-
-    @Override
-    public List<Class> getActiveStates() throws IllegalArgumentException, IllegalAccessException {
-        List<Class> activeStates=new ArrayList<Class>();
-        getActiveStates(activeStates);
+    public List<MetaState> getActiveMetaStates() {
+        List<MetaState> activeStates=new ArrayList<MetaState>();
+        getActiveMetaStates(activeStates);
         return activeStates;
     }
     
-    public void getActiveStates(List<Class> activeStates) {
+    public void getActiveMetaStates(List<MetaState> activeStates) {
         /* Add my stateInstance's class. */
-        activeStates.add(stateClass);
+        activeStates.add(this);
         /* Iterate down for each substate. */
         for(SubstateInfo substate: substates) {
-            substate.getActiveMetaState().getActiveStates(activeStates);
+            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>();
@@ -63,7 +64,7 @@ public class MetaState implements StateM
         visitor.visit(this);
         for (SubstateInfo substateInfo: substates) {
             for (MetaState ms: substateInfo.getPossibleMetaStates()) {
-                visitor.visit(ms);
+                ms.visitAll(visitor);
             }
         }
     }
@@ -75,4 +76,31 @@ public class MetaState implements StateM
     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();
+    }
 }

Modified: river/jtsk/skunk/surrogate/src/org/apache/river/container/hsm/PlainStateMachineExecutor.java
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/surrogate/src/org/apache/river/container/hsm/PlainStateMachineExecutor.java?rev=1433744&r1=1433743&r2=1433744&view=diff
==============================================================================
--- river/jtsk/skunk/surrogate/src/org/apache/river/container/hsm/PlainStateMachineExecutor.java (original)
+++ river/jtsk/skunk/surrogate/src/org/apache/river/container/hsm/PlainStateMachineExecutor.java Tue Jan 15 23:48:46 2013
@@ -25,13 +25,14 @@ import java.lang.reflect.Method;
 import java.lang.reflect.Proxy;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.logging.Level;
 import java.util.logging.Logger;
 
 /**
  *
  */
-public class PlainStateMachineExecutor implements StateMachineExecutor {
-    
+public class PlainStateMachineExecutor implements StateMachineExecutor, StateMachineInfo {
+
     private static final Logger log =
             Logger.getLogger(PlainStateMachineExecutor.class.getName(),
             MessageNames.BUNDLE_NAME);
@@ -56,6 +57,26 @@ public class PlainStateMachineExecutor i
     }
 
     /**
+     * Convenience method to compile a state machine and instantiate it.
+     *
+     * @param rootStateClass
+     * @return
+     */
+    public static Object createProxy(Object rootStateInstance) {
+        StateMachineCompiler compiler = new StateMachineCompiler();
+        try {
+            MetaState rootState = compiler.compile(rootStateInstance.getClass());
+            rootState.stateInstance=rootStateInstance;
+            instantiate(rootState);
+            return createProxy(rootState);
+        } catch (StateMachineException ex) {
+            throw ex;
+        } catch (Exception ex) {
+            throw new StateMachineException(ex, MessageNames.BUNDLE_NAME, MessageNames.ERROR_CREATING_PROXY);
+        }
+    }
+
+    /**
      * Create a fully-instantiated metastate from a compiled metastate.
      *
      * @param rootState
@@ -66,6 +87,9 @@ public class PlainStateMachineExecutor i
             @Override
             public void visit(MetaState metaState) {
                 try {
+                    if (metaState.stateInstance!=null) {
+                        return;
+                    }
                     /*
                      * Goal here is to create a stateInstance for each metastate.
                      * In the simple case, the stateClass is a root class, and we can
@@ -78,10 +102,11 @@ public class PlainStateMachineExecutor i
                          * That should be the stateInstance of a parent state.
                          */
                         Object parentInstance = findAParentInstance(metaState, metaState.stateClass.getEnclosingClass());
-                        
+
                         Constructor con = metaState.stateClass.getConstructor(parentInstance.getClass());
                         metaState.stateInstance = con.newInstance(parentInstance);
                     }
+                    log.log(Level.FINE, MessageNames.METASTATE_WAS_INSTANTIATED, new Object[]{metaState.stateClass, metaState.stateInstance});
                 } catch (Exception ex) {
                     throw new StateMachineException(ex, MessageNames.BUNDLE_NAME, MessageNames.ERROR_INSTANTIATING);
                 }
@@ -93,9 +118,8 @@ public class PlainStateMachineExecutor i
             public void visit(MetaState metaState) {
                 try {
                     for (SubstateInfo ssi : metaState.substates) {
-                        System.out.println("Setting field " + ssi.getField().getName() + " on "
-                                + metaState.stateClass);
-                        System.out.println("metastate's instance is " + metaState.stateInstance + ", substate value is " + ssi.getInitialMetaState().stateInstance);
+                        log.log(Level.FINE, MessageNames.SETTING_FIELD_TO, new Object[]{ssi.getField().getName(), metaState.stateInstance, ssi.getInitialMetaState().stateInstance});
+
                         ssi.getField().set(metaState.stateInstance, ssi.getInitialMetaState().stateInstance);
                     }
                 } catch (Exception ex) {
@@ -104,7 +128,7 @@ public class PlainStateMachineExecutor i
             }
         });
     }
-    
+
     private static Object findAParentInstance(MetaState metaState, Class enclosingClass) {
         for (MetaState currentState = metaState.parent; currentState != null; currentState = currentState.parent) {
             if (currentState.stateClass == enclosingClass) {
@@ -114,11 +138,12 @@ public class PlainStateMachineExecutor i
         throw new StateMachineException(MessageNames.BUNDLE_NAME, MessageNames.NO_PARENT_INSTANCE,
                 new Object[]{enclosingClass, metaState.stateInstance});
     }
-    
+
     public static Object createProxy(MetaState instantiatedMetaState) {
         RootState rootStateAnnotation = (RootState) instantiatedMetaState.stateClass.getAnnotation(RootState.class);
         Class eventInterface = rootStateAnnotation.value();
         PlainStateMachineExecutor executor = new PlainStateMachineExecutor(instantiatedMetaState);
+        executor.activate();
         Object proxy =
                 Proxy.newProxyInstance(eventInterface.getClassLoader(),
                 new Class[]{eventInterface},
@@ -126,7 +151,7 @@ public class PlainStateMachineExecutor i
         return proxy;
     }
     InvocationHandler invocationHandler = null;
-    
+
     public InvocationHandler getInvocationHandler() {
         if (invocationHandler == null) {
             invocationHandler = new InvocationHandler() {
@@ -138,14 +163,19 @@ public class PlainStateMachineExecutor i
         }
         return invocationHandler;
     }
-    
+
     PlainStateMachineExecutor(MetaState instantiatedMetaState) {
         this.rootMetaState = instantiatedMetaState;
         fillInControllerReferences();
         fillInRootStateReferences();
     }
     MetaState rootMetaState = null;
-    
+
+    private void activate() {
+        List<MetaState> initialStates = buildActiveStates();
+        runEntryMethods(initialStates);
+    }
+
     private synchronized Object runEvent(Method eventMethod, Object[] args)
             throws Throwable {
         clearOutput();
@@ -169,28 +199,25 @@ public class PlainStateMachineExecutor i
         }
         return null;
     }
-    
-    private void fillInControllerReferences(MetaState metaState) {
-    }
     Object output = null;
-    
+
     private void clearOutput() {
         output = null;
     }
-    
+
     private Object buildOutputValue(Class returnType) {
         return output;
     }
     List<Throwable> exceptions = new ArrayList<Throwable>();
-    
+
     private void clearExceptions() {
         exceptions.clear();
     }
-    
+
     private boolean hasExceptions() {
         return !exceptions.isEmpty();
     }
-    
+
     private Throwable buildOutputException() {
         if (exceptions.size() == 1) {
             return exceptions.get(0);
@@ -200,37 +227,34 @@ public class PlainStateMachineExecutor i
         }
     }
     List<TransitionOnSubstate> queuedTransitions = new ArrayList<TransitionOnSubstate>();
-    
+
     private void clearTransitions() {
         queuedTransitions.clear();
     }
-    
+
     @Override
     public void queueTransition(TransitionOnSubstate t) {
+        log.log(Level.FINER, MessageNames.QUEUED_TRANSITION,
+                new Object[]{t.targetMetaState.stateClass.getSimpleName(),
+                    t.targetMetaState.parent.stateClass.getSimpleName()});
         queuedTransitions.add(t);
     }
-    
+
     @Override
     public void output(Object outputObject) {
         output = outputObject;
     }
-    
+
     @Override
-    public void exception(Throwable cause) {
+    public void exception(MetaState metaState, Method interfaceMethod, Throwable cause) {
+        log.log(Level.FINE, MessageNames.STORING_EXCEPTION, new Object[]{metaState.stateInstance, interfaceMethod.getName(), cause.toString()});
         exceptions.add(cause);
     }
-    
+
     private List<MetaState> buildActiveStates() {
-        final List<MetaState> activeStates = new ArrayList<MetaState>();
-        rootMetaState.visitAll(new MetaStateVisitor() {
-            @Override
-            public void visit(MetaState metaState) {
-                activeStates.add(metaState);
-            }
-        });
-        return activeStates;
+        return rootMetaState.getActiveMetaStates();
     }
-    
+
     private void runEventActions(List<MetaState> activeStates, Method eventInterfaceMethod, Object[] args) {
         for (MetaState ms : activeStates) {
             Operation op = ms.eventMethods.get(eventInterfaceMethod);
@@ -239,7 +263,7 @@ public class PlainStateMachineExecutor i
             }
         }
     }
-    
+
     private void runGuardMethods(List<MetaState> activeStates) {
         for (MetaState ms : activeStates) {
             for (Operation op : ms.guardMethods) {
@@ -247,7 +271,7 @@ public class PlainStateMachineExecutor i
             }
         }
     }
-    
+
     private void runExitMethods(List<MetaState> exitingStates) {
         for (MetaState ms : exitingStates) {
             for (Operation op : ms.exitMethods) {
@@ -255,7 +279,7 @@ public class PlainStateMachineExecutor i
             }
         }
     }
-    
+
     private void runEntryMethods(List<MetaState> enteringStates) {
         for (MetaState ms : enteringStates) {
             for (Operation op : ms.entryMethods) {
@@ -263,9 +287,9 @@ public class PlainStateMachineExecutor i
             }
         }
     }
-    
+
     private void applyTransitions(List<MetaState> activeStates) {
-        
+
         while (!queuedTransitions.isEmpty()) {
             /* Pull a transition. */
             TransitionOnSubstate tos = queuedTransitions.remove(queuedTransitions.size() - 1);
@@ -278,7 +302,7 @@ public class PlainStateMachineExecutor i
             }
         }
     }
-    
+
     private void applyTransition(TransitionOnSubstate tos) {
         try {
             tos.substate.setActiveMetaState(tos.targetMetaState);
@@ -288,7 +312,7 @@ public class PlainStateMachineExecutor i
                     new Object[]{ex.getMessage()});
         }
     }
-    
+
     private void calculateStateDelta(List<MetaState> initialStates, List<MetaState> finalStates, List<MetaState> exiting, List<MetaState> entering) {
         for (MetaState initialState : initialStates) {
             if (!finalStates.contains(initialState)) {
@@ -301,33 +325,34 @@ public class PlainStateMachineExecutor i
             }
         }
     }
-    
+
     private void fillInControllerReferences() {
         rootMetaState.visitAll(new MetaStateVisitor() {
             @Override
             public void visit(MetaState metaState) {
+                log.fine("Visiting " + metaState + " to fill in controller reference.");
                 fillInReferenceFields(metaState, Controller.class, PlainStateMachineExecutor.this);
             }
         });
     }
-    
+
     private void fillInRootStateReferences() {
         rootMetaState.visitAll(new MetaStateVisitor() {
             @Override
             public void visit(MetaState metaState) {
-                System.out.println("Visiting " + metaState + " to fill in root state reference.");
+                log.fine("Visiting " + metaState + " to fill in root state reference.");
                 fillInReferenceFields(metaState, RootState.class, rootMetaState.stateInstance);
             }
         });
     }
-    
+
     private void fillInReferenceFields(MetaState metaState, Class<? extends Annotation> aClass, Object value) {
 
         for (Field f : metaState.stateClass.getFields()) {
-            
+
             if (f.getAnnotation(aClass) != null) {
                 try {
-                    System.out.println("Setting field " + metaState.stateInstance + "." + f.getName()
+                    log.fine("Setting field " + metaState.stateInstance + "." + f.getName()
                             + " to " + value);
                     boolean accessible = f.isAccessible();
                     f.setAccessible(true);
@@ -336,9 +361,14 @@ public class PlainStateMachineExecutor i
                 } catch (Exception ex) {
                     throw new StateMachineException(MessageNames.BUNDLE_NAME,
                             MessageNames.ERROR_INSTANTIATING, new Object[]{ex.getMessage()});
-                    
+
                 }
             }
         }
     }
+
+    @Override
+    public List<Class> getActiveStates() {
+        return rootMetaState.getActiveStates();
+    }
 }

Modified: river/jtsk/skunk/surrogate/src/org/apache/river/container/hsm/StateMachineCompiler.java
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/surrogate/src/org/apache/river/container/hsm/StateMachineCompiler.java?rev=1433744&r1=1433743&r2=1433744&view=diff
==============================================================================
--- river/jtsk/skunk/surrogate/src/org/apache/river/container/hsm/StateMachineCompiler.java (original)
+++ river/jtsk/skunk/surrogate/src/org/apache/river/container/hsm/StateMachineCompiler.java Tue Jan 15 23:48:46 2013
@@ -36,6 +36,9 @@ import org.apache.river.container.Utils;
  */
 public class StateMachineCompiler {
 
+    private static final Logger log=
+            Logger.getLogger(StateMachineCompiler.class.getName(),MessageNames.BUNDLE_NAME);
+    
     Class eventInterface = null;
 
     /**
@@ -49,6 +52,7 @@ public class StateMachineCompiler {
     }
 
     public MetaState compile(Class rootStateClass) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException {
+        log.log(Level.FINE, MessageNames.BEGINNING_COMPILE, new Object[] {rootStateClass.getName()});
         findEventInterface(rootStateClass);
         // First pass: create all metastates
         MetaState rootMetaState = createMetaState(rootStateClass);
@@ -66,6 +70,7 @@ public class StateMachineCompiler {
                 }
             }
         });
+        log.log(Level.FINE, MessageNames.COMPILE_COMPLETED, new Object[] {rootStateClass.getName()});
         return rootMetaState;
     }
 

Modified: river/jtsk/skunk/surrogate/src/org/apache/river/container/hsm/StateMachineExecutor.java
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/surrogate/src/org/apache/river/container/hsm/StateMachineExecutor.java?rev=1433744&r1=1433743&r2=1433744&view=diff
==============================================================================
--- river/jtsk/skunk/surrogate/src/org/apache/river/container/hsm/StateMachineExecutor.java (original)
+++ river/jtsk/skunk/surrogate/src/org/apache/river/container/hsm/StateMachineExecutor.java Tue Jan 15 23:48:46 2013
@@ -18,6 +18,8 @@
 
 package org.apache.river.container.hsm;
 
+import java.lang.reflect.Method;
+
 /**
  *
  */
@@ -33,6 +35,6 @@ public interface StateMachineExecutor {
 
     void output(Object outputObject);
 
-    void exception(Throwable cause);
+    void exception(MetaState metaState, Method interfaceEvent, Throwable cause);
 
 }

Added: river/jtsk/skunk/surrogate/src/org/apache/river/container/hsm/StateMachineInfo.java
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/surrogate/src/org/apache/river/container/hsm/StateMachineInfo.java?rev=1433744&view=auto
==============================================================================
--- river/jtsk/skunk/surrogate/src/org/apache/river/container/hsm/StateMachineInfo.java (added)
+++ river/jtsk/skunk/surrogate/src/org/apache/river/container/hsm/StateMachineInfo.java Tue Jan 15 23:48:46 2013
@@ -0,0 +1,15 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package org.apache.river.container.hsm;
+
+import java.util.List;
+
+/**
+ *
+ * @author trasukg
+ */
+public interface StateMachineInfo {
+    public List<Class> getActiveStates();
+}

Modified: river/jtsk/skunk/surrogate/test/org/apache/river/container/hsm/InitializedMachineTest.java
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/surrogate/test/org/apache/river/container/hsm/InitializedMachineTest.java?rev=1433744&r1=1433743&r2=1433744&view=diff
==============================================================================
--- river/jtsk/skunk/surrogate/test/org/apache/river/container/hsm/InitializedMachineTest.java (original)
+++ river/jtsk/skunk/surrogate/test/org/apache/river/container/hsm/InitializedMachineTest.java Tue Jan 15 23:48:46 2013
@@ -47,7 +47,7 @@ public class InitializedMachineTest {
     @Before
     public void setUp() throws Exception {
         UUT=new InitializedTestSM();
-        UUTI=(InitializedTestSMInterface) StateMachineFactory.createStateMachine(UUT);
+        UUTI=(InitializedTestSMInterface) PlainStateMachineExecutor.createProxy(UUT);
     }
 
     @After

Modified: river/jtsk/skunk/surrogate/test/org/apache/river/container/hsm/PlainMachineExecutorTest.java
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/surrogate/test/org/apache/river/container/hsm/PlainMachineExecutorTest.java?rev=1433744&r1=1433743&r2=1433744&view=diff
==============================================================================
--- river/jtsk/skunk/surrogate/test/org/apache/river/container/hsm/PlainMachineExecutorTest.java (original)
+++ river/jtsk/skunk/surrogate/test/org/apache/river/container/hsm/PlainMachineExecutorTest.java Tue Jan 15 23:48:46 2013
@@ -38,6 +38,9 @@ import static org.junit.Assert.assertTru
  */
 public class PlainMachineExecutorTest {
 
+    private static final Logger log=
+            Logger.getLogger(PlainMachineExecutorTest.class.getName());
+    
     public PlainMachineExecutorTest() throws InstantiationException, IllegalAccessException,
     NoSuchMethodException, InvocationTargetException {
     }
@@ -45,7 +48,6 @@ public class PlainMachineExecutorTest {
     @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
@@ -69,11 +71,13 @@ public class PlainMachineExecutorTest {
      */
     public void testActiveStates() {
 
-        assertEquals(2, UUT.getActiveStates().size());
+        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
@@ -112,11 +116,16 @@ public class PlainMachineExecutorTest {
     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.",
-                UUT.getActiveStates().contains(TestSM.B.class));
+                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

Modified: river/jtsk/skunk/surrogate/test/org/apache/river/container/hsm/StateMachineCompilerTest.java
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/surrogate/test/org/apache/river/container/hsm/StateMachineCompilerTest.java?rev=1433744&r1=1433743&r2=1433744&view=diff
==============================================================================
--- river/jtsk/skunk/surrogate/test/org/apache/river/container/hsm/StateMachineCompilerTest.java (original)
+++ river/jtsk/skunk/surrogate/test/org/apache/river/container/hsm/StateMachineCompilerTest.java Tue Jan 15 23:48:46 2013
@@ -15,7 +15,6 @@
  * 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;
@@ -30,103 +29,106 @@ 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();
-    
+    StateMachineCompiler compiler = new StateMachineCompiler();
+
     @Test
     public void testCompileReturnsMetaState() throws Exception {
-        MetaState stateMachine=compiler.compile(TestSM.class);
+        MetaState stateMachine = compiler.compile(TestSM.class);
         assertTrue(stateMachine + " isn't a MetaState", stateMachine instanceof MetaState);
     }
-    
-    @Test 
+
+    @Test
     public void testSampleActiveStates() throws Exception {
-        MetaState stateMachine=compiler.compile(TestSM.class);
-        List<Class> activeStates=stateMachine.getActiveStates();
+        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 
+     * MetaState for TestSM should have event methods for sayHello and
+     * nullTransition, but nothing else.
+     *
+     * @throws Exception
      */
-    @Test 
+    @Test
     public void testEventMethods() throws Exception {
-        MetaState stateMachine=compiler.compile(TestSM.class);
-        Collection<Method> methods=stateMachine.eventMethods.keySet();
-        Method sayHello=TestSMInterface.class.getMethod("sayHello");
+        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 
+     * 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);
+        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 
+     * 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);
+        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 
+     * 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);
+        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()) {
+        for (SubstateInfo ssi : metaState.substates) {
+            for (MetaState ms : ssi.getPossibleMetaStates()) {
                 if (ms.stateClass == stateClass) {
                     return ms;
                 }
@@ -134,4 +136,11 @@ public class StateMachineCompilerTest {
         }
         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();
+    }
 }

Modified: river/jtsk/skunk/surrogate/test/org/apache/river/container/hsm/TestSM.java
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/surrogate/test/org/apache/river/container/hsm/TestSM.java?rev=1433744&r1=1433743&r2=1433744&view=diff
==============================================================================
--- river/jtsk/skunk/surrogate/test/org/apache/river/container/hsm/TestSM.java (original)
+++ river/jtsk/skunk/surrogate/test/org/apache/river/container/hsm/TestSM.java Tue Jan 15 23:48:46 2013
@@ -32,21 +32,20 @@ public class TestSM {
     @Initial(A.class)
     @Retained
     public Object state;
+    
+    /* Really shouldn't need to be public - we'll fix shortly. */
     @Controller
-    StateMachine controller;
+    public StateMachineInfo controller;
     int nullTransitionEntryCount = 0;
     int aEntryCount = 0, aExitCount = 0;
 
     public List<Class> getActiveStates() {
         try {
-            return ((StateMachineImpl) controller).getActiveStates();
+            return controller.getActiveStates();
         } catch (IllegalArgumentException ex) {
             Logger.getLogger(TestSM.class.getName()).log(Level.SEVERE, null, ex);
             throw new RuntimeException(ex);
-        } catch (IllegalAccessException ex) {
-            Logger.getLogger(TestSM.class.getName()).log(Level.SEVERE, null, ex);
-            throw new RuntimeException(ex);
-        }
+        } 
     }
 
     @Transition(A.class)
@@ -78,7 +77,6 @@ public class TestSM {
     @Guard(A.class)
     public boolean beFalse() {
         return false;
-        
     }
     
     public class A {
@@ -125,8 +123,9 @@ public class TestSM {
 
     public class B1 {
 
+        @Transition(B2.class)
         public void moveSubstateOfB() {
-            controller.transition(B2.class);
+            
         }
     }
 

Modified: river/jtsk/skunk/surrogate/testfiles/logging.properties
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/surrogate/testfiles/logging.properties?rev=1433744&r1=1433743&r2=1433744&view=diff
==============================================================================
--- river/jtsk/skunk/surrogate/testfiles/logging.properties (original)
+++ river/jtsk/skunk/surrogate/testfiles/logging.properties Tue Jan 15 23:48:46 2013
@@ -15,10 +15,10 @@
 # Note that these classes must be on the system classpath.
 # By default we only configure a ConsoleHandler, which will only
 # show messages at the INFO and above levels.
-handlers= java.util.logging.ConsoleHandler
+#handlers= java.util.logging.ConsoleHandler
 
 # To also add the FileHandler, use the following line instead.
-#handlers= java.util.logging.FileHandler, java.util.logging.ConsoleHandler
+handlers= java.util.logging.FileHandler, java.util.logging.ConsoleHandler
 
 # Default global logging level.
 # This specifies which kinds of events are logged across
@@ -34,10 +34,11 @@ handlers= java.util.logging.ConsoleHandl
 ############################################################
 
 # default file output is in user's home directory.
-java.util.logging.FileHandler.pattern = %h/java%u.log
+java.util.logging.FileHandler.pattern = test.log
 java.util.logging.FileHandler.limit = 50000
 java.util.logging.FileHandler.count = 1
-java.util.logging.FileHandler.formatter = java.util.logging.XMLFormatter
+java.util.logging.FileHandler.formatter = java.util.logging.SimpleFormatter
+java.util.logging.SimpleFormatter.format=%1$tb %1$td, %1$tY %1$tl:%1$tM:%1$tS %1$Tp %2$s %4$s: %5$s%n
 
 # Limit the message that are printed on the console to INFO and above.
 java.util.logging.ConsoleHandler.level = FINER

Added: river/jtsk/skunk/surrogate/testfiles/testroot/test.log
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/surrogate/testfiles/testroot/test.log?rev=1433744&view=auto
==============================================================================
--- river/jtsk/skunk/surrogate/testfiles/testroot/test.log (added)
+++ river/jtsk/skunk/surrogate/testfiles/testroot/test.log Tue Jan 15 23:48:46 2013
@@ -0,0 +1,65 @@
+Jan 15, 2013 6:47:43 PM org.apache.river.container.hsm.InvokeVoidAndTransitionOperation eval FINER: Applying event onEntry to state A instance org.apache.river.container.hsm.TestSM$A@2887e18f.
+Jan 15, 2013 6:47:43 PM org.apache.river.container.hsm.InvokeAndTransitionOperation eval FINER: Applying event getActiveStates to state TestSM instance org.apache.river.container.hsm.TestSM@684383e3.
+Jan 15, 2013 6:47:43 PM org.apache.river.container.hsm.InvokeGuardOperation eval FINER: Running guard method beFalse on state TestSM instance org.apache.river.container.hsm.TestSM@684383e3.
+Jan 15, 2013 6:47:43 PM org.apache.river.container.hsm.InvokeAndTransitionOperation eval FINER: Applying event getActiveStates to state TestSM instance org.apache.river.container.hsm.TestSM@684383e3.
+Jan 15, 2013 6:47:43 PM org.apache.river.container.hsm.InvokeGuardOperation eval FINER: Running guard method beFalse on state TestSM instance org.apache.river.container.hsm.TestSM@684383e3.
+Jan 15, 2013 6:47:43 PM org.apache.river.container.hsm.StateMachineCompiler compile FINE: Begginning state machine compilation on org.apache.river.container.hsm.TestSM.
+Jan 15, 2013 6:47:43 PM org.apache.river.container.hsm.StateMachineCompiler compile FINE: Completed compile on org.apache.river.container.hsm.TestSM.
+Jan 15, 2013 6:47:43 PM org.apache.river.container.hsm.PlainStateMachineExecutor$1 visit FINE: MetaState for class org.apache.river.container.hsm.TestSM was instantiated as org.apache.river.container.hsm.TestSM@112062da.
+Jan 15, 2013 6:47:43 PM org.apache.river.container.hsm.PlainStateMachineExecutor$1 visit FINE: MetaState for class org.apache.river.container.hsm.TestSM$A was instantiated as org.apache.river.container.hsm.TestSM$A@6539defe.
+Jan 15, 2013 6:47:43 PM org.apache.river.container.hsm.PlainStateMachineExecutor$1 visit FINE: MetaState for class org.apache.river.container.hsm.TestSM$A$A1 was instantiated as org.apache.river.container.hsm.TestSM$A$A1@3a5f299d.
+Jan 15, 2013 6:47:43 PM org.apache.river.container.hsm.PlainStateMachineExecutor$1 visit FINE: MetaState for class org.apache.river.container.hsm.TestSM$B was instantiated as org.apache.river.container.hsm.TestSM$B@3da5205b.
+Jan 15, 2013 6:47:43 PM org.apache.river.container.hsm.PlainStateMachineExecutor$1 visit FINE: MetaState for class org.apache.river.container.hsm.TestSM$B1 was instantiated as org.apache.river.container.hsm.TestSM$B1@23ef55fb.
+Jan 15, 2013 6:47:43 PM org.apache.river.container.hsm.PlainStateMachineExecutor$1 visit FINE: MetaState for class org.apache.river.container.hsm.TestSM$B2 was instantiated as org.apache.river.container.hsm.TestSM$B2@35f5e42b.
+Jan 15, 2013 6:47:43 PM org.apache.river.container.hsm.PlainStateMachineExecutor$1 visit FINE: MetaState for class org.apache.river.container.hsm.TestSM$B3 was instantiated as org.apache.river.container.hsm.TestSM$B3@2256deba.
+Jan 15, 2013 6:47:43 PM org.apache.river.container.hsm.PlainStateMachineExecutor$2 visit FINE: Setting field state on org.apache.river.container.hsm.TestSM@112062da to org.apache.river.container.hsm.TestSM$A@6539defe.
+Jan 15, 2013 6:47:43 PM org.apache.river.container.hsm.PlainStateMachineExecutor$2 visit FINE: Setting field state on org.apache.river.container.hsm.TestSM$A@6539defe to org.apache.river.container.hsm.TestSM$A$A1@3a5f299d.
+Jan 15, 2013 6:47:43 PM org.apache.river.container.hsm.PlainStateMachineExecutor$2 visit FINE: Setting field state on org.apache.river.container.hsm.TestSM$B@3da5205b to org.apache.river.container.hsm.TestSM$B1@23ef55fb.
+Jan 15, 2013 6:47:43 PM org.apache.river.container.hsm.PlainStateMachineExecutor$4 visit FINE: Visiting Meta-org.apache.river.container.hsm.TestSM to fill in controller reference.
+Jan 15, 2013 6:47:43 PM org.apache.river.container.hsm.PlainStateMachineExecutor fillInReferenceFields FINE: Setting field org.apache.river.container.hsm.TestSM@112062da.controller to org.apache.river.container.hsm.PlainStateMachineExecutor@563e25fd
+Jan 15, 2013 6:47:43 PM org.apache.river.container.hsm.PlainStateMachineExecutor$4 visit FINE: Visiting Meta-org.apache.river.container.hsm.TestSM$A to fill in controller reference.
+Jan 15, 2013 6:47:43 PM org.apache.river.container.hsm.PlainStateMachineExecutor$4 visit FINE: Visiting Meta-org.apache.river.container.hsm.TestSM$A$A1 to fill in controller reference.
+Jan 15, 2013 6:47:43 PM org.apache.river.container.hsm.PlainStateMachineExecutor$4 visit FINE: Visiting Meta-org.apache.river.container.hsm.TestSM$B to fill in controller reference.
+Jan 15, 2013 6:47:43 PM org.apache.river.container.hsm.PlainStateMachineExecutor$4 visit FINE: Visiting Meta-org.apache.river.container.hsm.TestSM$B1 to fill in controller reference.
+Jan 15, 2013 6:47:43 PM org.apache.river.container.hsm.PlainStateMachineExecutor$4 visit FINE: Visiting Meta-org.apache.river.container.hsm.TestSM$B2 to fill in controller reference.
+Jan 15, 2013 6:47:43 PM org.apache.river.container.hsm.PlainStateMachineExecutor$4 visit FINE: Visiting Meta-org.apache.river.container.hsm.TestSM$B3 to fill in controller reference.
+Jan 15, 2013 6:47:43 PM org.apache.river.container.hsm.PlainStateMachineExecutor$5 visit FINE: Visiting Meta-org.apache.river.container.hsm.TestSM to fill in root state reference.
+Jan 15, 2013 6:47:43 PM org.apache.river.container.hsm.PlainStateMachineExecutor$5 visit FINE: Visiting Meta-org.apache.river.container.hsm.TestSM$A to fill in root state reference.
+Jan 15, 2013 6:47:43 PM org.apache.river.container.hsm.PlainStateMachineExecutor$5 visit FINE: Visiting Meta-org.apache.river.container.hsm.TestSM$A$A1 to fill in root state reference.
+Jan 15, 2013 6:47:43 PM org.apache.river.container.hsm.PlainStateMachineExecutor$5 visit FINE: Visiting Meta-org.apache.river.container.hsm.TestSM$B to fill in root state reference.
+Jan 15, 2013 6:47:43 PM org.apache.river.container.hsm.PlainStateMachineExecutor$5 visit FINE: Visiting Meta-org.apache.river.container.hsm.TestSM$B1 to fill in root state reference.
+Jan 15, 2013 6:47:43 PM org.apache.river.container.hsm.PlainStateMachineExecutor$5 visit FINE: Visiting Meta-org.apache.river.container.hsm.TestSM$B2 to fill in root state reference.
+Jan 15, 2013 6:47:43 PM org.apache.river.container.hsm.PlainStateMachineExecutor$5 visit FINE: Visiting Meta-org.apache.river.container.hsm.TestSM$B3 to fill in root state reference.
+Jan 15, 2013 6:47:43 PM org.apache.river.container.hsm.InvokeVoidAndTransitionOperation eval FINER: Applying event onEntry to state A instance org.apache.river.container.hsm.TestSM$A@6539defe.
+Jan 15, 2013 6:47:43 PM org.apache.river.container.hsm.InvokeAndTransitionOperation eval FINER: Applying event gotoA to state TestSM instance org.apache.river.container.hsm.TestSM@112062da.
+Jan 15, 2013 6:47:43 PM org.apache.river.container.hsm.PlainStateMachineExecutor queueTransition FINER: Queued transition to A on TestSM.
+Jan 15, 2013 6:47:43 PM org.apache.river.container.hsm.InvokeGuardOperation eval FINER: Running guard method beFalse on state TestSM instance org.apache.river.container.hsm.TestSM@112062da.
+Jan 15, 2013 6:47:43 PM org.apache.river.container.hsm.InvokeAndTransitionOperation eval FINER: Applying event getActiveStates to state TestSM instance org.apache.river.container.hsm.TestSM@112062da.
+Jan 15, 2013 6:47:43 PM org.apache.river.container.hsm.InvokeGuardOperation eval FINER: Running guard method beFalse on state TestSM instance org.apache.river.container.hsm.TestSM@112062da.
+Jan 15, 2013 6:47:43 PM org.apache.river.container.hsm.InvokeAndTransitionOperation eval FINER: Applying event getActiveStates to state TestSM instance org.apache.river.container.hsm.TestSM@112062da.
+Jan 15, 2013 6:47:43 PM org.apache.river.container.hsm.InvokeGuardOperation eval FINER: Running guard method beFalse on state TestSM instance org.apache.river.container.hsm.TestSM@112062da.
+Jan 15, 2013 6:47:43 PM org.apache.river.container.hsm.InvokeAndTransitionOperation eval FINER: Applying event gotoB to state TestSM instance org.apache.river.container.hsm.TestSM@112062da.
+Jan 15, 2013 6:47:43 PM org.apache.river.container.hsm.PlainStateMachineExecutor queueTransition FINER: Queued transition to B on TestSM.
+Jan 15, 2013 6:47:43 PM org.apache.river.container.hsm.InvokeGuardOperation eval FINER: Running guard method beFalse on state TestSM instance org.apache.river.container.hsm.TestSM@112062da.
+Jan 15, 2013 6:47:43 PM org.apache.river.container.hsm.InvokeVoidAndTransitionOperation eval FINER: Applying event onExit to state A instance org.apache.river.container.hsm.TestSM$A@6539defe.
+Jan 15, 2013 6:47:43 PM org.apache.river.container.hsm.InvokeAndTransitionOperation eval FINER: Applying event getActiveStates to state TestSM instance org.apache.river.container.hsm.TestSM@112062da.
+Jan 15, 2013 6:47:43 PM org.apache.river.container.hsm.InvokeGuardOperation eval FINER: Running guard method beFalse on state TestSM instance org.apache.river.container.hsm.TestSM@112062da.
+Jan 15, 2013 6:47:43 PM org.apache.river.container.hsm.InvokeAndTransitionOperation eval FINER: Applying event getActiveStates to state TestSM instance org.apache.river.container.hsm.TestSM@112062da.
+Jan 15, 2013 6:47:43 PM org.apache.river.container.hsm.InvokeGuardOperation eval FINER: Running guard method beFalse on state TestSM instance org.apache.river.container.hsm.TestSM@112062da.
+Jan 15, 2013 6:47:43 PM org.apache.river.container.hsm.InvokeAndTransitionOperation eval FINER: Applying event getActiveStates to state TestSM instance org.apache.river.container.hsm.TestSM@112062da.
+Jan 15, 2013 6:47:43 PM org.apache.river.container.hsm.InvokeGuardOperation eval FINER: Running guard method beFalse on state TestSM instance org.apache.river.container.hsm.TestSM@112062da.
+Jan 15, 2013 6:47:43 PM org.apache.river.container.hsm.InvokeAndTransitionOperation eval FINER: Applying event moveSubstateOfB to state B1 instance org.apache.river.container.hsm.TestSM$B1@23ef55fb.
+Jan 15, 2013 6:47:43 PM org.apache.river.container.hsm.PlainStateMachineExecutor queueTransition FINER: Queued transition to B2 on B.
+Jan 15, 2013 6:47:43 PM org.apache.river.container.hsm.InvokeGuardOperation eval FINER: Running guard method beFalse on state TestSM instance org.apache.river.container.hsm.TestSM@112062da.
+Jan 15, 2013 6:47:43 PM org.apache.river.container.hsm.InvokeAndTransitionOperation eval FINER: Applying event getActiveStates to state TestSM instance org.apache.river.container.hsm.TestSM@112062da.
+Jan 15, 2013 6:47:43 PM org.apache.river.container.hsm.InvokeGuardOperation eval FINER: Running guard method beFalse on state TestSM instance org.apache.river.container.hsm.TestSM@112062da.
+Jan 15, 2013 6:47:43 PM org.apache.river.container.hsm.InvokeAndTransitionOperation eval FINER: Applying event gotoA to state TestSM instance org.apache.river.container.hsm.TestSM@112062da.
+Jan 15, 2013 6:47:43 PM org.apache.river.container.hsm.PlainStateMachineExecutor queueTransition FINER: Queued transition to A on TestSM.
+Jan 15, 2013 6:47:43 PM org.apache.river.container.hsm.InvokeGuardOperation eval FINER: Running guard method beFalse on state TestSM instance org.apache.river.container.hsm.TestSM@112062da.
+Jan 15, 2013 6:47:43 PM org.apache.river.container.hsm.InvokeVoidAndTransitionOperation eval FINER: Applying event onEntry to state A instance org.apache.river.container.hsm.TestSM$A@6539defe.
+Jan 15, 2013 6:47:43 PM org.apache.river.container.hsm.InvokeAndTransitionOperation eval FINER: Applying event gotoB to state TestSM instance org.apache.river.container.hsm.TestSM@112062da.
+Jan 15, 2013 6:47:43 PM org.apache.river.container.hsm.PlainStateMachineExecutor queueTransition FINER: Queued transition to B on TestSM.
+Jan 15, 2013 6:47:43 PM org.apache.river.container.hsm.InvokeGuardOperation eval FINER: Running guard method beFalse on state TestSM instance org.apache.river.container.hsm.TestSM@112062da.
+Jan 15, 2013 6:47:43 PM org.apache.river.container.hsm.InvokeVoidAndTransitionOperation eval FINER: Applying event onExit to state A instance org.apache.river.container.hsm.TestSM$A@6539defe.
+Jan 15, 2013 6:47:43 PM org.apache.river.container.hsm.InvokeAndTransitionOperation eval FINER: Applying event getActiveStates to state TestSM instance org.apache.river.container.hsm.TestSM@112062da.
+Jan 15, 2013 6:47:43 PM org.apache.river.container.hsm.InvokeGuardOperation eval FINER: Running guard method beFalse on state TestSM instance org.apache.river.container.hsm.TestSM@112062da.