commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ra...@apache.org
Subject svn commit: r373325 - /jakarta/commons/sandbox/scxml/branches/STATELESS_MODEL/src/main/java/org/apache/commons/scxml/io/SCXMLDigester.java
Date Sun, 29 Jan 2006 16:48:40 GMT
Author: rahul
Date: Sun Jan 29 08:48:35 2006
New Revision: 373325

URL: http://svn.apache.org/viewcvs?rev=373325&view=rev
Log:
In a stateless model, the Context, Evaluator and NotificationRegistry have no role to play
in SCXML IO. Update the Digester to match the changes made to the object model in r373323.

The imports for o.a.c.s.{Context,Evaluator,NotificationRegistry} are no longer needed, which
is a fair indication that we have the desired separation of concerns.

Changes make BZ # 38275 ([scxml] More Explicit Instructions on core-digester.html) mostly
obsolete.


Modified:
    jakarta/commons/sandbox/scxml/branches/STATELESS_MODEL/src/main/java/org/apache/commons/scxml/io/SCXMLDigester.java

Modified: jakarta/commons/sandbox/scxml/branches/STATELESS_MODEL/src/main/java/org/apache/commons/scxml/io/SCXMLDigester.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/scxml/branches/STATELESS_MODEL/src/main/java/org/apache/commons/scxml/io/SCXMLDigester.java?rev=373325&r1=373324&r2=373325&view=diff
==============================================================================
--- jakarta/commons/sandbox/scxml/branches/STATELESS_MODEL/src/main/java/org/apache/commons/scxml/io/SCXMLDigester.java
(original)
+++ jakarta/commons/sandbox/scxml/branches/STATELESS_MODEL/src/main/java/org/apache/commons/scxml/io/SCXMLDigester.java
Sun Jan 29 08:48:35 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);
         }
     }
 



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


Mime
View raw message