cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gkossakow...@apache.org
Subject svn commit: r562870 - in /cocoon/trunk/core/cocoon-expression-language/cocoon-expression-language-impl/src/main/java/org/apache/cocoon: components/expression/javascript/JavaScriptExpression.java template/environment/FlowObjectModelHelper.java
Date Sun, 05 Aug 2007 14:16:10 GMT
Author: gkossakowski
Date: Sun Aug  5 07:16:09 2007
New Revision: 562870

URL: http://svn.apache.org/viewvc?view=rev&rev=562870
Log:
Moved getScope() method from FlowObjectModelHelper to the JavaScriptExpression because it
is used only there.

Modified:
    cocoon/trunk/core/cocoon-expression-language/cocoon-expression-language-impl/src/main/java/org/apache/cocoon/components/expression/javascript/JavaScriptExpression.java
    cocoon/trunk/core/cocoon-expression-language/cocoon-expression-language-impl/src/main/java/org/apache/cocoon/template/environment/FlowObjectModelHelper.java

Modified: cocoon/trunk/core/cocoon-expression-language/cocoon-expression-language-impl/src/main/java/org/apache/cocoon/components/expression/javascript/JavaScriptExpression.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-expression-language/cocoon-expression-language-impl/src/main/java/org/apache/cocoon/components/expression/javascript/JavaScriptExpression.java?view=diff&rev=562870&r1=562869&r2=562870
==============================================================================
--- cocoon/trunk/core/cocoon-expression-language/cocoon-expression-language-impl/src/main/java/org/apache/cocoon/components/expression/javascript/JavaScriptExpression.java
(original)
+++ cocoon/trunk/core/cocoon-expression-language/cocoon-expression-language-impl/src/main/java/org/apache/cocoon/components/expression/javascript/JavaScriptExpression.java
Sun Aug  5 07:16:09 2007
@@ -25,7 +25,6 @@
 import org.apache.cocoon.components.expression.ExpressionException;
 import org.apache.cocoon.components.expression.jexl.JSIntrospector;
 import org.apache.cocoon.components.flow.javascript.JavaScriptFlowHelper;
-import org.apache.cocoon.template.environment.FlowObjectModelHelper;
 import org.apache.commons.jexl.util.introspection.Info;
 import org.mozilla.javascript.Context;
 import org.mozilla.javascript.Script;
@@ -47,7 +46,7 @@
         Context ctx = Context.enter();
         try {
             // Note: used compileReader instead of compileString to work with the older Rhino
in C2.1
-            this.script = ctx.compileReader(FlowObjectModelHelper.getScope(rootScope), new
StringReader(getExpression()), "", 1, null);
+            this.script = ctx.compileReader(getScope(rootScope), new StringReader(getExpression()),
"", 1, null);
         } catch (Exception e) {
             // Note: this catch block is only needed for the Rhino in C2.1 where the older
             //       Rhino does not throw RuntimeExceptions
@@ -64,7 +63,7 @@
     public Object evaluate(ObjectModel objectModel) throws ExpressionException {
         Context ctx = Context.enter();
         try {
-            Scriptable scope = ctx.newObject(FlowObjectModelHelper.getScope(rootScope));
+            Scriptable scope = ctx.newObject(getScope(rootScope));
             // Populate the scope
             Iterator iter = objectModel.entrySet().iterator();
             while (iter.hasNext()) {
@@ -115,5 +114,20 @@
 
     public Object getNode(ObjectModel objectModel) throws ExpressionException {
         return evaluate(objectModel);
+    }
+
+    private Scriptable getScope(Scriptable rootScope) {
+        Scriptable scope;
+        Context ctx = Context.enter();
+        try {
+            scope = ctx.newObject(rootScope);
+            scope.setPrototype(rootScope);
+            scope.setParentScope(null);
+        } catch (Exception e) {
+            throw new RuntimeException("Exception", e);
+        } finally {
+            Context.exit();
+        }
+        return scope;
     }
 }

Modified: cocoon/trunk/core/cocoon-expression-language/cocoon-expression-language-impl/src/main/java/org/apache/cocoon/template/environment/FlowObjectModelHelper.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-expression-language/cocoon-expression-language-impl/src/main/java/org/apache/cocoon/template/environment/FlowObjectModelHelper.java?view=diff&rev=562870&r1=562869&r2=562870
==============================================================================
--- cocoon/trunk/core/cocoon-expression-language/cocoon-expression-language-impl/src/main/java/org/apache/cocoon/template/environment/FlowObjectModelHelper.java
(original)
+++ cocoon/trunk/core/cocoon-expression-language/cocoon-expression-language-impl/src/main/java/org/apache/cocoon/template/environment/FlowObjectModelHelper.java
Sun Aug  5 07:16:09 2007
@@ -26,8 +26,6 @@
 import org.apache.commons.jxpath.DynamicPropertyHandler;
 import org.apache.commons.jxpath.JXPathBeanInfo;
 import org.apache.commons.jxpath.JXPathIntrospector;
-import org.mozilla.javascript.Context;
-import org.mozilla.javascript.Scriptable;
 
 
 /**
@@ -39,21 +37,6 @@
 
     /** Avoid instantiation. */
     private FlowObjectModelHelper() {}
-
-    public static Scriptable getScope(Scriptable rootScope) {
-        Scriptable scope;
-        Context ctx = Context.enter();
-        try {
-            scope = ctx.newObject(rootScope);
-            scope.setPrototype(rootScope);
-            scope.setParentScope(null);
-        } catch (Exception e) {
-            throw new RuntimeException("Exception", e);
-        } finally {
-            Context.exit();
-        }
-        return scope;
-    }
 
     /**
      * Create an expression context that contains the object model



Mime
View raw message