jakarta-taglibs-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ra...@apache.org
Subject svn commit: r230683 - in /jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc: dm/SCXMLDialog.java scxml/SCXMLDigester.java scxml/model/SCXML.java
Date Sun, 07 Aug 2005 17:04:25 GMT
Author: rahul
Date: Sun Aug  7 10:04:21 2005
New Revision: 230683

URL: http://svn.apache.org/viewcvs?rev=230683&view=rev
Log:
Towards Commons Sandbox, a cleaner RDC - SCXML separation.

Modified:
    jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/dm/SCXMLDialog.java
    jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/scxml/SCXMLDigester.java
    jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/scxml/model/SCXML.java

Modified: jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/dm/SCXMLDialog.java
URL: http://svn.apache.org/viewcvs/jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/dm/SCXMLDialog.java?rev=230683&r1=230682&r2=230683&view=diff
==============================================================================
--- jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/dm/SCXMLDialog.java (original)
+++ jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/dm/SCXMLDialog.java Sun Aug
 7 10:04:21 2005
@@ -26,6 +26,7 @@
 import java.util.Map;
 import java.util.Set;
 
+import javax.servlet.ServletContext;
 import javax.servlet.jsp.JspContext;
 import javax.servlet.jsp.JspException;
 import javax.servlet.jsp.PageContext;
@@ -33,6 +34,7 @@
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+
 import org.apache.taglibs.rdc.core.BaseModel;
 import org.apache.taglibs.rdc.core.Constants;
 import org.apache.taglibs.rdc.core.GroupModel;
@@ -47,10 +49,12 @@
 import org.apache.taglibs.rdc.scxml.env.ELEvaluator;
 import org.apache.taglibs.rdc.scxml.env.RootContext;
 import org.apache.taglibs.rdc.scxml.env.SimpleDispatcher;
+import org.apache.taglibs.rdc.scxml.env.ServletContextResolver;
 import org.apache.taglibs.rdc.scxml.env.Tracer;
 import org.apache.taglibs.rdc.scxml.model.ModelException;
 import org.apache.taglibs.rdc.scxml.model.SCXML;
 import org.apache.taglibs.rdc.scxml.model.State;
+
 import org.xml.sax.ErrorHandler;
 import org.xml.sax.SAXParseException;
 
@@ -101,10 +105,11 @@
 		SCXML scxml = null;
 		Evaluator engine = new ELEvaluator();
 		Context rootCtx = new RootContext(ctx);
+		ServletContext sc = ((PageContext) ctx).getServletContext();
 		try {
-			scxml = SCXMLDigester.digest(((PageContext) ctx).
-				getServletContext(), groupTag.getConfig(), 
-				new SCXMLErrorHandler(), rootCtx, engine);
+			scxml = SCXMLDigester.digest(sc.getRealPath(groupTag.getConfig()),
+				new SCXMLErrorHandler(), rootCtx, engine, 
+				new ServletContextResolver(sc));
 		} catch (Exception e) {
 			MessageFormat msgFormat = new MessageFormat(ERR_DIGESTER_FAIL);
 			String errMsg = msgFormat.format(new Object[] {groupTag.

Modified: jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/scxml/SCXMLDigester.java
URL: http://svn.apache.org/viewcvs/jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/scxml/SCXMLDigester.java?rev=230683&r1=230682&r2=230683&view=diff
==============================================================================
--- jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/scxml/SCXMLDigester.java (original)
+++ jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/scxml/SCXMLDigester.java Sun
Aug  7 10:04:21 2005
@@ -24,8 +24,6 @@
 import java.util.Map;
 import java.util.Set;
 
-import javax.servlet.ServletContext;
-
 import org.apache.commons.digester.Digester;
 import org.apache.commons.digester.ExtendedBaseRules;
 import org.apache.commons.digester.ObjectCreateRule;
@@ -34,10 +32,6 @@
 import org.apache.commons.digester.SetPropertiesRule;
 import org.apache.commons.logging.LogFactory;
 
-import org.xml.sax.Attributes;
-import org.xml.sax.ErrorHandler;
-
-import org.apache.taglibs.rdc.scxml.env.ServletContextResolver;
 import org.apache.taglibs.rdc.scxml.env.URLResolver;
 import org.apache.taglibs.rdc.scxml.model.Action;
 import org.apache.taglibs.rdc.scxml.model.Assign;
@@ -60,6 +54,9 @@
 import org.apache.taglibs.rdc.scxml.model.TransitionTarget;
 import org.apache.taglibs.rdc.scxml.model.Var;
 
+import org.xml.sax.Attributes;
+import org.xml.sax.ErrorHandler;
+
 /**
  * The SCXMLDigester can be used to: <br>
  * a) Digest a SCXML file placed in a web application context <br>
@@ -79,33 +76,44 @@
 
 	//-- PUBLIC METHODS --//
 	/**
-	 * Convenience method for the RDC SCXML DM strategy impl
+	 * API for standalone usage where the SCXML document is a URL.
 	 * 
-	 * @param ServletContext
-	 *            The ServletContext within which this RDC group is hosted
-	 * @param String
-	 *            The absolute file from the base of the application context
-	 * @param ErrorHandler
+	 * @param scxmlURL
+	 *            a canonical absolute URL to parse (relative URLs within the
+	 *            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
+	 * 
+	 * @see Context
+	 * @see ErrorHandler
+	 * @see Evaluator
+	 * @see PathResolver
 	 */
-	public static SCXML digest(ServletContext sc, String file,
-			ErrorHandler errHandler, Context evalCtx, Evaluator evalEngine) {
+	public static SCXML digest(URL scxmlURL, ErrorHandler errHandler,
+			Context evalCtx, Evaluator evalEngine) {
 
 		SCXML scxml = null;
-		Digester scxmlDigester = SCXMLDigester.newInstance(null,
-				new ServletContextResolver(sc));
+		Digester scxmlDigester = SCXMLDigester
+				.newInstance(null, new URLResolver(scxmlURL));
 		scxmlDigester.setErrorHandler(errHandler);
 
 		try {
-			scxml = (SCXML) scxmlDigester.parse(sc.getRealPath(file));
+			scxml = (SCXML) scxmlDigester.parse(scxmlURL.toString());
 		} catch (Exception e) {
 			MessageFormat msgFormat = new MessageFormat(ERR_PARSE_FAIL);
-			String errMsg = msgFormat.format(new Object[] {sc.
-				getRealPath(file), e.getMessage()});
+			String errMsg = msgFormat.format(new Object[] {scxmlURL.toString(),
+					e.getMessage()});
         	log.error(errMsg, e);
-		}
+        }
 
 		if (scxml != null) {
 			updateSCXML(scxml, evalCtx, evalEngine);
@@ -116,11 +124,14 @@
 	}
 
 	/**
-	 * API for standalone usage.
+	 * API for standalone usage where the SCXML document is a URI.
+	 * A PathResolver must be provided.
 	 * 
-	 * @param scxmlURL
-	 *            a canonical absolute URL to parse (relative URLs within the
-	 *            top level document are to be resovled against this URL).
+	 * @param pathResolver
+	 *            The PathResolver for this context
+	 * @param documentRealPath 
+	 *            The String pointing to the absolute (real) path of the
+	 * 	          SCXML config 
 	 * @param errHandler
 	 *            The SAX ErrorHandler
 	 * @param evalCtx
@@ -130,27 +141,30 @@
 	 *            the scripting/expression language engine for creating local
 	 *            state-level variable contexts (if supported by a given
 	 *            scripting engine)
-	 * @see Context
-	 * @see Evaluator
 	 * 
 	 * @return SCXML The SCXML object corresponding to the file argument
+	 * 
+	 * @see Context
+	 * @see ErrorHandler
+	 * @see Evaluator
+	 * @see PathResolver
 	 */
-	public static SCXML digest(URL scxmlURL, ErrorHandler errHandler,
-			Context evalCtx, Evaluator evalEngine) {
+	public static SCXML digest(String documentRealPath, 
+			ErrorHandler errHandler, Context evalCtx, Evaluator evalEngine,
+			PathResolver pr) {
 
 		SCXML scxml = null;
-		Digester scxmlDigester = SCXMLDigester
-				.newInstance(null, new URLResolver(scxmlURL));
+		Digester scxmlDigester = SCXMLDigester.newInstance(null, pr);
 		scxmlDigester.setErrorHandler(errHandler);
 
 		try {
-			scxml = (SCXML) scxmlDigester.parse(scxmlURL.toString());
+			scxml = (SCXML) scxmlDigester.parse(documentRealPath);
 		} catch (Exception e) {
 			MessageFormat msgFormat = new MessageFormat(ERR_PARSE_FAIL);
-			String errMsg = msgFormat.format(new Object[] {scxmlURL.toString(),
-					e.getMessage()});
+			String errMsg = msgFormat.format(new Object[] { documentRealPath,
+				e.getMessage()});
         	log.error(errMsg, e);
-        }
+		}
 
 		if (scxml != null) {
 			updateSCXML(scxml, evalCtx, evalEngine);

Modified: jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/scxml/model/SCXML.java
URL: http://svn.apache.org/viewcvs/jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/scxml/model/SCXML.java?rev=230683&r1=230682&r2=230683&view=diff
==============================================================================
--- jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/scxml/model/SCXML.java (original)
+++ jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/scxml/model/SCXML.java Sun
Aug  7 10:04:21 2005
@@ -17,10 +17,10 @@
  */
 package org.apache.taglibs.rdc.scxml.model;
 
-import org.apache.taglibs.rdc.RDCUtils;
 import org.apache.taglibs.rdc.scxml.Context;
 import org.apache.taglibs.rdc.scxml.NotificationRegistry;
 import org.apache.taglibs.rdc.scxml.Observable;
+import org.apache.taglibs.rdc.scxml.SCXMLHelper;
 import org.apache.taglibs.rdc.scxml.SCXMLListener;
 
 import java.util.HashMap;
@@ -147,7 +147,7 @@
 	 */
 	public void addTarget(TransitionTarget target) {
 		String id = target.getId();
-		if (!RDCUtils.isStringEmpty(id)) {
+		if (!SCXMLHelper.isStringEmpty(id)) {
 			// Target is not anonymous, so makes sense to map it
 			targets.put(id, target);
 		}



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


Mime
View raw message