cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r416393 - /cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/environment/TemplateObjectModelHelper.java
Date Thu, 22 Jun 2006 15:17:45 GMT
Author: cziegeler
Date: Thu Jun 22 08:17:44 2006
New Revision: 416393

URL: http://svn.apache.org/viewvc?rev=416393&view=rev
Log:
Move javascript related stuff out of the TemplateObjectModelHelper

Modified:
    cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/environment/TemplateObjectModelHelper.java

Modified: cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/environment/TemplateObjectModelHelper.java
URL: http://svn.apache.org/viewvc/cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/environment/TemplateObjectModelHelper.java?rev=416393&r1=416392&r2=416393&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/environment/TemplateObjectModelHelper.java
(original)
+++ cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/environment/TemplateObjectModelHelper.java
Thu Jun 22 08:17:44 2006
@@ -20,15 +20,11 @@
 import java.util.HashMap;
 import java.util.Map;
 
-import org.apache.avalon.framework.CascadingRuntimeException;
 import org.apache.avalon.framework.parameters.Parameters;
 import org.apache.cocoon.components.flow.FlowHelper;
-import org.apache.cocoon.components.flow.javascript.fom.FOM_JavaScriptFlowHelper;
 import org.apache.commons.jxpath.DynamicPropertyHandler;
 import org.apache.commons.jxpath.JXPathBeanInfo;
 import org.apache.commons.jxpath.JXPathIntrospector;
-import org.mozilla.javascript.*;
-import org.mozilla.javascript.Context;
 
 
 /**
@@ -40,32 +36,10 @@
  * @version $Id: TemplateObjectModelHelper.java 359757 2005-12-29 08:53:30Z cziegeler $
  */
 public class TemplateObjectModelHelper {
-    private static Scriptable rootScope = null;
 
     /** Avoid instantiation */
     private TemplateObjectModelHelper() {}
 
-    public static Scriptable getScope() {
-        Context ctx = Context.enter();
-        try {
-            // Create it if never used up to now
-            if (rootScope == null) {
-                rootScope = ctx.initStandardObjects(null);
-            }
-            Scriptable scope = null;
-            try {
-                scope = ctx.newObject(rootScope);
-            } catch (Exception e) {
-                throw new CascadingRuntimeException("Exception", e);
-            }
-            scope.setPrototype(rootScope);
-            scope.setParentScope(null);
-            return scope;
-        } finally {
-            Context.exit();
-        }
-    }
-
     public static void fillContext(Object contextObject, Map map) {
         // Hack: I use jxpath to populate the context object's properties
         // in the jexl context
@@ -120,28 +94,21 @@
         // first create the "cocoon object":
         final Map cocoon = new HashMap();
 
-        // Needed for the FOM wrappers
-        Context.enter();
-        try {
-            // cocoon.request
-            final Request request = ObjectModelHelper.getRequest( objectModel );
-            cocoon.put("request", request);
-
-            // cocoon.session
-            final Session session = request.getSession(false);
-            if (session != null) {
-                cocoon.put("session", session);
-            }
-
-            // cocoon.context
-            final org.apache.cocoon.environment.Context context =
-                ObjectModelHelper.getContext( objectModel );
-            cocoon.put("context", context);
-
-        } finally {
-            Context.exit();
+        // cocoon.request
+        final Request request = ObjectModelHelper.getRequest( objectModel );
+        cocoon.put("request", request);
+
+        // cocoon.session
+        final Session session = request.getSession(false);
+        if (session != null) {
+            cocoon.put("session", session);
         }
 
+        // cocoon.context
+        final org.apache.cocoon.environment.Context context =
+            ObjectModelHelper.getContext( objectModel );
+        cocoon.put("context", context);
+
         // cocoon.continuation
         final Object cont = FlowHelper.getWebContinuation(objectModel);
         if ( cont != null ) {
@@ -165,35 +132,5 @@
         }
 
         return map;
-    }
-
-    /**
-     * Add java packages to object model. Allows to construct java objects.
-     * @param objectModel usually the result of invoking getTemplateObjectModel
-     */
-    public static Object 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();
-                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();
-            }
-        }
-        return objectModel;
     }
 }



Mime
View raw message