You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by ra...@apache.org on 2006/02/05 19:04:53 UTC

svn commit: r375066 [1/2] - in /jakarta/commons/sandbox/scxml/branches/BETWIXT_IO: ./ src/main/java/org/apache/commons/scxml/ src/main/java/org/apache/commons/scxml/env/jexl/ src/main/java/org/apache/commons/scxml/env/jsp/ src/main/java/org/apache/comm...

Author: rahul
Date: Sun Feb  5 10:04:50 2006
New Revision: 375066

URL: http://svn.apache.org/viewcvs?rev=375066&view=rev
Log:
Regular branch maintenance. Pull in the recent changes from trunk. This is particularly important in this case since the betwixt IO will be easier to set up on the stateless model.

Added:
    jakarta/commons/sandbox/scxml/branches/BETWIXT_IO/src/main/java/org/apache/commons/scxml/SCInstance.java
      - copied unchanged from r375060, jakarta/commons/sandbox/scxml/trunk/src/main/java/org/apache/commons/scxml/SCInstance.java
    jakarta/commons/sandbox/scxml/branches/BETWIXT_IO/src/test/java/org/apache/commons/scxml/TestBuiltin.java
      - copied unchanged from r375060, jakarta/commons/sandbox/scxml/trunk/src/test/java/org/apache/commons/scxml/TestBuiltin.java
    jakarta/commons/sandbox/scxml/branches/BETWIXT_IO/src/test/java/org/apache/commons/scxml/TestSCXMLHelper.java
      - copied unchanged from r375060, jakarta/commons/sandbox/scxml/trunk/src/test/java/org/apache/commons/scxml/TestSCXMLHelper.java
    jakarta/commons/sandbox/scxml/branches/BETWIXT_IO/src/test/java/org/apache/commons/scxml/TestStatus.java
      - copied unchanged from r375060, jakarta/commons/sandbox/scxml/trunk/src/test/java/org/apache/commons/scxml/TestStatus.java
    jakarta/commons/sandbox/scxml/branches/BETWIXT_IO/src/test/java/org/apache/commons/scxml/env/MockErrorReporter.java
      - copied unchanged from r375060, jakarta/commons/sandbox/scxml/trunk/src/test/java/org/apache/commons/scxml/env/MockErrorReporter.java
    jakarta/commons/sandbox/scxml/branches/BETWIXT_IO/src/test/java/org/apache/commons/scxml/env/TestLogUtils.java
      - copied unchanged from r375060, jakarta/commons/sandbox/scxml/trunk/src/test/java/org/apache/commons/scxml/env/TestLogUtils.java
    jakarta/commons/sandbox/scxml/branches/BETWIXT_IO/src/test/java/org/apache/commons/scxml/env/TestSimpleContext.java
      - copied unchanged from r375060, jakarta/commons/sandbox/scxml/trunk/src/test/java/org/apache/commons/scxml/env/TestSimpleContext.java
    jakarta/commons/sandbox/scxml/branches/BETWIXT_IO/src/test/java/org/apache/commons/scxml/io/TestSCXMLSerializer.java
      - copied unchanged from r375060, jakarta/commons/sandbox/scxml/trunk/src/test/java/org/apache/commons/scxml/io/TestSCXMLSerializer.java
    jakarta/commons/sandbox/scxml/branches/BETWIXT_IO/src/test/java/org/apache/commons/scxml/model/TestAction.java
      - copied unchanged from r375060, jakarta/commons/sandbox/scxml/trunk/src/test/java/org/apache/commons/scxml/model/TestAction.java
Removed:
    jakarta/commons/sandbox/scxml/branches/BETWIXT_IO/src/main/java/org/apache/commons/scxml/Observable.java
Modified:
    jakarta/commons/sandbox/scxml/branches/BETWIXT_IO/   (props changed)
    jakarta/commons/sandbox/scxml/branches/BETWIXT_IO/project.xml
    jakarta/commons/sandbox/scxml/branches/BETWIXT_IO/src/main/java/org/apache/commons/scxml/NotificationRegistry.java
    jakarta/commons/sandbox/scxml/branches/BETWIXT_IO/src/main/java/org/apache/commons/scxml/SCXMLExecutor.java
    jakarta/commons/sandbox/scxml/branches/BETWIXT_IO/src/main/java/org/apache/commons/scxml/SCXMLSemantics.java
    jakarta/commons/sandbox/scxml/branches/BETWIXT_IO/src/main/java/org/apache/commons/scxml/env/jexl/JexlContext.java
    jakarta/commons/sandbox/scxml/branches/BETWIXT_IO/src/main/java/org/apache/commons/scxml/env/jexl/JexlEvaluator.java
    jakarta/commons/sandbox/scxml/branches/BETWIXT_IO/src/main/java/org/apache/commons/scxml/env/jsp/ELEvaluator.java
    jakarta/commons/sandbox/scxml/branches/BETWIXT_IO/src/main/java/org/apache/commons/scxml/io/SCXMLDigester.java
    jakarta/commons/sandbox/scxml/branches/BETWIXT_IO/src/main/java/org/apache/commons/scxml/model/History.java
    jakarta/commons/sandbox/scxml/branches/BETWIXT_IO/src/main/java/org/apache/commons/scxml/model/SCXML.java
    jakarta/commons/sandbox/scxml/branches/BETWIXT_IO/src/main/java/org/apache/commons/scxml/model/State.java
    jakarta/commons/sandbox/scxml/branches/BETWIXT_IO/src/main/java/org/apache/commons/scxml/model/Transition.java
    jakarta/commons/sandbox/scxml/branches/BETWIXT_IO/src/main/java/org/apache/commons/scxml/model/TransitionTarget.java
    jakarta/commons/sandbox/scxml/branches/BETWIXT_IO/src/main/java/org/apache/commons/scxml/semantics/SCXMLSemanticsImpl.java
    jakarta/commons/sandbox/scxml/branches/BETWIXT_IO/src/main/java/org/apache/commons/scxml/test/StandaloneUtils.java
    jakarta/commons/sandbox/scxml/branches/BETWIXT_IO/src/test/java/org/apache/commons/scxml/SCXMLTestHelper.java
    jakarta/commons/sandbox/scxml/branches/BETWIXT_IO/src/test/java/org/apache/commons/scxml/SCXMLTestSuite.java
    jakarta/commons/sandbox/scxml/branches/BETWIXT_IO/src/test/java/org/apache/commons/scxml/env/EnvTestSuite.java
    jakarta/commons/sandbox/scxml/branches/BETWIXT_IO/src/test/java/org/apache/commons/scxml/env/jsp/RootContextTest.java
    jakarta/commons/sandbox/scxml/branches/BETWIXT_IO/src/test/java/org/apache/commons/scxml/io/IOTestSuite.java
    jakarta/commons/sandbox/scxml/branches/BETWIXT_IO/src/test/java/org/apache/commons/scxml/model/ActionsTest.java
    jakarta/commons/sandbox/scxml/branches/BETWIXT_IO/src/test/java/org/apache/commons/scxml/model/ModelTestSuite.java
    jakarta/commons/sandbox/scxml/branches/BETWIXT_IO/xdocs/api-notes/core-digester.xml
    jakarta/commons/sandbox/scxml/branches/BETWIXT_IO/xdocs/api-notes/core-engine.xml
    jakarta/commons/sandbox/scxml/branches/BETWIXT_IO/xdocs/navigation.xml

Propchange: jakarta/commons/sandbox/scxml/branches/BETWIXT_IO/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Sun Feb  5 10:04:50 2006
@@ -3,3 +3,4 @@
 build.properties
 target
 velocity.log
+cobertura.ser

Modified: jakarta/commons/sandbox/scxml/branches/BETWIXT_IO/project.xml
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/scxml/branches/BETWIXT_IO/project.xml?rev=375066&r1=375065&r2=375066&view=diff
==============================================================================
--- jakarta/commons/sandbox/scxml/branches/BETWIXT_IO/project.xml (original)
+++ jakarta/commons/sandbox/scxml/branches/BETWIXT_IO/project.xml Sun Feb  5 10:04:50 2006
@@ -87,6 +87,9 @@
     <contributor>
       <name>Jaroslav Gergic</name>
     </contributor>
+    <contributor>
+      <name>Peter Costa</name>
+    </contributor>
   </contributors>
   
   <dependencies>
@@ -226,6 +229,7 @@
      <!--report>maven-changelog-plugin</report-->
      <report>maven-changes-plugin</report>
      <report>maven-checkstyle-plugin</report>
+     <report>maven-cobertura-plugin</report>
      <!--report>maven-clover-plugin</report-->
      <!--report>maven-developer-activity-plugin</report-->
      <!--report>maven-file-activity-plugin</report-->

Modified: jakarta/commons/sandbox/scxml/branches/BETWIXT_IO/src/main/java/org/apache/commons/scxml/NotificationRegistry.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/scxml/branches/BETWIXT_IO/src/main/java/org/apache/commons/scxml/NotificationRegistry.java?rev=375066&r1=375065&r2=375066&view=diff
==============================================================================
--- jakarta/commons/sandbox/scxml/branches/BETWIXT_IO/src/main/java/org/apache/commons/scxml/NotificationRegistry.java (original)
+++ jakarta/commons/sandbox/scxml/branches/BETWIXT_IO/src/main/java/org/apache/commons/scxml/NotificationRegistry.java Sun Feb  5 10:04:50 2006
@@ -1,6 +1,6 @@
 /*
  *
- *   Copyright 2005 The Apache Software Foundation.
+ *   Copyright 2005-2006 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.
@@ -23,16 +23,20 @@
 import java.util.Map;
 import java.util.Set;
 
+import org.apache.commons.scxml.model.SCXML;
 import org.apache.commons.scxml.model.Transition;
 import org.apache.commons.scxml.model.TransitionTarget;
 
 /**
- * The registry where SCXML listeners are recorded for Observable
- * objects. The registry performs book keeping functions and notifies
- * all listeners of the events of interest.
+ * The registry where SCXML listeners are recorded for nodes of
+ * interest such as the <code>SCXML</code> root,
+ * <code>TransitionTarget</code>s and <code>Transition</code>s.
+ * The notification registry keeps track of all
+ * <code>SCXMLListener</code>s attached and notifies relevant
+ * listeners of the events that interest them.
  *
  */
-public class NotificationRegistry {
+public final class NotificationRegistry {
 
     /**
      * The Map of all listeners keyed by Observable.
@@ -52,7 +56,7 @@
      * @param source The observable this listener wants to listen to
      * @param lst The listener
      */
-    public final void addListener(final Observable source,
+    void addListener(final Object source,
             final SCXMLListener lst) {
         Set entries = (Set) regs.get(source);
         if (entries == null) {
@@ -68,7 +72,7 @@
      * @param source The observable this listener wants to stop listening to
      * @param lst The listener
      */
-    public final void removeListener(final Observable source,
+    void removeListener(final Object source,
             final SCXMLListener lst) {
         Set entries = (Set) regs.get(source);
         if (entries != null) {
@@ -83,10 +87,36 @@
      * Inform all relevant listeners that a TransitionTarget has been
      * entered.
      *
+     * @param observable The Observable
+     * @param state The TransitionTarget that was entered
+     */
+    public void fireOnEntry(final TransitionTarget observable,
+            final TransitionTarget state) {
+        Object source = observable;
+        fireOnEntry(source, state);
+    }
+
+    /**
+     * Inform all relevant listeners that a TransitionTarget has been
+     * entered.
+     *
+     * @param observable The Observable
+     * @param state The TransitionTarget that was entered
+     */
+    public void fireOnEntry(final SCXML observable,
+            final TransitionTarget state) {
+        Object source = observable;
+        fireOnEntry(source, state);
+    }
+
+    /**
+     * Inform all relevant listeners that a TransitionTarget has been
+     * entered.
+     *
      * @param source The Observable
      * @param state The TransitionTarget that was entered
      */
-    public final void fireOnEntry(final Observable source,
+    private void fireOnEntry(final Object source,
             final TransitionTarget state) {
         Set entries = (Set) regs.get(source);
         if (entries != null) {
@@ -101,10 +131,36 @@
      * Inform all relevant listeners that a TransitionTarget has been
      * exited.
      *
+     * @param observable The Observable
+     * @param state The TransitionTarget that was exited
+     */
+    public void fireOnExit(final TransitionTarget observable,
+            final TransitionTarget state) {
+        Object source = observable;
+        fireOnExit(source, state);
+    }
+
+    /**
+     * Inform all relevant listeners that a TransitionTarget has been
+     * exited.
+     *
+     * @param observable The Observable
+     * @param state The TransitionTarget that was exited
+     */
+    public void fireOnExit(final SCXML observable,
+            final TransitionTarget state) {
+        Object source = observable;
+        fireOnExit(source, state);
+    }
+
+    /**
+     * Inform all relevant listeners that a TransitionTarget has been
+     * exited.
+     *
      * @param source The Observable
      * @param state The TransitionTarget that was exited
      */
-    public final void fireOnExit(final Observable source,
+    private void fireOnExit(final Object source,
             final TransitionTarget state) {
         Set entries = (Set) regs.get(source);
         if (entries != null) {
@@ -118,12 +174,42 @@
     /**
      * Inform all relevant listeners of a transition that has occured.
      *
+     * @param observable The Observable
+     * @param from The source TransitionTarget
+     * @param to The destination TransitionTarget
+     * @param transition The Transition that was taken
+     */
+    public void fireOnTransition(final Transition observable,
+            final TransitionTarget from, final TransitionTarget to,
+            final Transition transition) {
+        Object source = observable;
+        fireOnTransition(source, from, to, transition);
+    }
+
+    /**
+     * Inform all relevant listeners of a transition that has occured.
+     *
+     * @param observable The Observable
+     * @param from The source TransitionTarget
+     * @param to The destination TransitionTarget
+     * @param transition The Transition that was taken
+     */
+    public void fireOnTransition(final SCXML observable,
+            final TransitionTarget from, final TransitionTarget to,
+            final Transition transition) {
+        Object source = observable;
+        fireOnTransition(source, from, to, transition);
+    }
+
+    /**
+     * Inform all relevant listeners of a transition that has occured.
+     *
      * @param source The Observable
      * @param from The source TransitionTarget
      * @param to The destination TransitionTarget
      * @param transition The Transition that was taken
      */
-    public final void fireOnTransition(final Observable source,
+    private void fireOnTransition(final Object source,
             final TransitionTarget from, final TransitionTarget to,
             final Transition transition) {
         Set entries = (Set) regs.get(source);
@@ -134,5 +220,6 @@
             }
         }
     }
+
 }
 

Modified: jakarta/commons/sandbox/scxml/branches/BETWIXT_IO/src/main/java/org/apache/commons/scxml/SCXMLExecutor.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/scxml/branches/BETWIXT_IO/src/main/java/org/apache/commons/scxml/SCXMLExecutor.java?rev=375066&r1=375065&r2=375066&view=diff
==============================================================================
--- jakarta/commons/sandbox/scxml/branches/BETWIXT_IO/src/main/java/org/apache/commons/scxml/SCXMLExecutor.java (original)
+++ jakarta/commons/sandbox/scxml/branches/BETWIXT_IO/src/main/java/org/apache/commons/scxml/SCXMLExecutor.java Sun Feb  5 10:04:50 2006
@@ -1,6 +1,6 @@
 /*
  *
- *   Copyright 2005 The Apache Software Foundation.
+ *   Copyright 2005-2006 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.
@@ -27,6 +27,7 @@
 import org.apache.commons.scxml.model.ModelException;
 import org.apache.commons.scxml.model.SCXML;
 import org.apache.commons.scxml.model.State;
+import org.apache.commons.scxml.model.Transition;
 import org.apache.commons.scxml.model.TransitionTarget;
 import org.apache.commons.scxml.semantics.SCXMLSemanticsImpl;
 
@@ -53,11 +54,6 @@
     private SCXML stateMachine;
 
     /**
-     * The evaluator for expressions.
-     */
-    private Evaluator evaluator;
-
-    /**
      * The current status of the stateMachine.
      */
     private Status currentStatus;
@@ -83,6 +79,11 @@
     private SCXMLSemantics semantics;
 
     /**
+     * The SCInstance.
+     */
+    private SCInstance scInstance;
+
+    /**
      * The worker method.
      * Re-evaluates current status whenever any events are triggered.
      *
@@ -102,14 +103,14 @@
             semantics.enumerateReachableTransitions(stateMachine, step,
                     errorReporter);
             // FilterTransitionSet
-            semantics.filterTransitionsSet(step, evaluator, errorReporter);
+            semantics.filterTransitionsSet(step, errorReporter, scInstance);
             // FollowTransitions
-            semantics.followTransitions(step, errorReporter);
+            semantics.followTransitions(step, errorReporter, scInstance);
             // UpdateHistoryStates
-            semantics.updateHistoryStates(step, errorReporter);
+            semantics.updateHistoryStates(step, errorReporter, scInstance);
             // ExecuteActions
-            semantics.executeActions(step, stateMachine, evaluator,
-                    eventdispatcher, errorReporter);
+            semantics.executeActions(step, stateMachine, eventdispatcher,
+                    errorReporter, scInstance);
             // AssignCurrentStatus
             updateStatus(step);
             // ***Cleanup external events if superStep
@@ -129,7 +130,8 @@
      */
     public SCXMLExecutor(final Evaluator expEvaluator,
             final EventDispatcher evtDisp, final ErrorReporter errRep) {
-        this(expEvaluator, evtDisp, errRep, null);    }
+        this(expEvaluator, evtDisp, errRep, null);
+    }
 
     /**
      * Convenience constructor.
@@ -149,7 +151,6 @@
     public SCXMLExecutor(final Evaluator expEvaluator,
             final EventDispatcher evtDisp, final ErrorReporter errRep,
             final SCXMLSemantics semantics) {
-        this.evaluator = expEvaluator;
         this.eventdispatcher = evtDisp;
         this.errorReporter = errRep;
         this.currentStatus = null;
@@ -162,6 +163,8 @@
         }
         this.currentStatus = null;
         this.stateMachine = null;
+        this.scInstance = new SCInstance();
+        this.scInstance.setEvaluator(expEvaluator);
     }
 
     /**
@@ -173,15 +176,18 @@
      */
     public void reset() throws ModelException {
         // Reset all variable contexts
-        stateMachine.getRootContext().reset();
-        // all states and parallels, only states have var. contexts
+        scInstance.getRootContext().reset();
+        // all states and parallels, only states have variable contexts
         for (Iterator i = stateMachine.getTargets().values().iterator();
                 i.hasNext();) {
             TransitionTarget tt = (TransitionTarget) i.next();
             if (tt instanceof State) {
-                ((State) tt).getContext().reset();
+                Context context = scInstance.lookupContext(tt);
+                if (context != null) {
+                    context.reset();
+                }
             } else if (tt instanceof History) {
-                ((History) tt).reset();
+                scInstance.reset((History) tt);
             }
         }
         // CreateEmptyStatus
@@ -190,10 +196,10 @@
         // DetermineInitialStates
         semantics.determineInitialStates(stateMachine,
                 step.getAfterStatus().getStates(),
-                step.getEntryList(), errorReporter);
+                step.getEntryList(), errorReporter, scInstance);
         // ExecuteActions
-        semantics.executeActions(step, stateMachine, evaluator,
-                eventdispatcher, errorReporter);
+        semantics.executeActions(step, stateMachine, eventdispatcher,
+                errorReporter, scInstance);
         // AssignCurrentStatus
         updateStatus(step);
         // Execute Immediate Transitions
@@ -214,19 +220,17 @@
     }
 
     /**
-     * Get the expression evaluator.
-     *
-     * @return Returns the evaluator.
+     * @param evaluator The evaluator to set.
      */
-    public Evaluator getEvaluator() {
-        return evaluator;
+    public void setEvaluator(final Evaluator evaluator) {
+        this.scInstance.setEvaluator(evaluator);
     }
 
     /**
-     * @param evaluator The evaluator to set.
+     * @param rootContext The Context that ties to the host environment.
      */
-    public void setEvaluator(final Evaluator evaluator) {
-        this.evaluator = evaluator;
+    public void setRootContext(final Context rootContext) {
+        this.scInstance.setRootContext(rootContext);
     }
 
     /**
@@ -242,17 +246,23 @@
      * Set the state machine to be executed.
      *
      * @param stateMachine The stateMachine to set.
-     * @throws ModelException in case there is a fatal SCXML object
-     *  model problem.
      */
-    public void setStateMachine(final SCXML stateMachine)
-            throws ModelException {
+    public void setStateMachine(final SCXML stateMachine) {
         // NormalizeStateMachine
         SCXML sm = semantics.normalizeStateMachine(stateMachine,
                 errorReporter);
         // StoreStateMachine
         this.stateMachine = sm;
-        // reset
+    }
+
+    /**
+     * Initiate state machine execution.
+     *
+     * @throws ModelException in case there is a fatal SCXML object
+     *  model problem.
+     */
+    public void go() throws ModelException {
+        // same as reset
         this.reset();
     }
 
@@ -319,6 +329,90 @@
     }
 
     /**
+     * Add a listener to the document root.
+     *
+     * @param scxml The document root to attach listener to.
+     * @param listener The SCXMLListener.
+     */
+    public void addListener(final SCXML scxml, final SCXMLListener listener) {
+        Object observable = scxml;
+        scInstance.getNotificationRegistry().addListener(observable, listener);
+    }
+
+    /**
+     * Remove this listener from the document root.
+     *
+     * @param scxml The document root.
+     * @param listener The SCXMLListener to be removed.
+     */
+    public void removeListener(final SCXML scxml,
+            final SCXMLListener listener) {
+        Object observable = scxml;
+        scInstance.getNotificationRegistry().removeListener(observable,
+            listener);
+    }
+
+    /**
+     * Add a listener to this transition target.
+     *
+     * @param transitionTarget The <code>TransitionTarget</code> to
+     *                         attach listener to.
+     * @param listener The SCXMLListener.
+     */
+    public void addListener(final TransitionTarget transitionTarget,
+            final SCXMLListener listener) {
+        Object observable = transitionTarget;
+        scInstance.getNotificationRegistry().addListener(observable, listener);
+    }
+
+    /**
+     * Remove this listener for this transition target.
+     *
+     * @param transitionTarget The <code>TransitionTarget</code>.
+     * @param listener The SCXMLListener to be removed.
+     */
+    public void removeListener(final TransitionTarget transitionTarget,
+            final SCXMLListener listener) {
+        Object observable = transitionTarget;
+        scInstance.getNotificationRegistry().removeListener(observable,
+            listener);
+    }
+
+    /**
+     * Add a listener to this transition.
+     *
+     * @param transition The <code>Transition</code> to attach listener to.
+     * @param listener The SCXMLListener.
+     */
+    public void addListener(final Transition transition,
+            final SCXMLListener listener) {
+        Object observable = transition;
+        scInstance.getNotificationRegistry().addListener(observable, listener);
+    }
+
+    /**
+     * Remove this listener for this transition.
+     *
+     * @param transition The <code>Transition</code>.
+     * @param listener The SCXMLListener to be removed.
+     */
+    public void removeListener(final Transition transition,
+            final SCXMLListener listener) {
+        Object observable = transition;
+        scInstance.getNotificationRegistry().removeListener(observable,
+            listener);
+    }
+
+    /**
+     * Get the state chart instance for this executor.
+     *
+     * @return The SCInstance for this executor.
+     */
+    SCInstance getSCInstance() {
+        return scInstance;
+    }
+
+    /**
      * Log the current set of active states.
      */
     private void logState() {
@@ -341,8 +435,10 @@
      * @param step The most recent Step
      */
     private void updateStatus(final Step step) {
-        this.currentStatus = step.getAfterStatus();
-        stateMachine.getRootContext().setLocal("_ALL_STATES",
+        currentStatus = step.getAfterStatus();
+        scInstance.getRootContext().setLocal("_ALL_STATES",
             SCXMLHelper.getAncestorClosure(currentStatus.getStates(), null));
     }
+
 }
+

Modified: jakarta/commons/sandbox/scxml/branches/BETWIXT_IO/src/main/java/org/apache/commons/scxml/SCXMLSemantics.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/scxml/branches/BETWIXT_IO/src/main/java/org/apache/commons/scxml/SCXMLSemantics.java?rev=375066&r1=375065&r2=375066&view=diff
==============================================================================
--- jakarta/commons/sandbox/scxml/branches/BETWIXT_IO/src/main/java/org/apache/commons/scxml/SCXMLSemantics.java (original)
+++ jakarta/commons/sandbox/scxml/branches/BETWIXT_IO/src/main/java/org/apache/commons/scxml/SCXMLSemantics.java Sun Feb  5 10:04:50 2006
@@ -1,6 +1,6 @@
 /*
  *
- *   Copyright 2005 The Apache Software Foundation.
+ *   Copyright 2005-2006 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.
@@ -68,11 +68,15 @@
      *            a list of States and Parallels to enter
      * @param errRep
      *            ErrorReporter callback
+     * @param scInstance
+     *            The state chart instance
+     *
      * @throws ModelException
      *             in case there is a fatal SCXML object model problem.
      */
     void determineInitialStates(final SCXML input, final Set states,
-            final List entryList, final ErrorReporter errRep)
+            final List entryList, final ErrorReporter errRep,
+            final SCInstance scInstance)
     throws ModelException;
 
     /**
@@ -83,18 +87,19 @@
      *            updated its AfterStatus/Events
      * @param stateMachine
      *            state machine - SCXML instance
-     * @param eval
-     *            the expression evaluator - Evaluator instance
      * @param evtDispatcher
      *            the event dispatcher - EventDispatcher instance
      * @param errRep
      *            error reporter
+     * @param scInstance
+     *            The state chart instance
+     *
      * @throws ModelException
      *             in case there is a fatal SCXML object model problem.
      */
     void executeActions(final Step step, final SCXML stateMachine,
-            final Evaluator eval, final EventDispatcher evtDispatcher,
-            final ErrorReporter errRep)
+            final EventDispatcher evtDispatcher, final ErrorReporter errRep,
+            final SCInstance scInstance)
     throws ModelException;
 
     /**
@@ -116,13 +121,13 @@
      *
      * @param step
      *            with current status
-     * @param evaluator
-     *            guard condition evaluator
      * @param errRep
      *            ErrorReporter callback
+     * @param scInstance
+     *            The state chart instance
      */
-    void filterTransitionsSet(final Step step, final Evaluator evaluator,
-            final ErrorReporter errRep);
+    void filterTransitionsSet(final Step step, final ErrorReporter errRep,
+            final SCInstance scInstance);
 
     /**
      * Follow the candidate transitions for this execution Step, and update the
@@ -130,11 +135,13 @@
      *
      * @param step The current Step
      * @param errorReporter The ErrorReporter for the current environment
+     * @param scInstance The state chart instance
      *
      * @throws ModelException
      *             in case there is a fatal SCXML object model problem.
      */
-    void followTransitions(final Step step, final ErrorReporter errorReporter)
+    void followTransitions(final Step step, final ErrorReporter errorReporter,
+            final SCInstance scInstance)
     throws ModelException;
 
     /**
@@ -145,7 +152,10 @@
      *            The current Step
      * @param errRep
      *            ErrorReporter callback
+     * @param scInstance
+     *            The state chart instance
      */
-    void updateHistoryStates(final Step step, final ErrorReporter errRep);
+    void updateHistoryStates(final Step step, final ErrorReporter errRep,
+            final SCInstance scInstance);
 
 }

Modified: jakarta/commons/sandbox/scxml/branches/BETWIXT_IO/src/main/java/org/apache/commons/scxml/env/jexl/JexlContext.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/scxml/branches/BETWIXT_IO/src/main/java/org/apache/commons/scxml/env/jexl/JexlContext.java?rev=375066&r1=375065&r2=375066&view=diff
==============================================================================
--- jakarta/commons/sandbox/scxml/branches/BETWIXT_IO/src/main/java/org/apache/commons/scxml/env/jexl/JexlContext.java (original)
+++ jakarta/commons/sandbox/scxml/branches/BETWIXT_IO/src/main/java/org/apache/commons/scxml/env/jexl/JexlContext.java Sun Feb  5 10:04:50 2006
@@ -20,6 +20,7 @@
 import java.util.Map;
 
 import org.apache.commons.scxml.Builtin;
+import org.apache.commons.scxml.Context;
 import org.apache.commons.scxml.env.SimpleContext;
 
 /**
@@ -44,6 +45,16 @@
      */
     public JexlContext(final Map initialVars) {
         super(initialVars);
+        getVars().put("_builtin", new Builtin());
+    }
+
+    /**
+     * Constructor with parent context.
+     *
+     * @param parent The parent context.
+     */
+    public JexlContext(final Context parent) {
+        super(parent);
         getVars().put("_builtin", new Builtin());
     }
 

Modified: jakarta/commons/sandbox/scxml/branches/BETWIXT_IO/src/main/java/org/apache/commons/scxml/env/jexl/JexlEvaluator.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/scxml/branches/BETWIXT_IO/src/main/java/org/apache/commons/scxml/env/jexl/JexlEvaluator.java?rev=375066&r1=375065&r2=375066&view=diff
==============================================================================
--- jakarta/commons/sandbox/scxml/branches/BETWIXT_IO/src/main/java/org/apache/commons/scxml/env/jexl/JexlEvaluator.java (original)
+++ jakarta/commons/sandbox/scxml/branches/BETWIXT_IO/src/main/java/org/apache/commons/scxml/env/jexl/JexlEvaluator.java Sun Feb  5 10:04:50 2006
@@ -81,13 +81,7 @@
      * @see Evaluator#newContext(Context)
      */
     public Context newContext(final Context parent) {
-        //for now, we do not support nested variable contexts
-        //world is flat ;)
-        if (parent != null) {
-            return parent;
-        } else {
-            return new org.apache.commons.scxml.env.jexl.JexlContext();
-        }
+        return new org.apache.commons.scxml.env.jexl.JexlContext(parent);
     }
 
     /**

Modified: jakarta/commons/sandbox/scxml/branches/BETWIXT_IO/src/main/java/org/apache/commons/scxml/env/jsp/ELEvaluator.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/scxml/branches/BETWIXT_IO/src/main/java/org/apache/commons/scxml/env/jsp/ELEvaluator.java?rev=375066&r1=375065&r2=375066&view=diff
==============================================================================
--- jakarta/commons/sandbox/scxml/branches/BETWIXT_IO/src/main/java/org/apache/commons/scxml/env/jsp/ELEvaluator.java (original)
+++ jakarta/commons/sandbox/scxml/branches/BETWIXT_IO/src/main/java/org/apache/commons/scxml/env/jsp/ELEvaluator.java Sun Feb  5 10:04:50 2006
@@ -97,13 +97,7 @@
      * @see Evaluator#newContext(Context)
      */
     public Context newContext(final Context parent) {
-        //for now, we do not support nested variable contexts
-        //world is flat ;)
-        if (parent != null) {
-            return parent;
-        } else {
-            return new ELContext(null);
-        }
+        return new ELContext(parent);
     }
 
     /**

Modified: jakarta/commons/sandbox/scxml/branches/BETWIXT_IO/src/main/java/org/apache/commons/scxml/io/SCXMLDigester.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/scxml/branches/BETWIXT_IO/src/main/java/org/apache/commons/scxml/io/SCXMLDigester.java?rev=375066&r1=375065&r2=375066&view=diff
==============================================================================
--- jakarta/commons/sandbox/scxml/branches/BETWIXT_IO/src/main/java/org/apache/commons/scxml/io/SCXMLDigester.java (original)
+++ jakarta/commons/sandbox/scxml/branches/BETWIXT_IO/src/main/java/org/apache/commons/scxml/io/SCXMLDigester.java Sun Feb  5 10:04:50 2006
@@ -35,9 +35,6 @@
 import org.apache.commons.digester.SetPropertiesRule;
 import org.apache.commons.logging.LogFactory;
 
-import org.apache.commons.scxml.Context;
-import org.apache.commons.scxml.Evaluator;
-import org.apache.commons.scxml.NotificationRegistry;
 import org.apache.commons.scxml.PathResolver;
 import org.apache.commons.scxml.SCXMLHelper;
 import org.apache.commons.scxml.env.URLResolver;
@@ -91,27 +88,17 @@
      *            top level document are to be resovled against this URL).
      * @param errHandler
      *            The SAX ErrorHandler
-     * @param evalCtx
-     *            the document-level variable context for guard condition
-     *            evaluation
-     * @param evalEngine
-     *            the scripting/expression language engine for creating local
-     *            state-level variable contexts (if supported by a given
-     *            scripting engine)
      *
      * @return SCXML The SCXML object corresponding to the file argument
      *
      * @throws IOException Underlying Digester parsing threw an IOException
      * @throws SAXException Underlying Digester parsing threw a SAXException
      *
-     * @see Context
      * @see ErrorHandler
-     * @see Evaluator
      * @see PathResolver
      */
     public static SCXML digest(final URL scxmlURL,
-            final ErrorHandler errHandler, final Context evalCtx,
-            final Evaluator evalEngine)
+            final ErrorHandler errHandler)
     throws IOException, SAXException {
 
         SCXML scxml = null;
@@ -133,7 +120,7 @@
         }
 
         if (scxml != null) {
-            updateSCXML(scxml, evalCtx, evalEngine);
+            updateSCXML(scxml);
         }
 
         return scxml;
@@ -151,27 +138,17 @@
      *            SCXML document
      * @param errHandler
      *            The SAX ErrorHandler
-     * @param evalCtx
-     *            the document-level variable context for guard condition
-     *            evaluation
-     * @param evalEngine
-     *            the scripting/expression language engine for creating local
-     *            state-level variable contexts (if supported by a given
-     *            scripting engine)
      *
      * @return SCXML The SCXML object corresponding to the file argument
      *
      * @throws IOException Underlying Digester parsing threw an IOException
      * @throws SAXException Underlying Digester parsing threw a SAXException
      *
-     * @see Context
      * @see ErrorHandler
-     * @see Evaluator
      * @see PathResolver
      */
     public static SCXML digest(final String documentRealPath,
-            final ErrorHandler errHandler, final Context evalCtx,
-            final Evaluator evalEngine, final PathResolver pathResolver)
+            final ErrorHandler errHandler, final PathResolver pathResolver)
     throws IOException, SAXException {
 
         SCXML scxml = null;
@@ -192,7 +169,7 @@
         }
 
         if (scxml != null) {
-            updateSCXML(scxml, evalCtx, evalEngine);
+            updateSCXML(scxml);
         }
 
         return scxml;
@@ -214,26 +191,16 @@
      *            The InputSource for the SCXML document
      * @param errHandler
      *            The SAX ErrorHandler
-     * @param evalCtx
-     *            the document-level variable context for guard condition
-     *            evaluation
-     * @param evalEngine
-     *            the scripting/expression language engine for creating local
-     *            state-level variable contexts (if supported by a given
-     *            scripting engine)
      *
      * @return SCXML The SCXML object corresponding to the file argument
      *
      * @throws IOException Underlying Digester parsing threw an IOException
      * @throws SAXException Underlying Digester parsing threw a SAXException
      *
-     * @see Context
      * @see ErrorHandler
-     * @see Evaluator
      */
     public static SCXML digest(final InputSource documentInputSource,
-            final ErrorHandler errHandler, final Context evalCtx,
-            final Evaluator evalEngine)
+            final ErrorHandler errHandler)
     throws IOException, SAXException {
 
         Digester scxmlDigester = SCXMLDigester.newInstance(null, null);
@@ -250,7 +217,7 @@
         }
 
         if (scxml != null) {
-            updateSCXML(scxml, evalCtx, evalEngine);
+            updateSCXML(scxml);
         }
 
         return scxml;
@@ -285,12 +252,8 @@
       * document.</p>
       *
       * @param scxml The SCXML object (output from Digester)
-      * @param evalCtx The root evaluation context (from the host environment
-      *                of the SCXML document)
-      * @param evalEngine The expression evaluator
       */
-    public static void updateSCXML(final SCXML scxml, final Context evalCtx,
-            final Evaluator evalEngine) {
+    public static void updateSCXML(final SCXML scxml) {
         // Watch case, slightly unfortunate naming ;-)
         String initialstate = scxml.getInitialstate();
         //we have to use getTargets() here since the initialState can be
@@ -304,13 +267,11 @@
             logModelError(ERR_SCXML_NO_INIT, new Object[] {initialstate});
         }
         scxml.setInitialState(initialState);
-        scxml.setRootContext(evalCtx);
         Map targets = scxml.getTargets();
         Map states = scxml.getStates();
         Iterator i = states.keySet().iterator();
         while (i.hasNext()) {
-            updateState((State) states.get(i.next()), targets, evalCtx,
-                    evalEngine);
+            updateState((State) states.get(i.next()), targets);
         }
     }
 
@@ -776,25 +737,8 @@
       *
       * @param s The State object
       * @param targets The global Map of all transition targets
-      * @param evalCtx The evaluation context for this State
-      * @param evalEngine The expression evaluator
       */
-    private static void updateState(final State s, final Map targets,
-            final Context evalCtx, final Evaluator evalEngine) {
-        //setup local variable context
-        Context localCtx = null;
-        if (s.getParent() == null) {
-            localCtx = evalEngine.newContext(evalCtx);
-        } else {
-            State parentState = null;
-            if (s.getParent() instanceof Parallel) {
-                parentState = (State) (s.getParent().getParent());
-            } else {
-                parentState = (State) (s.getParent());
-            }
-            localCtx = evalEngine.newContext(parentState.getContext());
-        }
-        s.setContext(localCtx);
+    private static void updateState(final State s, final Map targets) {
         //ensure both onEntry and onExit have parent
         //could add next two lines as a Digester rule for OnEntry/OnExit
         s.getOnEntry().setParent(s);
@@ -802,13 +746,10 @@
         //initialize next / inital
         Initial ini = s.getInitial();
         Map c = s.getChildren();
-        String badState = "anonymous state";
-        if (!SCXMLHelper.isStringEmpty(s.getId())) {
-            badState = "state with ID " + s.getId();
-        }
         if (!c.isEmpty()) {
             if (ini == null) {
-                logModelError(ERR_STATE_NO_INIT, new Object[] {badState});
+                logModelError(ERR_STATE_NO_INIT,
+                    new Object[] {getStateName(s)});
             }
             Transition initialTransition = ini.getTransition();
             updateTransition(initialTransition, targets);
@@ -817,7 +758,8 @@
             //check that initialState is a descendant of s
             if (initialState == null
                     || !SCXMLHelper.isDescendant(initialState, s)) {
-                logModelError(ERR_STATE_BAD_INIT, new Object[] {badState});
+                logModelError(ERR_STATE_BAD_INIT,
+                    new Object[] {getStateName(s)});
             }
         }
         List histories = s.getHistory();
@@ -828,17 +770,18 @@
             updateTransition(historyTransition, targets);
             State historyState = (State) historyTransition.getTarget();
             if (historyState == null) {
-                logModelError(ERR_STATE_NO_HIST, new Object[] {badState});
+                logModelError(ERR_STATE_NO_HIST,
+                    new Object[] {getStateName(s)});
             }
             if (!h.isDeep()) {
                 if (!c.containsValue(historyState)) {
                     logModelError(ERR_STATE_BAD_SHALLOW_HIST, new Object[] {
-                        badState });
+                        getStateName(s) });
                 }
             } else {
                 if (!SCXMLHelper.isDescendant(historyState, s)) {
                     logModelError(ERR_STATE_BAD_DEEP_HIST, new Object[] {
-                        badState });
+                        getStateName(s) });
                 }
             }
         }
@@ -849,19 +792,17 @@
             while (j.hasNext()) {
                 Transition trn = (Transition) j.next();
                 //could add next two lines as a Digester rule for Transition
-                trn.setNotificationRegistry(s.getNotificationRegistry());
                 trn.setParent(s);
                 updateTransition(trn, targets);
             }
         }
         Parallel p = s.getParallel();
         if (p != null) {
-            updateParallel(p, targets, evalCtx, evalEngine);
+            updateParallel(p, targets);
         } else {
             Iterator j = c.keySet().iterator();
             while (j.hasNext()) {
-                updateState((State) c.get(j.next()), targets, evalCtx,
-                        evalEngine);
+                updateState((State) c.get(j.next()), targets);
             }
         }
     }
@@ -871,14 +812,11 @@
       *
       * @param p The Parallel object
       * @param targets The global Map of all transition targets
-      * @param evalCtx The evaluation context for this State
-      * @param evalEngine The expression evaluator
       */
-    private static void updateParallel(final Parallel p, final Map targets,
-            final Context evalCtx, final Evaluator evalEngine) {
+    private static void updateParallel(final Parallel p, final Map targets) {
         Iterator i = p.getStates().iterator();
         while (i.hasNext()) {
-            updateState((State) i.next(), targets, evalCtx, evalEngine);
+            updateState((State) i.next(), targets);
         }
     }
 
@@ -916,6 +854,22 @@
         log.error(errMsg);
     }
 
+     /**
+      * Get state identifier for error message. This method is only
+      * called to produce an appropriate log message in some error
+      * conditions.
+      *
+      * @param state The <code>State</code> object
+      * @return The state identifier for the error message
+      */
+    private static String getStateName(final State state) {
+        String badState = "anonymous state";
+        if (!SCXMLHelper.isStringEmpty(state.getId())) {
+            badState = "state with ID " + state.getId();
+        }
+        return badState;
+    }
+
     /**
      * Discourage instantiation since this is a utility class.
      */
@@ -955,10 +909,8 @@
                 scxml = (SCXML) getDigester()
                         .peek(getDigester().getCount() - 1);
             }
-            NotificationRegistry notifReg = scxml.getNotificationRegistry();
             TransitionTarget tt = (TransitionTarget) getDigester().peek();
             scxml.addTarget(tt);
-            tt.setNotificationRegistry(notifReg);
         }
     }
 

Modified: jakarta/commons/sandbox/scxml/branches/BETWIXT_IO/src/main/java/org/apache/commons/scxml/model/History.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/scxml/branches/BETWIXT_IO/src/main/java/org/apache/commons/scxml/model/History.java?rev=375066&r1=375065&r2=375066&view=diff
==============================================================================
--- jakarta/commons/sandbox/scxml/branches/BETWIXT_IO/src/main/java/org/apache/commons/scxml/model/History.java (original)
+++ jakarta/commons/sandbox/scxml/branches/BETWIXT_IO/src/main/java/org/apache/commons/scxml/model/History.java Sun Feb  5 10:04:50 2006
@@ -1,6 +1,6 @@
 /*
  *
- *   Copyright 2005 The Apache Software Foundation.
+ *   Copyright 2005-2006 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.
@@ -17,9 +17,6 @@
  */
 package org.apache.commons.scxml.model;
 
-import java.util.HashSet;
-import java.util.Set;
-
 /**
  * The class in this SCXML object model that corresponds to the
  * &lt;history&gt; SCXML pseudo state element.
@@ -40,12 +37,6 @@
     private Transition transition;
 
     /**
-     * The configuration when the parent of this pseudo state was last
-     * exited.
-     */
-    private Set lastConfiguration;
-
-    /**
      * Default no-args constructor for XML Digester.
      */
     public History() {
@@ -90,52 +81,6 @@
             isDeep = true;
         }
         //shallow is by default
-    }
-
-    /**
-     * Get the last configuration for this history.
-     *
-     * @return Returns the lastConfiguration.
-     */
-    public final Set getLastConfiguration() {
-        return lastConfiguration;
-    }
-
-    /**
-     * Set the last configuration for this history.
-     *
-     * @param lc The lastConfiguration to set.
-     */
-    public final void setLastConfiguration(final Set lc) {
-        if (lastConfiguration == null) {
-            lastConfiguration = new HashSet(lc.size());
-        } else {
-            lastConfiguration.clear();
-        }
-        lastConfiguration.addAll(lc);
-    }
-
-    /**
-     * Check whether we have prior history.
-     *
-     * @return Whether we have a non-empty last configuration
-     */
-    public final boolean isEmpty() {
-        if (lastConfiguration == null || lastConfiguration.isEmpty()) {
-            return true;
-        }
-        return false;
-    }
-
-    /**
-     * Resets the history state.
-     *
-     * @see org.apache.commons.scxml.SCXMLExecutor#reset()
-     */
-    public final void reset() {
-        if (lastConfiguration != null) {
-            lastConfiguration.clear();
-        }
     }
 
 }

Modified: jakarta/commons/sandbox/scxml/branches/BETWIXT_IO/src/main/java/org/apache/commons/scxml/model/SCXML.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/scxml/branches/BETWIXT_IO/src/main/java/org/apache/commons/scxml/model/SCXML.java?rev=375066&r1=375065&r2=375066&view=diff
==============================================================================
--- jakarta/commons/sandbox/scxml/branches/BETWIXT_IO/src/main/java/org/apache/commons/scxml/model/SCXML.java (original)
+++ jakarta/commons/sandbox/scxml/branches/BETWIXT_IO/src/main/java/org/apache/commons/scxml/model/SCXML.java Sun Feb  5 10:04:50 2006
@@ -1,6 +1,6 @@
 /*
  *
- *   Copyright 2005 The Apache Software Foundation.
+ *   Copyright 2005-2006 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.
@@ -17,24 +17,18 @@
  */
 package org.apache.commons.scxml.model;
 
-import org.apache.commons.scxml.Context;
-import org.apache.commons.scxml.NotificationRegistry;
-import org.apache.commons.scxml.Observable;
-import org.apache.commons.scxml.SCXMLHelper;
-import org.apache.commons.scxml.SCXMLListener;
-
 import java.util.HashMap;
 import java.util.Map;
 
+import org.apache.commons.scxml.SCXMLHelper;
+
 /**
  * The class in this SCXML object model that corresponds to the
  * &lt;scxml&gt; root element, and serves as the &quot;document
- * root&quot;. It is also associated with the root Context, via which
- * the SCXMLExecutor may access and the query state of the host
- * environment.
+ * root&quot;.
  *
  */
-public class SCXML implements Observable {
+public class SCXML {
 
     /**
      * The SCXML XMLNS.
@@ -68,27 +62,16 @@
     private Map states;
 
     /**
-     * The notification registry.
-     */
-    private NotificationRegistry notifReg;
-
-    /**
      * A global map of all States and Parallels associated with this
      * state machine, keyed by their id.
      */
     private Map targets;
 
     /**
-     * The root Context which interfaces with the host environment.
-     */
-    private Context rootContext;
-
-    /**
      * Constructor.
      */
     public SCXML() {
         this.states = new HashMap();
-        this.notifReg = new NotificationRegistry();
         this.targets = new HashMap();
     }
 
@@ -188,15 +171,6 @@
     }
 
     /**
-     * Get the notification registry.
-     *
-     * @return NotificationRegistry Returns the notifReg.
-     */
-    public final NotificationRegistry getNotificationRegistry() {
-        return notifReg;
-    }
-
-    /**
      * Get the ID of the initial state.
      *
      * @return String Returns the initial state ID (used by XML Digester only).
@@ -214,44 +188,6 @@
      */
     public final void setInitialstate(final String initialstate) {
         this.initialstate = initialstate;
-    }
-
-    /**
-     * Get the root Context for this document.
-     *
-     * @return Returns the rootContext.
-     */
-    public final Context getRootContext() {
-        return rootContext;
-    }
-
-    /**
-     * Set the root Context for this document.
-     *
-     * @param rootContext The rootContext to set.
-     */
-    public final void setRootContext(final Context rootContext) {
-        this.rootContext = rootContext;
-    }
-
-    /**
-     * Register a listener to this document root.
-     *
-     * @param lst The SCXMLListener to add
-     * Remarks: Only valid if StateMachine is non null!
-     */
-    public final void addListener(final SCXMLListener lst) {
-        notifReg.addListener(this, lst);
-    }
-
-    /**
-     * Deregister a listener from this document root.
-     *
-     * @param lst The SCXMLListener to remove
-     * Remarks: Only valid if StateMachine is non null!
-     */
-    public final void removeListener(final SCXMLListener lst) {
-        notifReg.removeListener(this, lst);
     }
 
 }

Modified: jakarta/commons/sandbox/scxml/branches/BETWIXT_IO/src/main/java/org/apache/commons/scxml/model/State.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/scxml/branches/BETWIXT_IO/src/main/java/org/apache/commons/scxml/model/State.java?rev=375066&r1=375065&r2=375066&view=diff
==============================================================================
--- jakarta/commons/sandbox/scxml/branches/BETWIXT_IO/src/main/java/org/apache/commons/scxml/model/State.java (original)
+++ jakarta/commons/sandbox/scxml/branches/BETWIXT_IO/src/main/java/org/apache/commons/scxml/model/State.java Sun Feb  5 10:04:50 2006
@@ -1,6 +1,6 @@
 /*
  *
- *   Copyright 2005 The Apache Software Foundation.
+ *   Copyright 2005-2006 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.
@@ -23,8 +23,6 @@
 import java.util.List;
 import java.util.Map;
 
-import org.apache.commons.scxml.Context;
-
 /**
  * The class in this SCXML object model that corresponds to the
  * &lt;state&gt; SCXML element.
@@ -33,11 +31,6 @@
 public class State extends TransitionTarget {
 
     /**
-     * The Context in which any expressions will be evaluated.
-     */
-    private Context context;
-
-    /**
      * The Map containing immediate children of this State, keyed by
      * their IDs. Incompatible with the parallel property.
      */
@@ -87,25 +80,6 @@
         this.children = new HashMap();
         this.transitions = new HashMap();
         this.history = new ArrayList();
-    }
-
-    /**
-     * Get the Context.
-     *
-     * @return Context Returns the context.
-     */
-    public final Context getContext() {
-        return context;
-    }
-
-    /**
-     * Set the Context.
-     *
-     * @param context
-     *            The context to set.
-     */
-    public final void setContext(final Context context) {
-        this.context = context;
     }
 
     /**

Modified: jakarta/commons/sandbox/scxml/branches/BETWIXT_IO/src/main/java/org/apache/commons/scxml/model/Transition.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/scxml/branches/BETWIXT_IO/src/main/java/org/apache/commons/scxml/model/Transition.java?rev=375066&r1=375065&r2=375066&view=diff
==============================================================================
--- jakarta/commons/sandbox/scxml/branches/BETWIXT_IO/src/main/java/org/apache/commons/scxml/model/Transition.java (original)
+++ jakarta/commons/sandbox/scxml/branches/BETWIXT_IO/src/main/java/org/apache/commons/scxml/model/Transition.java Sun Feb  5 10:04:50 2006
@@ -1,6 +1,6 @@
 /*
  *
- *   Copyright 2005 The Apache Software Foundation.
+ *   Copyright 2005-2006 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.
@@ -17,10 +17,6 @@
  */
 package org.apache.commons.scxml.model;
 
-import org.apache.commons.scxml.NotificationRegistry;
-import org.apache.commons.scxml.Observable;
-import org.apache.commons.scxml.SCXMLListener;
-
 /**
  * The class in this SCXML object model that corresponds to the
  * &lt;transition&gt; SCXML element. Transition rules are triggered
@@ -28,7 +24,7 @@
  * &quot;guard-conditions&quot;.
  *
  */
-public class Transition extends Executable implements Observable {
+public class Transition extends Executable {
 
     /**
      * Property that specifies the trigger for this transition.
@@ -52,11 +48,6 @@
     private String next;
 
     /**
-     * The notification registry.
-     */
-    private NotificationRegistry notifReg;
-
-    /**
      * The path for this transition.
      * @see Path
      */
@@ -68,29 +59,10 @@
     public Transition() {
         super();
         this.target = null;
-        this.notifReg = null;
         this.path = null;
     }
 
     /**
-     * Register a listener to this document root.
-     *
-     * @param lst The SCXMLListener to add
-     */
-    public final void addListener(final SCXMLListener lst) {
-        notifReg.addListener(this, lst);
-    }
-
-    /**
-     * Deregister a listener from this document root.
-     *
-     * @param lst The SCXMLListener to remove
-     */
-    public final void removeListener(final SCXMLListener lst) {
-        notifReg.removeListener(this, lst);
-    }
-
-    /**
      * Get the guard condition (may be null).
      *
      * @return Returns the cond.
@@ -185,25 +157,6 @@
      */
     public final void setNext(final String next) {
         this.next = next;
-    }
-
-    /**
-     * Supply this Transition object a handle to the notification
-     * registry. Called by the Digester after instantiation.
-     *
-     * @param reg The notification registry
-     */
-    public final void setNotificationRegistry(final NotificationRegistry reg) {
-        notifReg = reg;
-    }
-
-    /**
-     * Get the notification registry.
-     *
-     * @return NotificationRegistry The notification registry.
-     */
-    public final NotificationRegistry getNotificationRegistry() {
-        return notifReg;
     }
 
     /**

Modified: jakarta/commons/sandbox/scxml/branches/BETWIXT_IO/src/main/java/org/apache/commons/scxml/model/TransitionTarget.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/scxml/branches/BETWIXT_IO/src/main/java/org/apache/commons/scxml/model/TransitionTarget.java?rev=375066&r1=375065&r2=375066&view=diff
==============================================================================
--- jakarta/commons/sandbox/scxml/branches/BETWIXT_IO/src/main/java/org/apache/commons/scxml/model/TransitionTarget.java (original)
+++ jakarta/commons/sandbox/scxml/branches/BETWIXT_IO/src/main/java/org/apache/commons/scxml/model/TransitionTarget.java Sun Feb  5 10:04:50 2006
@@ -1,6 +1,6 @@
 /*
  *
- *   Copyright 2005 The Apache Software Foundation.
+ *   Copyright 2005-2006 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.
@@ -17,16 +17,12 @@
  */
 package org.apache.commons.scxml.model;
 
-import org.apache.commons.scxml.NotificationRegistry;
-import org.apache.commons.scxml.Observable;
-import org.apache.commons.scxml.SCXMLListener;
-
 /**
  * An abstract base class for elements in SCXML that can serve as a
  * &lt;target&gt; for a &lt;transition&gt;, such as State or Parallel.
  *
  */
-public abstract class TransitionTarget implements Observable {
+public abstract class TransitionTarget {
 
     /**
      * Identifier for this transition target. Other parts of the SCXML
@@ -53,11 +49,6 @@
     private TransitionTarget parent;
 
     /**
-     * The notification registry.
-     */
-    private NotificationRegistry notifReg;
-
-    /**
      * Constructor.
      */
     public TransitionTarget() {
@@ -67,44 +58,6 @@
         onExit = new OnExit();   //empty defaults
         onExit.setParent(this);
         parent = null;
-        notifReg = null;
-    }
-
-    /**
-     * Register a listener to this document root.
-     *
-     * @param lst The SCXMLListener to add
-     */
-    public final void addListener(final SCXMLListener lst) {
-        notifReg.addListener(this, lst);
-    }
-
-    /**
-     * Deregister a listener from this document root.
-     *
-     * @param lst The SCXMLListener to remove
-     */
-    public final void removeListener(final SCXMLListener lst) {
-        notifReg.removeListener(this, lst);
-    }
-
-    /**
-     * Supply this TransitionTarget object a handle to the notification
-     * registry. Called by the Digester after instantiation.
-     *
-     * @param reg The notification registry
-     */
-    public final void setNotificationRegistry(final NotificationRegistry reg) {
-        notifReg = reg;
-    }
-
-    /**
-     * Get the notification registry.
-     *
-     * @return The notification registry.
-     */
-    public final NotificationRegistry getNotificationRegistry() {
-        return notifReg;
     }
 
     /**

Modified: jakarta/commons/sandbox/scxml/branches/BETWIXT_IO/src/main/java/org/apache/commons/scxml/semantics/SCXMLSemanticsImpl.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/scxml/branches/BETWIXT_IO/src/main/java/org/apache/commons/scxml/semantics/SCXMLSemanticsImpl.java?rev=375066&r1=375065&r2=375066&view=diff
==============================================================================
--- jakarta/commons/sandbox/scxml/branches/BETWIXT_IO/src/main/java/org/apache/commons/scxml/semantics/SCXMLSemanticsImpl.java (original)
+++ jakarta/commons/sandbox/scxml/branches/BETWIXT_IO/src/main/java/org/apache/commons/scxml/semantics/SCXMLSemanticsImpl.java Sun Feb  5 10:04:50 2006
@@ -1,6 +1,6 @@
 /*
  *
- *   Copyright 2005 The Apache Software Foundation.
+ *   Copyright 2005-2006 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.
@@ -36,6 +36,7 @@
 import org.apache.commons.scxml.Evaluator;
 import org.apache.commons.scxml.EventDispatcher;
 import org.apache.commons.scxml.NotificationRegistry;
+import org.apache.commons.scxml.SCInstance;
 import org.apache.commons.scxml.SCXMLExpressionException;
 import org.apache.commons.scxml.SCXMLHelper;
 import org.apache.commons.scxml.SCXMLSemantics;
@@ -107,11 +108,14 @@
      *            a list of States and Parallels to enter [out]
      * @param errRep
      *            ErrorReporter callback [inout]
+     * @param scInstance
+     *            The state chart instance [in]
      * @throws ModelException
      *             in case there is a fatal SCXML object model problem.
      */
     public void determineInitialStates(final SCXML input, final Set states,
-            final List entryList, final ErrorReporter errRep)
+            final List entryList, final ErrorReporter errRep,
+            final SCInstance scInstance)
             throws ModelException {
         State tmp = input.getInitialState();
         if (tmp == null) {
@@ -119,7 +123,7 @@
                     "SCXML initialstate is missing!", input);
         } else {
             states.add(tmp);
-            determineTargetStates(states, errRep);
+            determineTargetStates(states, errRep, scInstance);
             //set of ALL entered states (even if initialState is a jump-over)
             Set onEntry = SCXMLHelper.getAncestorClosure(states, null);
             // sort onEntry according state hierarchy
@@ -139,12 +143,12 @@
      *            a list of actions to execute [in]
      * @param derivedEvents
      *            collection of internal events generated by the actions [out]
-     * @param eval
-     *            the expression evaluator - Evaluator instance
      * @param evtDispatcher
      *            the event dispatcher - EventDispatcher instance
      * @param errRep
      *            ErrorReporter callback [inout]
+     * @param scInstance
+     *            The state chart instance [inout]
      * @throws ModelException
      *             in case there is a fatal SCXML object model problem
      * @throws SCXMLExpressionException
@@ -157,16 +161,18 @@
      * @see Evaluator
      */
     public void executeActionList(final List actions,
-            final Collection derivedEvents, final Evaluator eval,
-            final EventDispatcher evtDispatcher, final ErrorReporter errRep)
-            throws ModelException, SCXMLExpressionException {
+            final Collection derivedEvents,
+            final EventDispatcher evtDispatcher, final ErrorReporter errRep,
+            final SCInstance scInstance)
+    throws ModelException, SCXMLExpressionException {
+        Evaluator eval = scInstance.getEvaluator();
         // NOTE: "if" statement is a container - we may need to call this method
         // recursively and pass a sub-list of actions embedded in a particular
         // "if"
         for (Iterator i = actions.iterator(); i.hasNext();) {
             Action a = (Action) i.next();
             State parentState = a.getParentState();
-            Context ctx = parentState.getContext();
+            Context ctx = scInstance.getContext(parentState);
             // NOTE: "elseif" and "else" do not appear here, since they are
             // always handled as a part of "if" as a container
             if (a instanceof Assign) {
@@ -219,8 +225,8 @@
                     }
                 }
                 if (!todoList.isEmpty()) {
-                    executeActionList(todoList, derivedEvents, eval,
-                        evtDispatcher, errRep);
+                    executeActionList(todoList, derivedEvents, evtDispatcher,
+                        errRep, scInstance);
                 }
                 todoList.clear();
             } else if (a instanceof Log) {
@@ -285,27 +291,28 @@
      *            updated its AfterStatus/Events
      * @param stateMachine
      *            state machine - SCXML instance
-     * @param eval
-     *            the expression evaluator - Evaluator instance
      * @param evtDispatcher
      *            the event dispatcher - EventDispatcher instance
      * @param errRep
      *            error reporter
+     * @param scInstance
+     *            The state chart instance
      * @throws ModelException
      *             in case there is a fatal SCXML object model problem.
      */
     public void executeActions(final Step step, final SCXML stateMachine,
-            final Evaluator eval, final EventDispatcher evtDispatcher,
-            final ErrorReporter errRep) throws ModelException {
-        NotificationRegistry nr = stateMachine.getNotificationRegistry();
+            final EventDispatcher evtDispatcher,
+            final ErrorReporter errRep, final SCInstance scInstance)
+    throws ModelException {
+        NotificationRegistry nr = scInstance.getNotificationRegistry();
         Collection internalEvents = step.getAfterStatus().getEvents();
         // ExecutePhaseActions / OnExit
         for (Iterator i = step.getExitList().iterator(); i.hasNext();) {
             TransitionTarget tt = (TransitionTarget) i.next();
             OnExit oe = tt.getOnExit();
             try {
-                executeActionList(oe.getActions(), internalEvents, eval,
-                    evtDispatcher, errRep);
+                executeActionList(oe.getActions(), internalEvents,
+                    evtDispatcher, errRep, scInstance);
             } catch (SCXMLExpressionException e) {
                 errRep.onError(ErrorReporter.EXPRESSION_ERROR, e.getMessage(),
                         oe);
@@ -320,8 +327,8 @@
         for (Iterator i = step.getTransitList().iterator(); i.hasNext();) {
             Transition t = (Transition) i.next();
             try {
-                executeActionList(t.getActions(), internalEvents, eval,
-                    evtDispatcher, errRep);
+                executeActionList(t.getActions(), internalEvents,
+                    evtDispatcher, errRep, scInstance);
             } catch (SCXMLExpressionException e) {
                 errRep.onError(ErrorReporter.EXPRESSION_ERROR,
                     e.getMessage(), t);
@@ -335,8 +342,8 @@
             TransitionTarget tt = (TransitionTarget) i.next();
             OnEntry oe = tt.getOnEntry();
             try {
-                executeActionList(oe.getActions(), internalEvents, eval,
-                    evtDispatcher, errRep);
+                executeActionList(oe.getActions(), internalEvents,
+                    evtDispatcher, errRep, scInstance);
             } catch (SCXMLExpressionException e) {
                 errRep.onError(ErrorReporter.EXPRESSION_ERROR, e.getMessage(),
                         oe);
@@ -431,13 +438,13 @@
     /**
      * @param step
      *            [inout]
-     * @param evaluator
-     *            guard condition evaluator
      * @param errRep
      *            ErrorReporter callback [inout]
+     * @param scInstance
+     *            The state chart instance [in]
      */
     public void filterTransitionsSet(final Step step,
-            final Evaluator evaluator, final ErrorReporter errRep) {
+            final ErrorReporter errRep, final SCInstance scInstance) {
         /*
          * - filter transition set by applying events
          * (step/beforeStatus/events + step/externalEvents) (local check)
@@ -479,8 +486,8 @@
                 rslt = Boolean.TRUE;
             } else {
                 try {
-                    rslt = evaluator.evalCond(((State) t.getParent())
-                            .getContext(), t.getCond());
+                    rslt = scInstance.getEvaluator().evalCond(scInstance.
+                            getContext(t.getParent()), t.getCond());
                 } catch (SCXMLExpressionException e) {
                     rslt = Boolean.FALSE;
                     errRep.onError(ErrorReporter.EXPRESSION_ERROR, e
@@ -597,11 +604,14 @@
      *            a set seeded in previous step [inout]
      * @param errRep
      *            ErrorReporter callback [inout]
+     * @param scInstance
+     *            The state chart instance [in]
      * @throws ModelException On illegal configuration
      * @see #seedTargetSet(Set, List, ErrorReporter)
      */
     public void determineTargetStates(final Set states,
-            final ErrorReporter errRep) throws ModelException {
+            final ErrorReporter errRep, final SCInstance scInstance)
+    throws ModelException {
         LinkedList wrkSet = new LinkedList(states);
         // clear the seed-set - will be populated by leaf states
         states.clear();
@@ -653,10 +663,10 @@
                 }
             } else if (tt instanceof History) {
                 History h = (History) tt;
-                if (h.isEmpty()) {
+                if (scInstance.isEmpty(h)) {
                     wrkSet.addLast(h.getTransition().getRuntimeTarget());
                 } else {
-                    wrkSet.addAll(h.getLastConfiguration());
+                    wrkSet.addAll(scInstance.getLastConfiguration(h));
                 }
             } else {
                 throw new ModelException("Unknown TransitionTarget subclass:"
@@ -673,9 +683,11 @@
      *            [inout]
      * @param errRep
      *            ErrorReporter callback [inout]
+     * @param scInstance
+     *            The state chart instance [inout]
      */
     public void updateHistoryStates(final Step step,
-            final ErrorReporter errRep) {
+            final ErrorReporter errRep, final SCInstance scInstance) {
         Set oldState = step.getBeforeStatus().getStates();
         for (Iterator i = step.getExitList().iterator(); i.hasNext();) {
             Object o = i.next();
@@ -699,7 +711,7 @@
                                     }
                                 }
                             }
-                            h.setLastConfiguration(deep);
+                            scInstance.setLastConfiguration(h, deep);
                         } else {
                             if (shallow == null) {
                                 //calculate shallow history for a given state
@@ -709,7 +721,7 @@
                                 shallow.retainAll(SCXMLHelper
                                         .getAncestorClosure(oldState, null));
                             }
-                            h.setLastConfiguration(shallow);
+                            scInstance.setLastConfiguration(h, shallow);
                         }
                     }
                     shallow = null;
@@ -755,12 +767,14 @@
      *
      * @param step The current Step
      * @param errorReporter The ErrorReporter for the current environment
+     * @param scInstance The state chart instance
      *
      * @throws ModelException
      *             in case there is a fatal SCXML object model problem.
      */
     public void followTransitions(final Step step,
-            final ErrorReporter errorReporter) throws ModelException {
+            final ErrorReporter errorReporter, final SCInstance scInstance)
+    throws ModelException {
         Set currentStates = step.getBeforeStatus().getStates();
         List transitions = step.getTransitList();
         // DetermineExitedStates (currentStates, transitList) -> exitedStates
@@ -778,7 +792,7 @@
         // DetermineTargetStates (initialTargetSet) -> targetSet
         Set targetSet = step.getAfterStatus().getStates();
         targetSet.addAll(seedSet); //copy to preserve seedSet
-        determineTargetStates(targetSet, errorReporter);
+        determineTargetStates(targetSet, errorReporter, scInstance);
         // BuildOnEntryList (targetSet, seedSet) -> entryList
         Set entered = SCXMLHelper.getAncestorClosure(targetSet, seedSet);
         seedSet.clear();

Modified: jakarta/commons/sandbox/scxml/branches/BETWIXT_IO/src/main/java/org/apache/commons/scxml/test/StandaloneUtils.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/scxml/branches/BETWIXT_IO/src/main/java/org/apache/commons/scxml/test/StandaloneUtils.java?rev=375066&r1=375065&r2=375066&view=diff
==============================================================================
--- jakarta/commons/sandbox/scxml/branches/BETWIXT_IO/src/main/java/org/apache/commons/scxml/test/StandaloneUtils.java (original)
+++ jakarta/commons/sandbox/scxml/branches/BETWIXT_IO/src/main/java/org/apache/commons/scxml/test/StandaloneUtils.java Sun Feb  5 10:04:50 2006
@@ -77,8 +77,7 @@
             Context rootCtx = evaluator.newContext(null);
             EventDispatcher ed = new SimpleDispatcher();
             Tracer trc = new Tracer();
-            SCXML doc = SCXMLDigester.digest(new URL(documentURI), trc,
-                rootCtx, evaluator);
+            SCXML doc = SCXMLDigester.digest(new URL(documentURI), trc);
             if (doc == null) {
                 System.err.println("The SCXML document " + uri
                         + " can not be parsed!");
@@ -86,9 +85,11 @@
             }
             System.out.println(SCXMLSerializer.serialize(doc));
             SCXMLExecutor exec = new SCXMLExecutor(evaluator, ed, trc);
-            doc.addListener(trc);
+            exec.addListener(doc, trc);
             exec.setSuperStep(true);
+            exec.setRootContext(rootCtx);
             exec.setStateMachine(doc);
+            exec.go();
             BufferedReader br = new BufferedReader(new
                 InputStreamReader(System.in));
             String event = null;

Modified: jakarta/commons/sandbox/scxml/branches/BETWIXT_IO/src/test/java/org/apache/commons/scxml/SCXMLTestHelper.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/scxml/branches/BETWIXT_IO/src/test/java/org/apache/commons/scxml/SCXMLTestHelper.java?rev=375066&r1=375065&r2=375066&view=diff
==============================================================================
--- jakarta/commons/sandbox/scxml/branches/BETWIXT_IO/src/test/java/org/apache/commons/scxml/SCXMLTestHelper.java (original)
+++ jakarta/commons/sandbox/scxml/branches/BETWIXT_IO/src/test/java/org/apache/commons/scxml/SCXMLTestHelper.java Sun Feb  5 10:04:50 2006
@@ -19,12 +19,13 @@
 
 import junit.framework.Assert;
 
-import org.apache.commons.scxml.env.jsp.ELEvaluator;
-import org.apache.commons.scxml.env.jsp.ELContext;
 import org.apache.commons.scxml.env.SimpleDispatcher;
 import org.apache.commons.scxml.env.Tracer;
+import org.apache.commons.scxml.env.jexl.JexlContext;
+import org.apache.commons.scxml.env.jexl.JexlEvaluator;
 import org.apache.commons.scxml.io.SCXMLDigester;
 import org.apache.commons.scxml.model.SCXML;
+import org.apache.commons.scxml.model.TransitionTarget;
 
 import org.xml.sax.ErrorHandler;
 /**
@@ -33,25 +34,15 @@
 public class SCXMLTestHelper {
 
     public static SCXML digest(final URL url) {
-        Evaluator evaluator = new ELEvaluator();
-        Context ctx = new ELContext();
-        return digest(url, null, ctx, evaluator);
+        return digest(url, null);
     }
 
-    public static SCXML digest(final URL url, final Context ctx,
-            final Evaluator evaluator) {
-        return digest(url, null, ctx, evaluator);
-    }
-
-    public static SCXML digest(final URL url, final ErrorHandler errHandler,
-            final Context ctx, final Evaluator evaluator) {
+    public static SCXML digest(final URL url, final ErrorHandler errHandler) {
         Assert.assertNotNull(url);
-        Assert.assertNotNull(ctx);
         // SAX ErrorHandler may be null
-        Assert.assertNotNull(evaluator);
         SCXML scxml = null;
         try {
-            scxml = SCXMLDigester.digest(url, errHandler, ctx, evaluator);
+            scxml = SCXMLDigester.digest(url, errHandler);
         } catch (Exception e) {
             Assert.fail(e.getMessage());
         }
@@ -60,48 +51,78 @@
     }
 
     public static SCXMLExecutor getExecutor(final URL url) {
-        Evaluator evaluator = new ELEvaluator();
-        Context ctx = new ELContext();
-        SCXML scxml = digest(url, null, ctx, evaluator);
+        SCXML scxml = digest(url, null);
+        Evaluator evaluator = new JexlEvaluator();
         return getExecutor(evaluator, scxml);
     }
 
-    public static SCXMLExecutor getExecutor(final URL url, final Context ctx,
+    public static SCXMLExecutor getExecutor(final URL url,
             final Evaluator evaluator) {
-        SCXML scxml = digest(url, null, ctx, evaluator);
+        SCXML scxml = digest(url, null);
         return getExecutor(evaluator, scxml);
     }
 
     public static SCXMLExecutor getExecutor(final URL url,
-            final ErrorHandler errHandler,final Context ctx,
-            final Evaluator evaluator) {
-        SCXML scxml = digest(url, errHandler, ctx, evaluator);
+            final ErrorHandler errHandler) {
+        SCXML scxml = digest(url, errHandler);
+        Evaluator evaluator = new JexlEvaluator();
         return getExecutor(evaluator, scxml);
     }
 
     public static SCXMLExecutor getExecutor(Evaluator evaluator, SCXML scxml) {
         EventDispatcher ed = new SimpleDispatcher();
         Tracer trc = new Tracer();
-        return getExecutor(evaluator, scxml, ed, trc);
+        Context context = new JexlContext();
+        return getExecutor(context, evaluator, scxml, ed, trc);
+    }
+
+    public static SCXMLExecutor getExecutor(final URL url, final Context ctx,
+            final Evaluator evaluator) {
+        SCXML scxml = digest(url, null);
+        EventDispatcher ed = new SimpleDispatcher();
+        Tracer trc = new Tracer();
+        return getExecutor(ctx, evaluator, scxml, ed, trc);
     }
 
-    public static SCXMLExecutor getExecutor(Evaluator evaluator, SCXML scxml,
-            EventDispatcher ed, Tracer trc) {
+    public static SCXMLExecutor getExecutor(Context context,
+            Evaluator evaluator, SCXML scxml, EventDispatcher ed, Tracer trc) {
         Assert.assertNotNull(evaluator);
+        Assert.assertNotNull(context);
         Assert.assertNotNull(scxml);
         Assert.assertNotNull(ed);
         Assert.assertNotNull(trc);
         SCXMLExecutor exec = null;
         try {
             exec = new SCXMLExecutor(evaluator, ed, trc);
-            scxml.addListener(trc);
+            exec.addListener(scxml, trc);
+            exec.setRootContext(context);
             exec.setSuperStep(true);
             exec.setStateMachine(scxml);
+            exec.go();
         } catch (Exception e) {
             Assert.fail(e.getMessage());
         }
         Assert.assertNotNull(exec);
         return exec;
+    }
+
+    public static TransitionTarget lookupTransitionTarget(SCXMLExecutor exec,
+            String id) {
+        return (TransitionTarget) exec.getStateMachine().getTargets().get(id);
+    }
+
+    public static Context lookupContext(SCXMLExecutor exec,
+            TransitionTarget tt) {
+        return exec.getSCInstance().lookupContext(tt);
+    }
+
+    public static Context lookupContext(SCXMLExecutor exec,
+            String id) {
+        TransitionTarget tt = lookupTransitionTarget(exec, id);
+        if (tt == null) {
+            return null;
+        }
+        return exec.getSCInstance().lookupContext(tt);
     }
 
     /**

Modified: jakarta/commons/sandbox/scxml/branches/BETWIXT_IO/src/test/java/org/apache/commons/scxml/SCXMLTestSuite.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/scxml/branches/BETWIXT_IO/src/test/java/org/apache/commons/scxml/SCXMLTestSuite.java?rev=375066&r1=375065&r2=375066&view=diff
==============================================================================
--- jakarta/commons/sandbox/scxml/branches/BETWIXT_IO/src/test/java/org/apache/commons/scxml/SCXMLTestSuite.java (original)
+++ jakarta/commons/sandbox/scxml/branches/BETWIXT_IO/src/test/java/org/apache/commons/scxml/SCXMLTestSuite.java Sun Feb  5 10:04:50 2006
@@ -1,5 +1,5 @@
 /*
- * Copyright 2005 The Apache Software Foundation.
+ * Copyright 2005-2006 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.
@@ -48,6 +48,9 @@
         suite.setName("Commons-SCXML Tests");
         suite.addTest(SCXMLDigesterTest.suite());
         suite.addTest(SCXMLExecutorTest.suite());
+        suite.addTest(TestBuiltin.suite());
+        suite.addTest(TestSCXMLHelper.suite());
+        suite.addTest(TestStatus.suite());
         suite.addTest(TriggerEventTest.suite());
         return suite;
     }

Modified: jakarta/commons/sandbox/scxml/branches/BETWIXT_IO/src/test/java/org/apache/commons/scxml/env/EnvTestSuite.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/scxml/branches/BETWIXT_IO/src/test/java/org/apache/commons/scxml/env/EnvTestSuite.java?rev=375066&r1=375065&r2=375066&view=diff
==============================================================================
--- jakarta/commons/sandbox/scxml/branches/BETWIXT_IO/src/test/java/org/apache/commons/scxml/env/EnvTestSuite.java (original)
+++ jakarta/commons/sandbox/scxml/branches/BETWIXT_IO/src/test/java/org/apache/commons/scxml/env/EnvTestSuite.java Sun Feb  5 10:04:50 2006
@@ -1,5 +1,5 @@
 /*
- * Copyright 2005 The Apache Software Foundation.
+ * Copyright 2005-2006 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.
@@ -47,6 +47,8 @@
     public static Test suite() {
         TestSuite suite = new TestSuite();
         suite.setName("Commons-SCXML Environments Tests");
+        suite.addTest(TestLogUtils.suite());
+        suite.addTest(TestSimpleContext.suite());
         return suite;
     }
 }

Modified: jakarta/commons/sandbox/scxml/branches/BETWIXT_IO/src/test/java/org/apache/commons/scxml/env/jsp/RootContextTest.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/scxml/branches/BETWIXT_IO/src/test/java/org/apache/commons/scxml/env/jsp/RootContextTest.java?rev=375066&r1=375065&r2=375066&view=diff
==============================================================================
--- jakarta/commons/sandbox/scxml/branches/BETWIXT_IO/src/test/java/org/apache/commons/scxml/env/jsp/RootContextTest.java (original)
+++ jakarta/commons/sandbox/scxml/branches/BETWIXT_IO/src/test/java/org/apache/commons/scxml/env/jsp/RootContextTest.java Sun Feb  5 10:04:50 2006
@@ -49,7 +49,7 @@
     private URL rootCtxSample;
     private ELEvaluator evaluator;
     private JspContext jspCtx;
-    private RootContext ctx;
+    private RootContext rootCtx;
     private SCXMLExecutor exec;
 
     /**
@@ -61,7 +61,7 @@
         evaluator = new ELEvaluator();
         jspCtx = new MockJspContext();
         jspCtx.setAttribute("foo", "1");
-        ctx = new RootContext(jspCtx);
+        rootCtx = new RootContext(jspCtx);
     }
 
     /**
@@ -71,7 +71,7 @@
         rootCtxSample = null;
         evaluator = null;
         jspCtx = null;
-        ctx = null;
+        rootCtx = null;
         exec = null;
     }
 
@@ -79,11 +79,14 @@
      * Test the implementation
      */
     public void testRootContext() {
-        assertEquals("1", String.valueOf(ctx.get("foo")));
-        exec = SCXMLTestHelper.getExecutor(rootCtxSample, ctx, evaluator);
+        assertEquals("1", String.valueOf(rootCtx.get("foo")));
+        exec = SCXMLTestHelper.getExecutor(rootCtxSample, rootCtx, evaluator);
         assertEquals("1", String.valueOf(jspCtx.getAttribute("foo")));
-        assertEquals("2", String.valueOf(ctx.get("foo")));
+        assertEquals("2", String.valueOf(rootCtx.get("foo")));
         assertNull(jspCtx.getAttribute("bar"));
+        ELContext ctx = (ELContext) SCXMLTestHelper.lookupContext(exec,
+            "rootCtxTest");
+        assertNotNull(ctx);
         assertNotNull(ctx.get("bar"));
         try {
             assertNull(jspCtx.getVariableResolver().resolveVariable("bar"));

Modified: jakarta/commons/sandbox/scxml/branches/BETWIXT_IO/src/test/java/org/apache/commons/scxml/io/IOTestSuite.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/scxml/branches/BETWIXT_IO/src/test/java/org/apache/commons/scxml/io/IOTestSuite.java?rev=375066&r1=375065&r2=375066&view=diff
==============================================================================
--- jakarta/commons/sandbox/scxml/branches/BETWIXT_IO/src/test/java/org/apache/commons/scxml/io/IOTestSuite.java (original)
+++ jakarta/commons/sandbox/scxml/branches/BETWIXT_IO/src/test/java/org/apache/commons/scxml/io/IOTestSuite.java Sun Feb  5 10:04:50 2006
@@ -47,6 +47,7 @@
     public static Test suite() {
         TestSuite suite = new TestSuite();
         suite.setName("Commons-SCXML IO Tests");
+        suite.addTest(TestSCXMLSerializer.suite());
         return suite;
     }
 }

Modified: jakarta/commons/sandbox/scxml/branches/BETWIXT_IO/src/test/java/org/apache/commons/scxml/model/ActionsTest.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/scxml/branches/BETWIXT_IO/src/test/java/org/apache/commons/scxml/model/ActionsTest.java?rev=375066&r1=375065&r2=375066&view=diff
==============================================================================
--- jakarta/commons/sandbox/scxml/branches/BETWIXT_IO/src/test/java/org/apache/commons/scxml/model/ActionsTest.java (original)
+++ jakarta/commons/sandbox/scxml/branches/BETWIXT_IO/src/test/java/org/apache/commons/scxml/model/ActionsTest.java Sun Feb  5 10:04:50 2006
@@ -22,10 +22,10 @@
 import junit.framework.TestSuite;
 import junit.textui.TestRunner;
 
-import org.apache.commons.scxml.env.jsp.ELEvaluator;
-import org.apache.commons.scxml.env.jsp.ELContext;
 import org.apache.commons.scxml.SCXMLExecutor;
 import org.apache.commons.scxml.SCXMLTestHelper;
+import org.apache.commons.scxml.env.jsp.ELContext;
+import org.apache.commons.scxml.env.jsp.ELEvaluator;
 /**
  * Unit tests {@link org.apache.commons.scxml.model.Assign}.
  * Unit tests {@link org.apache.commons.scxml.model.Cancel}.
@@ -83,6 +83,8 @@
      */
     public void testModelActions() {
         exec = SCXMLTestHelper.getExecutor(actionsSample, ctx, evaluator);
+        ELContext ctx = (ELContext) SCXMLTestHelper.lookupContext(exec,
+            "actionsTest");
         assertEquals((String) ctx.get("foo"), "foobar");
     }
 

Modified: jakarta/commons/sandbox/scxml/branches/BETWIXT_IO/src/test/java/org/apache/commons/scxml/model/ModelTestSuite.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/scxml/branches/BETWIXT_IO/src/test/java/org/apache/commons/scxml/model/ModelTestSuite.java?rev=375066&r1=375065&r2=375066&view=diff
==============================================================================
--- jakarta/commons/sandbox/scxml/branches/BETWIXT_IO/src/test/java/org/apache/commons/scxml/model/ModelTestSuite.java (original)
+++ jakarta/commons/sandbox/scxml/branches/BETWIXT_IO/src/test/java/org/apache/commons/scxml/model/ModelTestSuite.java Sun Feb  5 10:04:50 2006
@@ -1,5 +1,5 @@
 /*
- * Copyright 2005 The Apache Software Foundation.
+ * Copyright 2005-2006 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.
@@ -48,6 +48,7 @@
         TestSuite suite = new TestSuite();
         suite.setName("Commons-SCXML Model Tests");
         suite.addTest(ActionsTest.suite());
+        suite.addTest(TestAction.suite());
         return suite;
     }
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org