cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r497332 - in /cocoon/trunk/blocks/cocoon-flowscript/cocoon-flowscript-impl: src/changes/ src/changes/changes.xml src/main/java/org/apache/cocoon/components/flow/javascript/fom/FOM_Cocoon.java status.xml
Date Thu, 18 Jan 2007 07:33:00 GMT
Author: cziegeler
Date: Wed Jan 17 23:32:59 2007
New Revision: 497332

URL: http://svn.apache.org/viewvc?view=rev&rev=497332
Log:
Make settings bean and web application context available via the cocoon object in
flow script (cocoon.settings and cocoon.applicationContext).

Added:
    cocoon/trunk/blocks/cocoon-flowscript/cocoon-flowscript-impl/src/changes/
    cocoon/trunk/blocks/cocoon-flowscript/cocoon-flowscript-impl/src/changes/changes.xml 
 (with props)
Removed:
    cocoon/trunk/blocks/cocoon-flowscript/cocoon-flowscript-impl/status.xml
Modified:
    cocoon/trunk/blocks/cocoon-flowscript/cocoon-flowscript-impl/src/main/java/org/apache/cocoon/components/flow/javascript/fom/FOM_Cocoon.java

Added: cocoon/trunk/blocks/cocoon-flowscript/cocoon-flowscript-impl/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-flowscript/cocoon-flowscript-impl/src/changes/changes.xml?view=auto&rev=497332
==============================================================================
--- cocoon/trunk/blocks/cocoon-flowscript/cocoon-flowscript-impl/src/changes/changes.xml (added)
+++ cocoon/trunk/blocks/cocoon-flowscript/cocoon-flowscript-impl/src/changes/changes.xml Wed
Jan 17 23:32:59 2007
@@ -0,0 +1,38 @@
+<?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.
+-->
+<!--+
+    | @version $Id$
+    +-->
+<document>
+  <properties>
+    <title>Changes Cocoon FlowScript Implementation</title>
+  </properties>
+  <body>
+    <release version="1.0.0-M2-SNAPSHOT" date="2007-00-00" description="unreleased">
+      <action dev="CZ" type="add">
+        Make settings bean and web application context available via the cocoon object in
+        flow script (cocoon.settings and cocoon.applicationContext).
+      </action>
+      <action dev="JH" type="fix" fixes-bug="COCOON-1811" due-to="Rob Berens">
+        Allow dynamic loading of JavaScript objects even when scope is locked.
+      </action>
+    </release> 
+  </body>
+</document>

Propchange: cocoon/trunk/blocks/cocoon-flowscript/cocoon-flowscript-impl/src/changes/changes.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/trunk/blocks/cocoon-flowscript/cocoon-flowscript-impl/src/changes/changes.xml
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: cocoon/trunk/blocks/cocoon-flowscript/cocoon-flowscript-impl/src/main/java/org/apache/cocoon/components/flow/javascript/fom/FOM_Cocoon.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-flowscript/cocoon-flowscript-impl/src/main/java/org/apache/cocoon/components/flow/javascript/fom/FOM_Cocoon.java?view=diff&rev=497332&r1=497331&r2=497332
==============================================================================
--- cocoon/trunk/blocks/cocoon-flowscript/cocoon-flowscript-impl/src/main/java/org/apache/cocoon/components/flow/javascript/fom/FOM_Cocoon.java
(original)
+++ cocoon/trunk/blocks/cocoon-flowscript/cocoon-flowscript-impl/src/main/java/org/apache/cocoon/components/flow/javascript/fom/FOM_Cocoon.java
Wed Jan 17 23:32:59 2007
@@ -39,11 +39,13 @@
 import org.apache.cocoon.components.flow.ContinuationsManager;
 import org.apache.cocoon.components.flow.WebContinuation;
 import org.apache.cocoon.components.flow.Interpreter.Argument;
+import org.apache.cocoon.configuration.Settings;
 import org.apache.cocoon.environment.ObjectModelHelper;
 import org.apache.cocoon.environment.Redirector;
 import org.apache.cocoon.environment.Request;
 import org.apache.cocoon.environment.Response;
 import org.apache.cocoon.environment.Session;
+import org.apache.cocoon.spring.configurator.WebAppContextUtils;
 import org.apache.cocoon.util.ClassUtils;
 import org.mozilla.javascript.JavaScriptException;
 import org.mozilla.javascript.NativeJavaClass;
@@ -54,6 +56,7 @@
 import org.mozilla.javascript.Undefined;
 import org.mozilla.javascript.Wrapper;
 import org.mozilla.javascript.continuations.Continuation;
+import org.springframework.web.context.WebApplicationContext;
 
 /**
  * Implementation of FOM (Flow Object Model).
@@ -128,10 +131,9 @@
             if (session != null) {
                 return session;
             }
-            Map objectModel = ContextHelper.getObjectModel(this.avalonContext);         
  
             session = new FOM_Session(
                     getParentScope(),
-                    ObjectModelHelper.getRequest(objectModel).getSession(true));
+                    ObjectModelHelper.getRequest(this.getObjectModel()).getSession(true));
             return session;
         }
 
@@ -139,10 +141,9 @@
             if (request != null) {
                 return request;
             }
-            Map objectModel = ContextHelper.getObjectModel(this.avalonContext);
             request = new FOM_Request(
                     getParentScope(),
-                    ObjectModelHelper.getRequest(objectModel));
+                    ObjectModelHelper.getRequest(this.getObjectModel()));
             return request;
         }
 
@@ -150,10 +151,9 @@
             if (context != null) {
                 return context;
             }
-            Map objectModel = ContextHelper.getObjectModel(this.avalonContext);
             context = new FOM_Context(
                     getParentScope(),
-                    ObjectModelHelper.getContext(objectModel));
+                    ObjectModelHelper.getContext(this.getObjectModel()));
             return context;
         }
 
@@ -161,9 +161,8 @@
             if (response != null) {
                 return response;
             }
-            Map objectModel = ContextHelper.getObjectModel(this.avalonContext);
             response = org.mozilla.javascript.Context.toObject(
-                    ObjectModelHelper.getResponse(objectModel),
+                    ObjectModelHelper.getResponse(this.getObjectModel()),
                     getParentScope());
             return response;
         }
@@ -183,6 +182,10 @@
         public void setParameters(Scriptable parameters) {
             this.parameters = parameters;
         }
+
+        protected Map getObjectModel() {
+            return ContextHelper.getObjectModel(this.avalonContext);
+        }
     }
 
     private CallContext currentCall;
@@ -621,7 +624,7 @@
      * @return The request
      */
     public Request getRequest() {
-        return ObjectModelHelper.getRequest(ContextHelper.getObjectModel(currentCall.avalonContext));
+        return ObjectModelHelper.getRequest(currentCall.getObjectModel());
     }
 
     /**
@@ -629,7 +632,7 @@
      * @return The session (may be null)
      */
     public Session getSession() {
-        return ObjectModelHelper.getRequest(ContextHelper.getObjectModel(currentCall.avalonContext)).getSession(true);
+        return ObjectModelHelper.getRequest(currentCall.getObjectModel()).getSession(true);
     }
 
     /**
@@ -637,7 +640,7 @@
      * @return The response
      */
     public Response getResponse() {
-        return ObjectModelHelper.getResponse(ContextHelper.getObjectModel(currentCall.avalonContext));
+        return ObjectModelHelper.getResponse(currentCall.getObjectModel());
     }
 
     /**
@@ -645,7 +648,37 @@
      * @return The context
      */
     public org.apache.cocoon.environment.Context getContext() {
-        return ObjectModelHelper.getContext(ContextHelper.getObjectModel(currentCall.avalonContext));
+        return ObjectModelHelper.getContext(currentCall.getObjectModel());
+    }
+
+    /**
+     * Get the current settings object.
+     */
+    public Settings getSettings() {
+        return (Settings)WebAppContextUtils.getCurrentWebApplicationContext().getBean(Settings.ROLE);
+    }
+
+    /**
+     * Get the current settings object for java script.
+     */
+    public Scriptable jsGet_settings() {
+        final Settings s = this.getSettings();
+        return org.mozilla.javascript.Context.toObject(s, getParentScope());
+    }
+    
+    /**
+     * Get the current application context.
+     */
+    public WebApplicationContext getApplicationContext() {
+        return WebAppContextUtils.getCurrentWebApplicationContext();
+    }
+
+    /**
+     * Get the current application context for java script.
+     */
+    public Scriptable jsGet_applicationContext() {
+        final WebApplicationContext w = this.getApplicationContext();
+        return org.mozilla.javascript.Context.toObject(w, getParentScope());
     }
 
     /**
@@ -653,7 +686,7 @@
      * @return The object model
      */
     public Map getObjectModel() {
-        return ContextHelper.getObjectModel(currentCall.avalonContext);
+        return currentCall.getObjectModel();
     }
 
     private Context getAvalonContext() {



Mime
View raw message