cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gkossakow...@apache.org
Subject svn commit: r561357 - in /cocoon/trunk: blocks/cocoon-template/cocoon-template-impl/src/test/resources/org/apache/cocoon/template/jxtg/ core/cocoon-expression-language/cocoon-expression-language-impl/src/main/java/org/apache/cocoon/components/expressio...
Date Tue, 31 Jul 2007 15:12:54 GMT
Author: gkossakowski
Date: Tue Jul 31 08:12:52 2007
New Revision: 561357

URL: http://svn.apache.org/viewvc?view=rev&rev=561357
Log:
COCOON-2095: More work on cleaning up various helper classes.
Basically, the work consists of moving initialization stuff from helper classes to approporiate
ObjectModel providers. Detailed info:
  * introduced Rhino's root scope as Spring bean
  * moved adding java packages from FlowObjectModelHelper to ObjectModel providers
  * adapted tests so they use new root scope as Spring bean

Added:
    cocoon/trunk/core/cocoon-expression-language/cocoon-expression-language-impl/src/main/java/org/apache/cocoon/components/expression/helpers/
    cocoon/trunk/core/cocoon-expression-language/cocoon-expression-language-impl/src/main/java/org/apache/cocoon/components/expression/helpers/RhinoScopeFactory.java
  (with props)
    cocoon/trunk/core/cocoon-expression-language/cocoon-expression-language-impl/src/main/java/org/apache/cocoon/objectmodel/provider/JavaEntryObjectModelProvider.java
  (with props)
    cocoon/trunk/core/cocoon-expression-language/cocoon-expression-language-impl/src/main/java/org/apache/cocoon/objectmodel/provider/PackagesEntryObjectModelProvider.java
  (with props)
    cocoon/trunk/core/cocoon-expression-language/cocoon-expression-language-impl/src/main/resources/META-INF/cocoon/spring/RhinoScope.xml
  (with props)
Modified:
    cocoon/trunk/blocks/cocoon-template/cocoon-template-impl/src/test/resources/org/apache/cocoon/template/jxtg/JXTemplateGeneratorTestCase.spring.xml
    cocoon/trunk/core/cocoon-expression-language/cocoon-expression-language-impl/src/main/java/org/apache/cocoon/components/expression/javascript/JavaScriptCompiler.java
    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
    cocoon/trunk/core/cocoon-expression-language/cocoon-expression-language-impl/src/main/resources/META-INF/cocoon/spring/JavaScriptCompiler.xml
    cocoon/trunk/core/cocoon-expression-language/cocoon-expression-language-impl/src/main/resources/META-INF/cocoon/spring/ObjectModel.xml
    cocoon/trunk/core/cocoon-expression-language/cocoon-expression-language-impl/src/main/resources/META-INF/cocoon/spring/ObjectModelProviders.xml
    cocoon/trunk/core/cocoon-expression-language/cocoon-expression-language-impl/src/test/java/org/apache/cocoon/components/expression/javascript/JavaScriptTestCase.java
    cocoon/trunk/core/cocoon-expression-language/cocoon-expression-language-impl/src/test/resources/org/apache/cocoon/components/expression/ExpressionTestCase.spring.xml
    cocoon/trunk/core/cocoon-expression-language/cocoon-expression-language-impl/src/test/resources/org/apache/cocoon/environment/FOMTestCase.spring.xml

Modified: cocoon/trunk/blocks/cocoon-template/cocoon-template-impl/src/test/resources/org/apache/cocoon/template/jxtg/JXTemplateGeneratorTestCase.spring.xml
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-template/cocoon-template-impl/src/test/resources/org/apache/cocoon/template/jxtg/JXTemplateGeneratorTestCase.spring.xml?view=diff&rev=561357&r1=561356&r2=561357
==============================================================================
--- cocoon/trunk/blocks/cocoon-template/cocoon-template-impl/src/test/resources/org/apache/cocoon/template/jxtg/JXTemplateGeneratorTestCase.spring.xml
(original)
+++ cocoon/trunk/blocks/cocoon-template/cocoon-template-impl/src/test/resources/org/apache/cocoon/template/jxtg/JXTemplateGeneratorTestCase.spring.xml
Tue Jul 31 08:12:52 2007
@@ -25,6 +25,7 @@
   <import resource="classpath:META-INF/cocoon/spring/JexlCompiler.xml"/>
   <import resource="classpath:META-INF/cocoon/spring/JXPathCompiler.xml"/>
   <import resource="classpath:META-INF/cocoon/spring/ObjectModelProviders.xml"/>
+  <import resource="classpath:META-INF/cocoon/spring/RhinoScope.xml"/>
   
   <!-- Redefining this bean instead of importing because originally it is in "call" scope
-->
   <bean name="org.apache.cocoon.objectmodel.ObjectModel" class="org.apache.cocoon.objectmodel.ObjectModelImpl">

Added: cocoon/trunk/core/cocoon-expression-language/cocoon-expression-language-impl/src/main/java/org/apache/cocoon/components/expression/helpers/RhinoScopeFactory.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/helpers/RhinoScopeFactory.java?view=auto&rev=561357
==============================================================================
--- cocoon/trunk/core/cocoon-expression-language/cocoon-expression-language-impl/src/main/java/org/apache/cocoon/components/expression/helpers/RhinoScopeFactory.java
(added)
+++ cocoon/trunk/core/cocoon-expression-language/cocoon-expression-language-impl/src/main/java/org/apache/cocoon/components/expression/helpers/RhinoScopeFactory.java
Tue Jul 31 08:12:52 2007
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.components.expression.helpers;
+
+import org.mozilla.javascript.Context;
+import org.mozilla.javascript.Scriptable;
+
+/**
+ * This is a simple factory class that produces Rhino scope.
+ * Scope returned by this factory will be used as Spring bean.
+ */
+public final class RhinoScopeFactory {
+
+    public static Scriptable createRhinoScope() {
+        final Scriptable rootScope;
+
+        Context ctx = Context.enter();
+        try {
+            rootScope = ctx.initStandardObjects(null);
+        } finally {
+            Context.exit();
+        }
+        return rootScope;
+    }
+}

Propchange: cocoon/trunk/core/cocoon-expression-language/cocoon-expression-language-impl/src/main/java/org/apache/cocoon/components/expression/helpers/RhinoScopeFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: cocoon/trunk/core/cocoon-expression-language/cocoon-expression-language-impl/src/main/java/org/apache/cocoon/components/expression/javascript/JavaScriptCompiler.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/JavaScriptCompiler.java?view=diff&rev=561357&r1=561356&r2=561357
==============================================================================
--- cocoon/trunk/core/cocoon-expression-language/cocoon-expression-language-impl/src/main/java/org/apache/cocoon/components/expression/javascript/JavaScriptCompiler.java
(original)
+++ cocoon/trunk/core/cocoon-expression-language/cocoon-expression-language-impl/src/main/java/org/apache/cocoon/components/expression/javascript/JavaScriptCompiler.java
Tue Jul 31 08:12:52 2007
@@ -19,16 +19,27 @@
 import org.apache.cocoon.components.expression.Expression;
 import org.apache.cocoon.components.expression.ExpressionCompiler;
 import org.apache.cocoon.components.expression.ExpressionException;
+import org.mozilla.javascript.Scriptable;
 
 /**
  * @version $Id$
  */
 public class JavaScriptCompiler implements ExpressionCompiler {
+    
+    Scriptable rootScope;
 
     /**
      * @see org.apache.cocoon.components.expression.ExpressionCompiler#compile(java.lang.String,
java.lang.String)
      */
     public Expression compile(String language, String expression) throws ExpressionException
{
-        return new JavaScriptExpression(language, expression);
+        return new JavaScriptExpression(language, expression, rootScope);
+    }
+
+    public Scriptable getRootScope() {
+        return rootScope;
+    }
+
+    public void setRootScope(Scriptable rootScope) {
+        this.rootScope = rootScope;
     }
 }

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=561357&r1=561356&r2=561357
==============================================================================
--- 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
Tue Jul 31 08:12:52 2007
@@ -35,9 +35,11 @@
 
     private Script script;
     private JSIntrospector introspector;
+    private Scriptable rootScope;
 
-    public JavaScriptExpression(String language, String expression) {
+    public JavaScriptExpression(String language, String expression, Scriptable rootScope)
{
         super(language, expression);
+        this.rootScope = rootScope;
         compile();
     }
 
@@ -45,7 +47,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(), new StringReader(getExpression()),
"", 1, null);
+            this.script = ctx.compileReader(FlowObjectModelHelper.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
@@ -62,7 +64,7 @@
     public Object evaluate(ObjectModel objectModel) throws ExpressionException {
         Context ctx = Context.enter();
         try {
-            Scriptable scope = ctx.newObject(FlowObjectModelHelper.getScope());
+            Scriptable scope = ctx.newObject(FlowObjectModelHelper.getScope(rootScope));
             // Populate the scope
             Iterator iter = objectModel.entrySet().iterator();
             while (iter.hasNext()) {

Added: cocoon/trunk/core/cocoon-expression-language/cocoon-expression-language-impl/src/main/java/org/apache/cocoon/objectmodel/provider/JavaEntryObjectModelProvider.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-expression-language/cocoon-expression-language-impl/src/main/java/org/apache/cocoon/objectmodel/provider/JavaEntryObjectModelProvider.java?view=auto&rev=561357
==============================================================================
--- cocoon/trunk/core/cocoon-expression-language/cocoon-expression-language-impl/src/main/java/org/apache/cocoon/objectmodel/provider/JavaEntryObjectModelProvider.java
(added)
+++ cocoon/trunk/core/cocoon-expression-language/cocoon-expression-language-impl/src/main/java/org/apache/cocoon/objectmodel/provider/JavaEntryObjectModelProvider.java
Tue Jul 31 08:12:52 2007
@@ -0,0 +1,56 @@
+package org.apache.cocoon.objectmodel.provider;
+
+import org.mozilla.javascript.Context;
+import org.mozilla.javascript.Scriptable;
+import org.mozilla.javascript.ScriptableObject;
+
+/**
+ * Adds java packages to {@link org.apache.cocoon.objectmodel.ObjectModel ObjectModel}. Allows
to construct java objects.
+ * 
+ * @see PackagesEntryObjectModelProvider
+ */
+public class JavaEntryObjectModelProvider implements ObjectModelProvider {
+    
+    private Scriptable rootScope;
+
+    //FIXME: This method is duplicated in PackagesEntryObjectModelProvider
+    private Scriptable getScope() {
+        Context ctx = Context.enter();
+        try {
+            // Create it if never used up to now
+            if (rootScope == null) {
+                rootScope = ctx.initStandardObjects(null);
+            }
+            try {
+                Scriptable scope = ctx.newObject(rootScope);
+                scope.setPrototype(rootScope);
+                scope.setParentScope(null);
+                return scope;
+            } catch (Exception e) {
+                throw new RuntimeException("Exception", e);
+            }
+        } finally {
+            Context.exit();
+        }
+    }
+
+    public Object getObject() {
+        Object javaPackage;
+        Context.enter();
+        try {
+           javaPackage = ScriptableObject.getProperty( getScope(), "java" );
+        } finally {
+            Context.exit();
+        }
+        return javaPackage;
+    }
+
+    public Scriptable getRootScope() {
+        return rootScope;
+    }
+
+    public void setRootScope(Scriptable rootScope) {
+        this.rootScope = rootScope;
+    }
+
+}

Propchange: cocoon/trunk/core/cocoon-expression-language/cocoon-expression-language-impl/src/main/java/org/apache/cocoon/objectmodel/provider/JavaEntryObjectModelProvider.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/trunk/core/cocoon-expression-language/cocoon-expression-language-impl/src/main/java/org/apache/cocoon/objectmodel/provider/PackagesEntryObjectModelProvider.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-expression-language/cocoon-expression-language-impl/src/main/java/org/apache/cocoon/objectmodel/provider/PackagesEntryObjectModelProvider.java?view=auto&rev=561357
==============================================================================
--- cocoon/trunk/core/cocoon-expression-language/cocoon-expression-language-impl/src/main/java/org/apache/cocoon/objectmodel/provider/PackagesEntryObjectModelProvider.java
(added)
+++ cocoon/trunk/core/cocoon-expression-language/cocoon-expression-language-impl/src/main/java/org/apache/cocoon/objectmodel/provider/PackagesEntryObjectModelProvider.java
Tue Jul 31 08:12:52 2007
@@ -0,0 +1,65 @@
+package org.apache.cocoon.objectmodel.provider;
+
+import org.mozilla.javascript.Context;
+import org.mozilla.javascript.NativeJavaPackage;
+import org.mozilla.javascript.Scriptable;
+import org.mozilla.javascript.ScriptableObject;
+
+/**
+ * Adds java packages to {@link org.apache.cocoon.objectmodel.ObjectModel ObjectModel}. Allows
to construct java objects.
+ * 
+ * @see JavaEntryObjectModelProvider
+ */
+public class PackagesEntryObjectModelProvider implements ObjectModelProvider {
+    
+    private Scriptable rootScope;
+
+    //FIXME: This method is duplicated in JavaEntryObjectModelProvider
+    private Scriptable getScope() {
+        Context ctx = Context.enter();
+        try {
+            // Create it if never used up to now
+            if (rootScope == null) {
+                rootScope = ctx.initStandardObjects(null);
+            }
+            try {
+                Scriptable scope = ctx.newObject(rootScope);
+                scope.setPrototype(rootScope);
+                scope.setParentScope(null);
+                return scope;
+            } catch (Exception e) {
+                throw new RuntimeException("Exception", e);
+            }
+        } finally {
+            Context.exit();
+        }
+    }
+
+    public Object getObject() {
+        Scriptable newPackages;
+        Context.enter();
+        try {
+            final String JAVA_PACKAGE = "JavaPackage";
+            ClassLoader cl = Thread.currentThread().getContextClassLoader();
+            // FIXME - NativeJavaPackage is an internal class which we should not use
+            newPackages = new NativeJavaPackage( "", cl );
+            newPackages.setParentScope( getScope() );
+            newPackages.setPrototype( ScriptableObject.getClassPrototype(   getScope(),
+                                                                            JAVA_PACKAGE
) );
+            //objectModel.put( "Packages", newPackages );
+            //objectModel.put( "java", ScriptableObject.getProperty( getScope(), "java" )
);
+        } finally {
+            Context.exit();
+        }
+        return newPackages;
+    }
+
+    public Scriptable getRootScope() {
+        return rootScope;
+    }
+
+    public void setRootScope(Scriptable rootScope) {
+        this.rootScope = rootScope;
+    }
+
+}

Propchange: cocoon/trunk/core/cocoon-expression-language/cocoon-expression-language-impl/src/main/java/org/apache/cocoon/objectmodel/provider/PackagesEntryObjectModelProvider.java
------------------------------------------------------------------------------
    svn:eol-style = native

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=561357&r1=561356&r2=561357
==============================================================================
--- 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
Tue Jul 31 08:12:52 2007
@@ -37,29 +37,22 @@
  */
 public class FlowObjectModelHelper {
 
-    private static Scriptable rootScope;
-
     /** Avoid instantiation. */
     private FlowObjectModelHelper() {}
 
-    public static Scriptable getScope() {
+    public static Scriptable getScope(Scriptable rootScope) {
+        Scriptable scope;
         Context ctx = Context.enter();
         try {
-            // Create it if never used up to now
-            if (rootScope == null) {
-                rootScope = ctx.initStandardObjects(null);
-            }
-            try {
-                Scriptable scope = ctx.newObject(rootScope);
-                scope.setPrototype(rootScope);
-                scope.setParentScope(null);
-                return scope;
-            } catch (Exception e) {
-                throw new RuntimeException("Exception", e);
-            }
+            scope = ctx.newObject(rootScope);
+            scope.setPrototype(rootScope);
+            scope.setParentScope(null);
+        } catch (Exception e) {
+            throw new RuntimeException("Exception", e);
         } finally {
             Context.exit();
         }
+        return scope;
     }
 
     /**
@@ -69,7 +62,7 @@
     public static void fillNewObjectModelWithFOM(ObjectModel newObjectModel, 
                                                             final Map objectModel, final
Parameters parameters) {
         Map expressionContext = TemplateObjectModelHelper.getTemplateObjectModel(objectModel,
parameters);
-        FlowObjectModelHelper.addJavaPackages(expressionContext);
+        //FlowObjectModelHelper.addJavaPackages(expressionContext);
         
         //FIXME: It's a temporary code!
         ((Map)newObjectModel.get("cocoon")).putAll((Map)expressionContext.get("cocoon"));
@@ -80,36 +73,6 @@
             newObjectModel.put(key, expressionContext.get(key));
         }
         newObjectModel.put(org.apache.cocoon.objectmodel.ObjectModel.CONTEXTBEAN, FlowHelper.getContextObject(objectModel));
-    }
-
-    /**
-     * Add java packages to object model. Allows to construct java objects.
-     * @param objectModel usually the result of invoking getTemplateObjectModel
-     */
-    public static void addJavaPackages( Map objectModel ) {
-        Object javaPkg = FOM_JavaScriptFlowHelper.getJavaPackage(objectModel);
-        Object pkgs = FOM_JavaScriptFlowHelper.getPackages(objectModel);
-        
-        // packages might have already been set up if flowscript is being used
-        if ( javaPkg != null && pkgs != null ) {
-            objectModel.put( "Packages", javaPkg );
-            objectModel.put( "java", pkgs );
-        } else { 
-            Context.enter();
-            try {
-                final String JAVA_PACKAGE = "JavaPackage";
-                ClassLoader cl = Thread.currentThread().getContextClassLoader();
-                // FIXME - NativeJavaPackage is an internal class which we should not use
-                Scriptable newPackages = new NativeJavaPackage( "", cl );
-                newPackages.setParentScope( getScope() );
-                newPackages.setPrototype( ScriptableObject.getClassPrototype(   getScope(),
-                                                                                JAVA_PACKAGE
) );
-                objectModel.put( "Packages", newPackages );
-                objectModel.put( "java", ScriptableObject.getProperty( getScope(), "java"
) );
-            } finally {
-                Context.exit();
-            }
-        }
     }
 
 }

Modified: cocoon/trunk/core/cocoon-expression-language/cocoon-expression-language-impl/src/main/resources/META-INF/cocoon/spring/JavaScriptCompiler.xml
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-expression-language/cocoon-expression-language-impl/src/main/resources/META-INF/cocoon/spring/JavaScriptCompiler.xml?view=diff&rev=561357&r1=561356&r2=561357
==============================================================================
--- cocoon/trunk/core/cocoon-expression-language/cocoon-expression-language-impl/src/main/resources/META-INF/cocoon/spring/JavaScriptCompiler.xml
(original)
+++ cocoon/trunk/core/cocoon-expression-language/cocoon-expression-language-impl/src/main/resources/META-INF/cocoon/spring/JavaScriptCompiler.xml
Tue Jul 31 08:12:52 2007
@@ -15,11 +15,14 @@
   See the License for the specific language governing permissions and
   limitations under the License.
 -->
-<!-- SVN $Id $ -->
+<!-- SVN $Id: $ -->
 <beans xmlns="http://www.springframework.org/schema/beans"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
 
-  <bean name="org.apache.cocoon.components.expression.ExpressionCompiler/js" class="org.apache.cocoon.components.expression.javascript.JavaScriptCompiler"/>
+  <bean name="org.apache.cocoon.components.expression.ExpressionCompiler/js" 
+        class="org.apache.cocoon.components.expression.javascript.JavaScriptCompiler">
+    <property name="rootScope" ref="org.mozilla.javascript.Scriptable/rootScope"/>
+  </bean>
 
 </beans>

Modified: cocoon/trunk/core/cocoon-expression-language/cocoon-expression-language-impl/src/main/resources/META-INF/cocoon/spring/ObjectModel.xml
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-expression-language/cocoon-expression-language-impl/src/main/resources/META-INF/cocoon/spring/ObjectModel.xml?view=diff&rev=561357&r1=561356&r2=561357
==============================================================================
--- cocoon/trunk/core/cocoon-expression-language/cocoon-expression-language-impl/src/main/resources/META-INF/cocoon/spring/ObjectModel.xml
(original)
+++ cocoon/trunk/core/cocoon-expression-language/cocoon-expression-language-impl/src/main/resources/META-INF/cocoon/spring/ObjectModel.xml
Tue Jul 31 08:12:52 2007
@@ -30,6 +30,8 @@
         <property name="initialEntries">
           <map>
             <entry key="cocoon" value-ref="org.apache.cocoon.objectmodel.provider.CocoonEntryObjectModelProvider"/>
+            <entry key="Packages" value-ref="org.apache.cocoon.objectmodel.provider.PackagesEntryObjectModelProvider"/>
+            <entry key="java" value-ref="org.apache.cocoon.objectmodel.provider.JavaEntryObjectModelProvider"/>
           </map>
         </property>        
     </bean>

Modified: cocoon/trunk/core/cocoon-expression-language/cocoon-expression-language-impl/src/main/resources/META-INF/cocoon/spring/ObjectModelProviders.xml
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-expression-language/cocoon-expression-language-impl/src/main/resources/META-INF/cocoon/spring/ObjectModelProviders.xml?view=diff&rev=561357&r1=561356&r2=561357
==============================================================================
--- cocoon/trunk/core/cocoon-expression-language/cocoon-expression-language-impl/src/main/resources/META-INF/cocoon/spring/ObjectModelProviders.xml
(original)
+++ cocoon/trunk/core/cocoon-expression-language/cocoon-expression-language-impl/src/main/resources/META-INF/cocoon/spring/ObjectModelProviders.xml
Tue Jul 31 08:12:52 2007
@@ -20,11 +20,23 @@
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
 
-    <!-- ObjectModelEntry provider for cocoon -->
+    <!-- ObjectModelEntry provider for 'cocoon' -->
     <bean name="org.apache.cocoon.objectmodel.provider.CocoonEntryObjectModelProvider"
           class="org.apache.cocoon.objectmodel.provider.CocoonEntryObjectModelProvider">
         <property name="settings" ref="org.apache.cocoon.configuration.Settings"/>
         <property name="processInfoProvider" ref="org.apache.cocoon.processing.ProcessInfoProvider"/>
+    </bean>
+    
+    <!-- ObjectModelEntry provider for 'Packages' -->
+    <bean name="org.apache.cocoon.objectmodel.provider.PackagesEntryObjectModelProvider"
+          class="org.apache.cocoon.objectmodel.provider.PackagesEntryObjectModelProvider">
+      <property name="rootScope" ref="org.mozilla.javascript.Scriptable/rootScope"/>
+    </bean>
+    
+    <!-- ObjectModelEntry provider for 'java' -->
+    <bean name="org.apache.cocoon.objectmodel.provider.JavaEntryObjectModelProvider"
+          class="org.apache.cocoon.objectmodel.provider.JavaEntryObjectModelProvider">
+      <property name="rootScope" ref="org.mozilla.javascript.Scriptable/rootScope"/>
     </bean>
 
 </beans>

Added: cocoon/trunk/core/cocoon-expression-language/cocoon-expression-language-impl/src/main/resources/META-INF/cocoon/spring/RhinoScope.xml
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-expression-language/cocoon-expression-language-impl/src/main/resources/META-INF/cocoon/spring/RhinoScope.xml?view=auto&rev=561357
==============================================================================
--- cocoon/trunk/core/cocoon-expression-language/cocoon-expression-language-impl/src/main/resources/META-INF/cocoon/spring/RhinoScope.xml
(added)
+++ cocoon/trunk/core/cocoon-expression-language/cocoon-expression-language-impl/src/main/resources/META-INF/cocoon/spring/RhinoScope.xml
Tue Jul 31 08:12:52 2007
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+  
+  http://www.apache.org/licenses/LICENSE-2.0
+  
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+<!-- SVN $Id: $ -->
+<beans xmlns="http://www.springframework.org/schema/beans"
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xmlns:configurator="http://cocoon.apache.org/schema/configurator"
+  xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
+  http://cocoon.apache.org/schema/configurator http://cocoon.apache.org/schema/configurator/cocoon-configurator-1.0.1.xsd">
+  
+  <bean name="org.mozilla.javascript.Scriptable/rootScope" 
+        class="org.apache.cocoon.components.expression.helpers.RhinoScopeFactory" factory-method="createRhinoScope">
+  </bean>
+  
+</beans>

Propchange: cocoon/trunk/core/cocoon-expression-language/cocoon-expression-language-impl/src/main/resources/META-INF/cocoon/spring/RhinoScope.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/trunk/core/cocoon-expression-language/cocoon-expression-language-impl/src/main/resources/META-INF/cocoon/spring/RhinoScope.xml
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: cocoon/trunk/core/cocoon-expression-language/cocoon-expression-language-impl/src/test/java/org/apache/cocoon/components/expression/javascript/JavaScriptTestCase.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-expression-language/cocoon-expression-language-impl/src/test/java/org/apache/cocoon/components/expression/javascript/JavaScriptTestCase.java?view=diff&rev=561357&r1=561356&r2=561357
==============================================================================
--- cocoon/trunk/core/cocoon-expression-language/cocoon-expression-language-impl/src/test/java/org/apache/cocoon/components/expression/javascript/JavaScriptTestCase.java
(original)
+++ cocoon/trunk/core/cocoon-expression-language/cocoon-expression-language-impl/src/test/java/org/apache/cocoon/components/expression/javascript/JavaScriptTestCase.java
Tue Jul 31 08:12:52 2007
@@ -21,8 +21,8 @@
 import junit.framework.TestCase;
 
 import org.apache.cocoon.components.expression.Expression;
-import org.apache.cocoon.components.expression.ExpressionCompiler;
 import org.apache.cocoon.components.expression.ExpressionException;
+import org.apache.cocoon.components.expression.helpers.RhinoScopeFactory;
 import org.apache.cocoon.objectmodel.ObjectModel;
 import org.apache.cocoon.objectmodel.ObjectModelImpl;
 
@@ -32,14 +32,16 @@
 public class JavaScriptTestCase extends TestCase {
 
     public void testExpression() throws ExpressionException {
-        ExpressionCompiler compiler = new JavaScriptCompiler();
+        JavaScriptCompiler compiler = new JavaScriptCompiler();
+        compiler.setRootScope(RhinoScopeFactory.createRhinoScope());
         Expression expression = compiler.compile("js", "1+2");
         Object result = expression.evaluate(new ObjectModelImpl());
         assertEquals(new Integer(3), result);
     }
 
     public void testContextExpression() throws ExpressionException {
-        ExpressionCompiler compiler = new JavaScriptCompiler();
+        JavaScriptCompiler compiler = new JavaScriptCompiler();
+        compiler.setRootScope(RhinoScopeFactory.createRhinoScope());
         ObjectModel objectModel = new ObjectModelImpl();
         objectModel.put("a", new Long(1));
         objectModel.put("b", new Long(2));
@@ -49,7 +51,8 @@
     }
 
     public void testIterator() throws ExpressionException {
-        ExpressionCompiler compiler = new JavaScriptCompiler();
+        JavaScriptCompiler compiler = new JavaScriptCompiler();
+        compiler.setRootScope(RhinoScopeFactory.createRhinoScope());
         ObjectModel objectModel = new ObjectModelImpl();
         String[] arr = { "foo" };
         objectModel.put("arr", arr);

Modified: cocoon/trunk/core/cocoon-expression-language/cocoon-expression-language-impl/src/test/resources/org/apache/cocoon/components/expression/ExpressionTestCase.spring.xml
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-expression-language/cocoon-expression-language-impl/src/test/resources/org/apache/cocoon/components/expression/ExpressionTestCase.spring.xml?view=diff&rev=561357&r1=561356&r2=561357
==============================================================================
--- cocoon/trunk/core/cocoon-expression-language/cocoon-expression-language-impl/src/test/resources/org/apache/cocoon/components/expression/ExpressionTestCase.spring.xml
(original)
+++ cocoon/trunk/core/cocoon-expression-language/cocoon-expression-language-impl/src/test/resources/org/apache/cocoon/components/expression/ExpressionTestCase.spring.xml
Tue Jul 31 08:12:52 2007
@@ -24,5 +24,6 @@
   <import resource="classpath:META-INF/cocoon/spring/JavaScriptCompiler.xml"/>
   <import resource="classpath:META-INF/cocoon/spring/JexlCompiler.xml"/>
   <import resource="classpath:META-INF/cocoon/spring/JXPathCompiler.xml"/>
+  <import resource="classpath:META-INF/cocoon/spring/RhinoScope.xml"/>
   
 </beans>

Modified: cocoon/trunk/core/cocoon-expression-language/cocoon-expression-language-impl/src/test/resources/org/apache/cocoon/environment/FOMTestCase.spring.xml
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-expression-language/cocoon-expression-language-impl/src/test/resources/org/apache/cocoon/environment/FOMTestCase.spring.xml?view=diff&rev=561357&r1=561356&r2=561357
==============================================================================
--- cocoon/trunk/core/cocoon-expression-language/cocoon-expression-language-impl/src/test/resources/org/apache/cocoon/environment/FOMTestCase.spring.xml
(original)
+++ cocoon/trunk/core/cocoon-expression-language/cocoon-expression-language-impl/src/test/resources/org/apache/cocoon/environment/FOMTestCase.spring.xml
Tue Jul 31 08:12:52 2007
@@ -24,6 +24,7 @@
   <import resource="classpath:META-INF/cocoon/spring/JexlCompiler.xml"/>
   <import resource="classpath:META-INF/cocoon/spring/JXPathCompiler.xml"/>
   <import resource="classpath:META-INF/cocoon/spring/ObjectModelProviders.xml"/>
+  <import resource="classpath:META-INF/cocoon/spring/RhinoScope.xml"/>
   
   <!-- Redefining this bean instead of importing because originally it is in "call" scope
-->
   <bean name="org.apache.cocoon.objectmodel.ObjectModel" class="org.apache.cocoon.objectmodel.ObjectModelImpl">



Mime
View raw message