jakarta-bsf-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From antel...@apache.org
Subject svn commit: r591073 - in /jakarta/bsf/branches/bsf-3.0-beta2: bsf-api/src/main/java/javax/script/ bsf-utils/ bsf-utils/src/main/java/org/apache/bsf/xml/ bsf-utils/src/main/java/org/mozilla/ bsf-utils/src/main/java/org/mozilla/javascript/ testing/ testi...
Date Thu, 01 Nov 2007 16:34:11 GMT
Author: antelder
Date: Thu Nov  1 09:34:09 2007
New Revision: 591073

URL: http://svn.apache.org/viewvc?rev=591073&view=rev
Log:
Merge trunk changes into beta2 branch

Added:
    jakarta/bsf/branches/bsf-3.0-beta2/bsf-utils/src/main/java/org/apache/bsf/xml/JavaScriptE4XAxiomHelper.java
      - copied unchanged from r591065, jakarta/bsf/trunk/bsf3/bsf-utils/src/main/java/org/apache/bsf/xml/JavaScriptE4XAxiomHelper.java
    jakarta/bsf/branches/bsf-3.0-beta2/bsf-utils/src/main/java/org/apache/bsf/xml/JavaScriptE4XXmlBeansHelper.java
      - copied unchanged from r591065, jakarta/bsf/trunk/bsf3/bsf-utils/src/main/java/org/apache/bsf/xml/JavaScriptE4XXmlBeansHelper.java
    jakarta/bsf/branches/bsf-3.0-beta2/bsf-utils/src/main/java/org/mozilla/
      - copied from r591065, jakarta/bsf/trunk/bsf3/bsf-utils/src/main/java/org/mozilla/
    jakarta/bsf/branches/bsf-3.0-beta2/bsf-utils/src/main/java/org/mozilla/javascript/
      - copied from r591065, jakarta/bsf/trunk/bsf3/bsf-utils/src/main/java/org/mozilla/javascript/
    jakarta/bsf/branches/bsf-3.0-beta2/bsf-utils/src/main/java/org/mozilla/javascript/ContextHelper.java
      - copied unchanged from r591065, jakarta/bsf/trunk/bsf3/bsf-utils/src/main/java/org/mozilla/javascript/ContextHelper.java
    jakarta/bsf/branches/bsf-3.0-beta2/testing/e4x-1.6R7-Axiom/   (props changed)
      - copied from r591065, jakarta/bsf/trunk/bsf3/testing/e4x-1.6R7-Axiom/
    jakarta/bsf/branches/bsf-3.0-beta2/testing/e4x-1.6R7-Axiom/pom.xml
      - copied unchanged from r591065, jakarta/bsf/trunk/bsf3/testing/e4x-1.6R7-Axiom/pom.xml
    jakarta/bsf/branches/bsf-3.0-beta2/testing/e4x-1.6R7-Axiom/src/
      - copied from r591065, jakarta/bsf/trunk/bsf3/testing/e4x-1.6R7-Axiom/src/
    jakarta/bsf/branches/bsf-3.0-beta2/testing/e4x-1.6R7-Axiom/src/main/
      - copied from r591065, jakarta/bsf/trunk/bsf3/testing/e4x-1.6R7-Axiom/src/main/
    jakarta/bsf/branches/bsf-3.0-beta2/testing/e4x-1.6R7-Axiom/src/main/java/
      - copied from r591065, jakarta/bsf/trunk/bsf3/testing/e4x-1.6R7-Axiom/src/main/java/
    jakarta/bsf/branches/bsf-3.0-beta2/testing/e4x-1.6R7-Axiom/src/main/resources/
      - copied from r591065, jakarta/bsf/trunk/bsf3/testing/e4x-1.6R7-Axiom/src/main/resources/
    jakarta/bsf/branches/bsf-3.0-beta2/testing/e4x-1.6R7-Axiom/src/test/
      - copied from r591065, jakarta/bsf/trunk/bsf3/testing/e4x-1.6R7-Axiom/src/test/
    jakarta/bsf/branches/bsf-3.0-beta2/testing/e4x-1.6R7-Axiom/src/test/java/
      - copied from r591065, jakarta/bsf/trunk/bsf3/testing/e4x-1.6R7-Axiom/src/test/java/
    jakarta/bsf/branches/bsf-3.0-beta2/testing/e4x-1.6R7-Axiom/src/test/java/org/
      - copied from r591065, jakarta/bsf/trunk/bsf3/testing/e4x-1.6R7-Axiom/src/test/java/org/
    jakarta/bsf/branches/bsf-3.0-beta2/testing/e4x-1.6R7-Axiom/src/test/java/org/apache/
      - copied from r591065, jakarta/bsf/trunk/bsf3/testing/e4x-1.6R7-Axiom/src/test/java/org/apache/
    jakarta/bsf/branches/bsf-3.0-beta2/testing/e4x-1.6R7-Axiom/src/test/java/org/apache/bsf/
      - copied from r591065, jakarta/bsf/trunk/bsf3/testing/e4x-1.6R7-Axiom/src/test/java/org/apache/bsf/
    jakarta/bsf/branches/bsf-3.0-beta2/testing/e4x-1.6R7-Axiom/src/test/java/org/apache/bsf/testing/
      - copied from r591065, jakarta/bsf/trunk/bsf3/testing/e4x-1.6R7-Axiom/src/test/java/org/apache/bsf/testing/
    jakarta/bsf/branches/bsf-3.0-beta2/testing/e4x-1.6R7-Axiom/src/test/java/org/apache/bsf/testing/e4x/
      - copied from r591065, jakarta/bsf/trunk/bsf3/testing/e4x-1.6R7-Axiom/src/test/java/org/apache/bsf/testing/e4x/
    jakarta/bsf/branches/bsf-3.0-beta2/testing/e4x-1.6R7-Axiom/src/test/java/org/apache/bsf/testing/e4x/HelloTestCase.java
      - copied unchanged from r591065, jakarta/bsf/trunk/bsf3/testing/e4x-1.6R7-Axiom/src/test/java/org/apache/bsf/testing/e4x/HelloTestCase.java
    jakarta/bsf/branches/bsf-3.0-beta2/testing/e4x-1.6R7-Axiom/src/test/resources/
      - copied from r591065, jakarta/bsf/trunk/bsf3/testing/e4x-1.6R7-Axiom/src/test/resources/
Modified:
    jakarta/bsf/branches/bsf-3.0-beta2/bsf-api/src/main/java/javax/script/ScriptEngineManager.java
    jakarta/bsf/branches/bsf-3.0-beta2/bsf-utils/pom.xml
    jakarta/bsf/branches/bsf-3.0-beta2/bsf-utils/src/main/java/org/apache/bsf/xml/JavaScriptE4XHelper.java
    jakarta/bsf/branches/bsf-3.0-beta2/bsf-utils/src/main/java/org/apache/bsf/xml/XMLHelper.java
    jakarta/bsf/branches/bsf-3.0-beta2/testing/groovy-1.1/   (props changed)
    jakarta/bsf/branches/bsf-3.0-beta2/testing/jython-2.2/   (props changed)
    jakarta/bsf/branches/bsf-3.0-beta2/testing/pom.xml

Modified: jakarta/bsf/branches/bsf-3.0-beta2/bsf-api/src/main/java/javax/script/ScriptEngineManager.java
URL: http://svn.apache.org/viewvc/jakarta/bsf/branches/bsf-3.0-beta2/bsf-api/src/main/java/javax/script/ScriptEngineManager.java?rev=591073&r1=591072&r2=591073&view=diff
==============================================================================
--- jakarta/bsf/branches/bsf-3.0-beta2/bsf-api/src/main/java/javax/script/ScriptEngineManager.java
(original)
+++ jakarta/bsf/branches/bsf-3.0-beta2/bsf-api/src/main/java/javax/script/ScriptEngineManager.java
Thu Nov  1 09:34:09 2007
@@ -19,6 +19,7 @@
 
 package javax.script;
 
+import java.lang.reflect.Method;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.HashSet;
@@ -93,9 +94,25 @@
                 mimeTypeAssociations.put(data.get(i), factory);
             }            
         }
+        
+        initXMLHelper(loader);
     }
-	
+
     /**
+     * Initialise the xml helper here so BSF clients don't have to.
+     * (Temporary approach for beta2 release)
+     */
+    private void initXMLHelper(ClassLoader loader) {
+    	try {
+			Class xmlHelperClass = Class.forName("org.apache.bsf.xml.XMLHelper", true, loader);
+			Method initMethod = xmlHelperClass.getMethod("init", new Class[]{});
+			initMethod.invoke(null, new Object[]{});
+		} catch (Throwable e) {
+			// ignore
+		}
+	}
+
+	/**
      * Retrieves the associated value for the spefied key in the 
      * GLOBAL_SCOPE
      *  

Modified: jakarta/bsf/branches/bsf-3.0-beta2/bsf-utils/pom.xml
URL: http://svn.apache.org/viewvc/jakarta/bsf/branches/bsf-3.0-beta2/bsf-utils/pom.xml?rev=591073&r1=591072&r2=591073&view=diff
==============================================================================
--- jakarta/bsf/branches/bsf-3.0-beta2/bsf-utils/pom.xml (original)
+++ jakarta/bsf/branches/bsf-3.0-beta2/bsf-utils/pom.xml Thu Nov  1 09:34:09 2007
@@ -72,7 +72,7 @@
         <dependency>
             <groupId>rhino</groupId>
             <artifactId>js</artifactId>
-            <version>1.6R5</version>
+            <version>1.6R6</version>
             <scope>compile</scope>
         </dependency>
         <dependency>

Modified: jakarta/bsf/branches/bsf-3.0-beta2/bsf-utils/src/main/java/org/apache/bsf/xml/JavaScriptE4XHelper.java
URL: http://svn.apache.org/viewvc/jakarta/bsf/branches/bsf-3.0-beta2/bsf-utils/src/main/java/org/apache/bsf/xml/JavaScriptE4XHelper.java?rev=591073&r1=591072&r2=591073&view=diff
==============================================================================
--- jakarta/bsf/branches/bsf-3.0-beta2/bsf-utils/src/main/java/org/apache/bsf/xml/JavaScriptE4XHelper.java
(original)
+++ jakarta/bsf/branches/bsf-3.0-beta2/bsf-utils/src/main/java/org/apache/bsf/xml/JavaScriptE4XHelper.java
Thu Nov  1 09:34:09 2007
@@ -19,99 +19,21 @@
 package org.apache.bsf.xml;
 
 import javax.script.ScriptEngine;
-import javax.script.ScriptException;
-import javax.xml.stream.XMLStreamException;
-
-import org.apache.axiom.om.OMElement;
-import org.apache.axiom.om.impl.builder.StAXOMBuilder;
-import org.apache.xmlbeans.XmlObject;
-import org.mozilla.javascript.Context;
-import org.mozilla.javascript.Scriptable;
-import org.mozilla.javascript.ScriptableObject;
-import org.mozilla.javascript.Wrapper;
-import org.mozilla.javascript.xml.XMLObject;
 
 /**
  * XMLHelper for JavaScript E4X
  */
 public class JavaScriptE4XHelper extends DefaultXMLHelper {
 
-	private Scriptable scope;
-
-    private static boolean axiomE4XImpl = false;
-    static {
-        try {
-            Class.forName("org.mozilla.javascript.xmlimpl.AxiomNode");
-            axiomE4XImpl = true;
-        } catch (ClassNotFoundException ignore) {}
-    }
-
-    JavaScriptE4XHelper(ScriptEngine engine) {
-	    Context cx = Context.enter();
-	    try {
-	        this.scope = cx.initStandardObjects();
-	    } finally {
-	        Context.exit();
-	    }
-	}
-
-	public OMElement toOMElement(Object scriptXML) throws ScriptException {
-        if (scriptXML == null) {
-        	return null;
-        }
-
-        if (!(scriptXML instanceof XMLObject)) {
-            return null;
-        }
-
-        if (axiomE4XImpl) {
-            return (OMElement) ScriptableObject.callMethod(
-                (Scriptable) scriptXML, "getXmlObject", new Object[0]);
-
-        } else {
-            // TODO: E4X Bug? Shouldn't need this copy, but without it the outer element
gets lost???
-            Scriptable jsXML =
-                (Scriptable) ScriptableObject.callMethod((Scriptable) scriptXML, "copy",
new Object[0]);
-            Wrapper wrapper =
-                (Wrapper) ScriptableObject.callMethod((XMLObject)jsXML, "getXmlObject", new
Object[0]);
-
-            XmlObject xmlObject = (XmlObject) wrapper.unwrap();
-
-            try {
-                StAXOMBuilder builder = new StAXOMBuilder(xmlObject.newInputStream());
-                return builder.getDocumentElement();
-
-            } catch (XMLStreamException e) {
-            	throw new ScriptException(e);
-            }
-        }
-	}
-
-	public Object toScriptXML(OMElement om) throws ScriptException {
-        if (om == null) {
-        	return null;
-        }
-        Context cx = Context.enter();
-        try {
-        	if (axiomE4XImpl) {
-
-        		return cx.newObject(scope, "XML", new Object[]{om});
-
-        	} else {
-
-        		XmlObject xml = null;
-                try {
-                    xml = XmlObject.Factory.parse(om.getXMLStreamReader());
-                } catch (Exception e) {
-                	throw new ScriptException(e);
-                }
-                Object wrappedXML = cx.getWrapFactory().wrap(cx, scope, xml, XmlObject.class);
-                return cx.newObject(scope, "XML", new Object[]{wrappedXML});
+	public static XMLHelper getXMLHelper(ScriptEngine engine) {
 
-        	}
-        } finally {
-            Context.exit();
-        }
+		try {
+			Class.forName("org.wso2.javascript.xmlimpl.XMLLibImpl", true, JavaScriptE4XHelper.class.getClassLoader());
+			return new JavaScriptE4XAxiomHelper(engine);
+		} catch (ClassNotFoundException e) {
+			// TODO: also support Rhino 1.6R7 DOM based E4X impl 
+			return new JavaScriptE4XXmlBeansHelper(engine);
+		}
 	}
 
 }

Modified: jakarta/bsf/branches/bsf-3.0-beta2/bsf-utils/src/main/java/org/apache/bsf/xml/XMLHelper.java
URL: http://svn.apache.org/viewvc/jakarta/bsf/branches/bsf-3.0-beta2/bsf-utils/src/main/java/org/apache/bsf/xml/XMLHelper.java?rev=591073&r1=591072&r2=591073&view=diff
==============================================================================
--- jakarta/bsf/branches/bsf-3.0-beta2/bsf-utils/src/main/java/org/apache/bsf/xml/XMLHelper.java
(original)
+++ jakarta/bsf/branches/bsf-3.0-beta2/bsf-utils/src/main/java/org/apache/bsf/xml/XMLHelper.java
Thu Nov  1 09:34:09 2007
@@ -32,21 +32,33 @@
  */
 public abstract class XMLHelper {
 
+	/**
+	 * Register axiom-e4x if its available
+	 * @deprecated temp approach for beta2 release
+	 */
+	public static void init() {
+		try {
+			Class.forName("org.wso2.javascript.xmlimpl.XMLLibImpl", true, JavaScriptE4XHelper.class.getClassLoader());
+			JavaScriptE4XAxiomHelper.init();
+		} catch (ClassNotFoundException e) {
+		}
+	}
+
 	public static XMLHelper getArgHelper(ScriptEngine engine) {
-		// TODO: better discovery mechanisim than hardcoded class names 
+		// TODO: better discovery mechanisim than hardcoded class names
 		if (engine == null) {
 			return null;
 		}
 		String language = engine.getFactory().getLanguageName();
 		if ("ECMAScript".endsWith(language)) {
-			return new JavaScriptE4XHelper(engine);
+			return JavaScriptE4XHelper.getXMLHelper(engine);
 		} else if ("ruby".endsWith(language)) {
 			return new JRubyReXMLHelper(engine);
 		} else {
 			return new DefaultXMLHelper();
 		}
 	}
-
+	
 	public abstract Object toScriptXML(OMElement om) throws ScriptException;
 	public abstract OMElement toOMElement(Object scriptXML) throws ScriptException;
 

Propchange: jakarta/bsf/branches/bsf-3.0-beta2/testing/e4x-1.6R7-Axiom/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Thu Nov  1 09:34:09 2007
@@ -0,0 +1,4 @@
+target
+.project
+.classpath
+.settings

Propchange: jakarta/bsf/branches/bsf-3.0-beta2/testing/groovy-1.1/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Thu Nov  1 09:34:09 2007
@@ -0,0 +1,4 @@
+target
+.project
+.classpath
+.settings

Propchange: jakarta/bsf/branches/bsf-3.0-beta2/testing/jython-2.2/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Thu Nov  1 09:34:09 2007
@@ -0,0 +1,4 @@
+target
+.project
+.classpath
+.settings

Modified: jakarta/bsf/branches/bsf-3.0-beta2/testing/pom.xml
URL: http://svn.apache.org/viewvc/jakarta/bsf/branches/bsf-3.0-beta2/testing/pom.xml?rev=591073&r1=591072&r2=591073&view=diff
==============================================================================
--- jakarta/bsf/branches/bsf-3.0-beta2/testing/pom.xml (original)
+++ jakarta/bsf/branches/bsf-3.0-beta2/testing/pom.xml Thu Nov  1 09:34:09 2007
@@ -38,6 +38,7 @@
             </activation>
             <modules>
                 <module>e4x</module>
+                <module>e4x-1.6R7-Axiom</module>
                 <module>groovy</module>
                 <module>groovy-1.1</module>
                 <module>javascript</module>



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


Mime
View raw message