haul 2002/07/02 01:32:07 Modified: src/java/org/apache/cocoon/environment AbstractEnvironment.java Environment.java src/java/org/apache/cocoon/environment/wrapper EnvironmentWrapper.java src/java/org/apache/cocoon/components/treeprocessor TreeProcessor.java src/java/org/apache/cocoon/components/source SitemapSource.java src/java/org/apache/cocoon/components/source/impl SitemapSource.java src/java/org/apache/cocoon/components/flow AbstractInterpreter.java ContinuationsManager.java ContinuationsManagerImpl.java Interpreter.java InterpreterSelector.java ScriptSource.java WebContinuation.java src/java/org/apache/cocoon/components/flow/javascript JSCocoon.java JSGlobal.java JSLog.java JSWebContinuation.java JavaScriptInterpreter.java system.js Added: src/java/org/apache/cocoon/components/flow/javascript ScriptableMap.java Log: <action dev="CH" type="add"> Added support for actions and In-/OutputModules to the JavaScript Flow. Caveat: Modifications of the Redirector object are ignored. </action> Revision Changes Path 1.23 +21 -1 xml-cocoon2/src/java/org/apache/cocoon/environment/AbstractEnvironment.java Index: AbstractEnvironment.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/environment/AbstractEnvironment.java,v retrieving revision 1.22 retrieving revision 1.23 diff -u -r1.22 -r1.23 --- AbstractEnvironment.java 13 Jun 2002 09:28:15 -0000 1.22 +++ AbstractEnvironment.java 2 Jul 2002 08:32:06 -0000 1.23 @@ -51,6 +51,7 @@ package org.apache.cocoon.environment; import org.apache.avalon.excalibur.collections.IteratorEnumeration; +import org.apache.avalon.framework.component.ComponentManager; import org.apache.avalon.framework.component.ComponentException; import org.apache.avalon.framework.logger.AbstractLoggable; import org.apache.cocoon.ProcessingException; @@ -107,6 +108,25 @@ /** The attributes */ private Map attributes = new HashMap(); + + /** The current manager */ + protected ComponentManager manager = null; + + /** + * The treeprocessor sets up new managers per sitemap. Get the + * "current" one for this environment. + */ + public ComponentManager getComponentManager(){ + return this.manager; + } + + /** + * The treeprocessor sets up new managers per sitemap. Set the + * "current" one for this environment. + */ + public void setComponentManager(ComponentManager manager){ + this.manager = manager; + } /** * Constructs the abstract enviornment 1.12 +13 -1 xml-cocoon2/src/java/org/apache/cocoon/environment/Environment.java Index: Environment.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/environment/Environment.java,v retrieving revision 1.11 retrieving revision 1.12 diff -u -r1.11 -r1.12 --- Environment.java 6 Jun 2002 14:43:40 -0000 1.11 +++ Environment.java 2 Jul 2002 08:32:06 -0000 1.12 @@ -50,6 +50,7 @@ */ package org.apache.cocoon.environment; +import org.apache.avalon.framework.component.ComponentManager; import org.apache.cocoon.components.source.SourceHandler; import org.apache.excalibur.xmlizer.XMLizer; import java.io.IOException; @@ -70,6 +71,11 @@ extends SourceResolver { /** + * Get the <code>ComponentManager</code> for the current request. + */ + ComponentManager getComponentManager(); + + /** * Get the <code>SourceHandler</code> for the current request * @deprecated Not used anymore (FIXME - This should be removed) */ @@ -177,6 +183,12 @@ * environment is not able to test it */ boolean isResponseModified(long lastModified); + + /** + * Set the <code>ComponentManager</code> for the current request. + */ + void setComponentManager(ComponentManager manager); + /** * Mark the response as not modified. 1.17 +17 -1 xml-cocoon2/src/java/org/apache/cocoon/environment/wrapper/EnvironmentWrapper.java Index: EnvironmentWrapper.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/environment/wrapper/EnvironmentWrapper.java,v retrieving revision 1.16 retrieving revision 1.17 diff -u -r1.16 -r1.17 --- EnvironmentWrapper.java 3 Jun 2002 11:45:52 -0000 1.16 +++ EnvironmentWrapper.java 2 Jul 2002 08:32:07 -0000 1.17 @@ -50,6 +50,7 @@ */ package org.apache.cocoon.environment.wrapper; +import org.apache.avalon.framework.component.ComponentManager; import org.apache.cocoon.ProcessingException; import org.apache.cocoon.environment.AbstractEnvironment; import org.apache.cocoon.environment.Environment; @@ -123,10 +124,25 @@ Logger logger, boolean rawMode) throws MalformedURLException { + this(env, requestURI, queryString, logger, null, false); + } + + /** + * Constructs an EnvironmentWrapper object from a Request + * and Response objects + */ + public EnvironmentWrapper(Environment env, + String requestURI, + String queryString, + Logger logger, + ComponentManager manager, + boolean rawMode) + throws MalformedURLException { super(env.getURI(), env.getView(), env.getRootContext(), env.getAction()); this.setComponents(env.getSourceResolver(), null); this.setLogger(logger); this.environment = env; + this.manager = manager; this.context = env.getContext(); this.prefix = new StringBuffer(env.getURIPrefix()); 1.17 +2 -1 xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/TreeProcessor.java Index: TreeProcessor.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/TreeProcessor.java,v retrieving revision 1.16 retrieving revision 1.17 diff -u -r1.16 -r1.17 --- TreeProcessor.java 13 Jun 2002 09:28:15 -0000 1.16 +++ TreeProcessor.java 2 Jul 2002 08:32:07 -0000 1.17 @@ -323,6 +323,7 @@ // and now process CocoonComponentManager.enterEnvironment(environment, environment.getObjectModel(), this); + environment.setComponentManager(this.manager); try { return this.rootNode.invoke(environment, context); } finally { 1.19 +2 -2 xml-cocoon2/src/java/org/apache/cocoon/components/source/SitemapSource.java Index: SitemapSource.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/source/SitemapSource.java,v retrieving revision 1.18 retrieving revision 1.19 diff -u -r1.18 -r1.19 --- SitemapSource.java 13 Jun 2002 09:28:15 -0000 1.18 +++ SitemapSource.java 2 Jul 2002 08:32:07 -0000 1.19 @@ -189,7 +189,7 @@ "cocoon://" + requestURI : "cocoon://" + requestURI + "?" + queryString; - this.environment = new EnvironmentWrapper(env, requestURI, queryString, logger, rawMode); + this.environment = new EnvironmentWrapper(env, requestURI, queryString, logger, manager, rawMode); this.uri = uri; this.refresh(); } 1.14 +2 -2 xml-cocoon2/src/java/org/apache/cocoon/components/source/impl/SitemapSource.java Index: SitemapSource.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/source/impl/SitemapSource.java,v retrieving revision 1.13 retrieving revision 1.14 diff -u -r1.13 -r1.14 --- SitemapSource.java 12 Jun 2002 10:14:53 -0000 1.13 +++ SitemapSource.java 2 Jul 2002 08:32:07 -0000 1.14 @@ -200,7 +200,7 @@ "cocoon://" + requestURI : "cocoon://" + requestURI + "?" + queryString; - this.environment = new EnvironmentWrapper(env, requestURI, queryString, logger, rawMode); + this.environment = new EnvironmentWrapper(env, requestURI, queryString, logger, manager, rawMode); this.uri = uri; this.discardValidity(); } 1.4 +50 -0 xml-cocoon2/src/java/org/apache/cocoon/components/flow/AbstractInterpreter.java Index: AbstractInterpreter.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/flow/AbstractInterpreter.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- AbstractInterpreter.java 13 Jun 2002 09:28:14 -0000 1.3 +++ AbstractInterpreter.java 2 Jul 2002 08:32:07 -0000 1.4 @@ -1,3 +1,53 @@ +/* + + ============================================================================ + The Apache Software License, Version 1.1 + ============================================================================ + + Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved. + + Redistribution and use in source and binary forms, with or without modifica- + tion, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + 3. The end-user documentation included with the redistribution, if any, must + include the following acknowledgment: "This product includes software + developed by the Apache Software Foundation (http://www.apache.org/)." + Alternately, this acknowledgment may appear in the software itself, if + and wherever such third-party acknowledgments normally appear. + + 4. The names "Apache Cocoon" and "Apache Software Foundation" must not be + used to endorse or promote products derived from this software without + prior written permission. For written permission, please contact + [EMAIL PROTECTED] + + 5. Products derived from this software may not be called "Apache", nor may + "Apache" appear in their name, without prior written permission of the + Apache Software Foundation. + + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, + INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- + DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + This software consists of voluntary contributions made by many individuals + on behalf of the Apache Software Foundation and was originally created by + Stefano Mazzocchi <[EMAIL PROTECTED]>. For more information on the Apache + Software Foundation, please see <http://www.apache.org/>. + +*/ package org.apache.cocoon.components.flow; import java.lang.System; 1.2 +50 -0 xml-cocoon2/src/java/org/apache/cocoon/components/flow/ContinuationsManager.java Index: ContinuationsManager.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/flow/ContinuationsManager.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- ContinuationsManager.java 19 May 2002 19:19:38 -0000 1.1 +++ ContinuationsManager.java 2 Jul 2002 08:32:07 -0000 1.2 @@ -1,3 +1,53 @@ +/* + + ============================================================================ + The Apache Software License, Version 1.1 + ============================================================================ + + Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved. + + Redistribution and use in source and binary forms, with or without modifica- + tion, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + 3. The end-user documentation included with the redistribution, if any, must + include the following acknowledgment: "This product includes software + developed by the Apache Software Foundation (http://www.apache.org/)." + Alternately, this acknowledgment may appear in the software itself, if + and wherever such third-party acknowledgments normally appear. + + 4. The names "Apache Cocoon" and "Apache Software Foundation" must not be + used to endorse or promote products derived from this software without + prior written permission. For written permission, please contact + [EMAIL PROTECTED] + + 5. Products derived from this software may not be called "Apache", nor may + "Apache" appear in their name, without prior written permission of the + Apache Software Foundation. + + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, + INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- + DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + This software consists of voluntary contributions made by many individuals + on behalf of the Apache Software Foundation and was originally created by + Stefano Mazzocchi <[EMAIL PROTECTED]>. For more information on the Apache + Software Foundation, please see <http://www.apache.org/>. + +*/ package org.apache.cocoon.components.flow; /** 1.2 +50 -0 xml-cocoon2/src/java/org/apache/cocoon/components/flow/ContinuationsManagerImpl.java Index: ContinuationsManagerImpl.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/flow/ContinuationsManagerImpl.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- ContinuationsManagerImpl.java 19 May 2002 19:19:38 -0000 1.1 +++ ContinuationsManagerImpl.java 2 Jul 2002 08:32:07 -0000 1.2 @@ -1,3 +1,53 @@ +/* + + ============================================================================ + The Apache Software License, Version 1.1 + ============================================================================ + + Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved. + + Redistribution and use in source and binary forms, with or without modifica- + tion, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + 3. The end-user documentation included with the redistribution, if any, must + include the following acknowledgment: "This product includes software + developed by the Apache Software Foundation (http://www.apache.org/)." + Alternately, this acknowledgment may appear in the software itself, if + and wherever such third-party acknowledgments normally appear. + + 4. The names "Apache Cocoon" and "Apache Software Foundation" must not be + used to endorse or promote products derived from this software without + prior written permission. For written permission, please contact + [EMAIL PROTECTED] + + 5. Products derived from this software may not be called "Apache", nor may + "Apache" appear in their name, without prior written permission of the + Apache Software Foundation. + + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, + INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- + DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + This software consists of voluntary contributions made by many individuals + on behalf of the Apache Software Foundation and was originally created by + Stefano Mazzocchi <[EMAIL PROTECTED]>. For more information on the Apache + Software Foundation, please see <http://www.apache.org/>. + +*/ package org.apache.cocoon.components.flow; import java.security.SecureRandom; 1.3 +50 -0 xml-cocoon2/src/java/org/apache/cocoon/components/flow/Interpreter.java Index: Interpreter.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/flow/Interpreter.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- Interpreter.java 13 Jun 2002 09:28:14 -0000 1.2 +++ Interpreter.java 2 Jul 2002 08:32:07 -0000 1.3 @@ -1,3 +1,53 @@ +/* + + ============================================================================ + The Apache Software License, Version 1.1 + ============================================================================ + + Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved. + + Redistribution and use in source and binary forms, with or without modifica- + tion, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + 3. The end-user documentation included with the redistribution, if any, must + include the following acknowledgment: "This product includes software + developed by the Apache Software Foundation (http://www.apache.org/)." + Alternately, this acknowledgment may appear in the software itself, if + and wherever such third-party acknowledgments normally appear. + + 4. The names "Apache Cocoon" and "Apache Software Foundation" must not be + used to endorse or promote products derived from this software without + prior written permission. For written permission, please contact + [EMAIL PROTECTED] + + 5. Products derived from this software may not be called "Apache", nor may + "Apache" appear in their name, without prior written permission of the + Apache Software Foundation. + + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, + INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- + DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + This software consists of voluntary contributions made by many individuals + on behalf of the Apache Software Foundation and was originally created by + Stefano Mazzocchi <[EMAIL PROTECTED]>. For more information on the Apache + Software Foundation, please see <http://www.apache.org/>. + +*/ package org.apache.cocoon.components.flow; import java.util.List; 1.2 +50 -0 xml-cocoon2/src/java/org/apache/cocoon/components/flow/InterpreterSelector.java Index: InterpreterSelector.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/flow/InterpreterSelector.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- InterpreterSelector.java 19 May 2002 19:19:38 -0000 1.1 +++ InterpreterSelector.java 2 Jul 2002 08:32:07 -0000 1.2 @@ -1,3 +1,53 @@ +/* + + ============================================================================ + The Apache Software License, Version 1.1 + ============================================================================ + + Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved. + + Redistribution and use in source and binary forms, with or without modifica- + tion, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + 3. The end-user documentation included with the redistribution, if any, must + include the following acknowledgment: "This product includes software + developed by the Apache Software Foundation (http://www.apache.org/)." + Alternately, this acknowledgment may appear in the software itself, if + and wherever such third-party acknowledgments normally appear. + + 4. The names "Apache Cocoon" and "Apache Software Foundation" must not be + used to endorse or promote products derived from this software without + prior written permission. For written permission, please contact + [EMAIL PROTECTED] + + 5. Products derived from this software may not be called "Apache", nor may + "Apache" appear in their name, without prior written permission of the + Apache Software Foundation. + + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, + INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- + DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + This software consists of voluntary contributions made by many individuals + on behalf of the Apache Software Foundation and was originally created by + Stefano Mazzocchi <[EMAIL PROTECTED]>. For more information on the Apache + Software Foundation, please see <http://www.apache.org/>. + +*/ package org.apache.cocoon.components.flow; import org.apache.avalon.excalibur.component.ExcaliburComponentSelector; 1.3 +50 -0 xml-cocoon2/src/java/org/apache/cocoon/components/flow/ScriptSource.java Index: ScriptSource.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/flow/ScriptSource.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- ScriptSource.java 13 Jun 2002 09:28:14 -0000 1.2 +++ ScriptSource.java 2 Jul 2002 08:32:07 -0000 1.3 @@ -1,3 +1,53 @@ +/* + + ============================================================================ + The Apache Software License, Version 1.1 + ============================================================================ + + Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved. + + Redistribution and use in source and binary forms, with or without modifica- + tion, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + 3. The end-user documentation included with the redistribution, if any, must + include the following acknowledgment: "This product includes software + developed by the Apache Software Foundation (http://www.apache.org/)." + Alternately, this acknowledgment may appear in the software itself, if + and wherever such third-party acknowledgments normally appear. + + 4. The names "Apache Cocoon" and "Apache Software Foundation" must not be + used to endorse or promote products derived from this software without + prior written permission. For written permission, please contact + [EMAIL PROTECTED] + + 5. Products derived from this software may not be called "Apache", nor may + "Apache" appear in their name, without prior written permission of the + Apache Software Foundation. + + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, + INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- + DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + This software consists of voluntary contributions made by many individuals + on behalf of the Apache Software Foundation and was originally created by + Stefano Mazzocchi <[EMAIL PROTECTED]>. For more information on the Apache + Software Foundation, please see <http://www.apache.org/>. + +*/ package org.apache.cocoon.components.flow; import org.apache.cocoon.environment.Environment; 1.2 +50 -0 xml-cocoon2/src/java/org/apache/cocoon/components/flow/WebContinuation.java Index: WebContinuation.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/flow/WebContinuation.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- WebContinuation.java 19 May 2002 19:19:38 -0000 1.1 +++ WebContinuation.java 2 Jul 2002 08:32:07 -0000 1.2 @@ -1,3 +1,53 @@ +/* + + ============================================================================ + The Apache Software License, Version 1.1 + ============================================================================ + + Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved. + + Redistribution and use in source and binary forms, with or without modifica- + tion, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + 3. The end-user documentation included with the redistribution, if any, must + include the following acknowledgment: "This product includes software + developed by the Apache Software Foundation (http://www.apache.org/)." + Alternately, this acknowledgment may appear in the software itself, if + and wherever such third-party acknowledgments normally appear. + + 4. The names "Apache Cocoon" and "Apache Software Foundation" must not be + used to endorse or promote products derived from this software without + prior written permission. For written permission, please contact + [EMAIL PROTECTED] + + 5. Products derived from this software may not be called "Apache", nor may + "Apache" appear in their name, without prior written permission of the + Apache Software Foundation. + + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, + INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- + DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + This software consists of voluntary contributions made by many individuals + on behalf of the Apache Software Foundation and was originally created by + Stefano Mazzocchi <[EMAIL PROTECTED]>. For more information on the Apache + Software Foundation, please see <http://www.apache.org/>. + +*/ package org.apache.cocoon.components.flow; import java.lang.Comparable; 1.2 +178 -0 xml-cocoon2/src/java/org/apache/cocoon/components/flow/javascript/JSCocoon.java Index: JSCocoon.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/flow/javascript/JSCocoon.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- JSCocoon.java 19 May 2002 19:19:39 -0000 1.1 +++ JSCocoon.java 2 Jul 2002 08:32:07 -0000 1.2 @@ -1,20 +1,80 @@ +/* + + ============================================================================ + The Apache Software License, Version 1.1 + ============================================================================ + + Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved. + + Redistribution and use in source and binary forms, with or without modifica- + tion, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + 3. The end-user documentation included with the redistribution, if any, must + include the following acknowledgment: "This product includes software + developed by the Apache Software Foundation (http://www.apache.org/)." + Alternately, this acknowledgment may appear in the software itself, if + and wherever such third-party acknowledgments normally appear. + + 4. The names "Apache Cocoon" and "Apache Software Foundation" must not be + used to endorse or promote products derived from this software without + prior written permission. For written permission, please contact + [EMAIL PROTECTED] + + 5. Products derived from this software may not be called "Apache", nor may + "Apache" appear in their name, without prior written permission of the + Apache Software Foundation. + + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, + INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- + DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + This software consists of voluntary contributions made by many individuals + on behalf of the Apache Software Foundation and was originally created by + Stefano Mazzocchi <[EMAIL PROTECTED]>. For more information on the Apache + Software Foundation, please see <http://www.apache.org/>. + +*/ package org.apache.cocoon.components.flow.javascript; import java.util.HashMap; import java.util.Map; +import java.util.Iterator; import org.apache.avalon.framework.component.Component; import org.apache.avalon.framework.component.ComponentException; import org.apache.avalon.framework.component.ComponentManager; +import org.apache.avalon.framework.component.ComponentSelector; +import org.apache.avalon.framework.parameters.Parameters; +import org.apache.cocoon.acting.Action; import org.apache.cocoon.components.flow.AbstractInterpreter; import org.apache.cocoon.components.flow.ContinuationsManager; import org.apache.cocoon.components.flow.ContinuationsManagerImpl; +import org.apache.cocoon.components.modules.input.InputModule; +import org.apache.cocoon.components.modules.output.OutputModule; import org.apache.cocoon.environment.Context; import org.apache.cocoon.environment.Environment; 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.environment.SourceResolver; +import org.apache.cocoon.sitemap.SitemapRedirector; import org.mozilla.javascript.NativeArray; +import org.mozilla.javascript.NativeObject; import org.mozilla.javascript.ScriptRuntime; import org.mozilla.javascript.Scriptable; import org.mozilla.javascript.ScriptableObject; @@ -29,6 +89,7 @@ */ public class JSCocoon extends ScriptableObject { + protected static String OBJECT_SOURCE_RESOLVER = "source-resolver"; protected AbstractInterpreter interp; protected Scriptable scope; protected NativeArray parameters; @@ -176,6 +237,7 @@ return manager; } + public static Map jsobjectToMap(Scriptable jsobject) { HashMap hash = new HashMap(); @@ -191,4 +253,120 @@ } return hash; } + + public static Object jsobjectToObject(Object obj) { + if (obj instanceof Wrapper) + obj = ((Wrapper) obj).unwrap(); + else if (obj instanceof Scriptable) + obj = jsobjectToMap((Scriptable)obj); + return obj; + } + + public Scriptable jsFunction_callAction(String type, String source, Scriptable parameters) throws Exception { + + Redirector redirector = new SitemapRedirector(this.environment); + SourceResolver resolver = (SourceResolver) this.environment.getObjectModel().get(JSCocoon.OBJECT_SOURCE_RESOLVER); + ComponentManager sitemapManager = this.environment.getComponentManager(); + ComponentSelector actionSelector = (ComponentSelector) sitemapManager.lookup(Action.ROLE+"Selector"); + Action action = (Action) actionSelector.select(type); + Map result = null; + try { + result = action.act(redirector, + resolver, + this.environment.getObjectModel(), + source, + JSCocoon.jsobjectToParameters(parameters)); + } finally { + actionSelector.release(action); + } + + // what should be done with the redirector ?? + // ignore it or call sendPage with it? + // return JSCocoon.mapToObject(result); + return new ScriptableMap(result); + } + + // Really needed? Java objects are accessible from JS... + // Besides, evaluating the returned object throws an error... + // I reckon it's a missing prototype but have no idea what to + // pass to setPrototype. + public static Scriptable mapToObject( Map map ) { + NativeObject obj = new NativeObject(); + Iterator iter = map.keySet().iterator(); + while(iter.hasNext()){ + String key = (String) iter.next(); + obj.put(key, obj, (String) map.get(key)); + } + return obj; + } + + public static Parameters jsobjectToParameters(Scriptable jsobject){ + Parameters params = new Parameters(); + Object[] ids = jsobject.getIds(); + for (int i = 0; i < ids.length; i++) { + String key = ScriptRuntime.toString(ids[i]); + Object value = jsobject.get(key, jsobject); + if (value == Undefined.instance) + value = null; + else + value = ScriptRuntime.toString(value); + params.setParameter(key, (String) value); + } + return params; + } + + public Object jsFunction_inputModuleGetAttribute(String type, String attribute) throws Exception { + // since no new components can be declared on sitemap we could + // very well use the 'other' one here. Anyway, since it's there... + ComponentManager sitemapManager = this.environment.getComponentManager(); + ComponentSelector inputSelector = (ComponentSelector) sitemapManager.lookup(InputModule.ROLE+"Selector"); + InputModule input = (InputModule) inputSelector.select(type); + Object result = null; + try { + result = input.getAttribute(attribute, null, this.environment.getObjectModel()); + } finally { + inputSelector.release(input); + } + return result; + } + + public void jsFunction_outputModuleSetAttribute(String type, String attribute, Object value) throws Exception { + // since no new components can be declared on sitemap we could + // very well use the 'other' one here. Anyway, since it's there... + ComponentManager sitemapManager = this.environment.getComponentManager(); + ComponentSelector outputSelector = (ComponentSelector) sitemapManager.lookup(OutputModule.ROLE+"Selector"); + OutputModule output = (OutputModule) outputSelector.select(type); + try { + output.setAttribute(null, this.environment.getObjectModel(), attribute, JSCocoon.jsobjectToObject(value)); + } finally { + outputSelector.release(output); + } + } + + public void jsFunction_outputModuleCommit(String type) throws Exception { + // since no new components can be declared on sitemap we could + // very well use the 'other' one here. Anyway, since it's there... + ComponentManager sitemapManager = this.environment.getComponentManager(); + ComponentSelector outputSelector = (ComponentSelector) sitemapManager.lookup(OutputModule.ROLE+"Selector"); + OutputModule output = (OutputModule) outputSelector.select(type); + try { + output.commit(null, this.environment.getObjectModel()); + } finally { + outputSelector.release(output); + } + } + + public void jsFunction_outputModuleRollback(String type) throws Exception { + // since no new components can be declared on sitemap we could + // very well use the 'other' one here. Anyway, since it's there... + ComponentManager sitemapManager = this.environment.getComponentManager(); + ComponentSelector outputSelector = (ComponentSelector) sitemapManager.lookup(OutputModule.ROLE+"Selector"); + OutputModule output = (OutputModule) outputSelector.select(type); + try { + output.rollback(null, this.environment.getObjectModel(), null); + } finally { + outputSelector.release(output); + } + } + } 1.2 +50 -0 xml-cocoon2/src/java/org/apache/cocoon/components/flow/javascript/JSGlobal.java Index: JSGlobal.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/flow/javascript/JSGlobal.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- JSGlobal.java 19 May 2002 19:19:39 -0000 1.1 +++ JSGlobal.java 2 Jul 2002 08:32:07 -0000 1.2 @@ -1,3 +1,53 @@ +/* + + ============================================================================ + The Apache Software License, Version 1.1 + ============================================================================ + + Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved. + + Redistribution and use in source and binary forms, with or without modifica- + tion, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + 3. The end-user documentation included with the redistribution, if any, must + include the following acknowledgment: "This product includes software + developed by the Apache Software Foundation (http://www.apache.org/)." + Alternately, this acknowledgment may appear in the software itself, if + and wherever such third-party acknowledgments normally appear. + + 4. The names "Apache Cocoon" and "Apache Software Foundation" must not be + used to endorse or promote products derived from this software without + prior written permission. For written permission, please contact + [EMAIL PROTECTED] + + 5. Products derived from this software may not be called "Apache", nor may + "Apache" appear in their name, without prior written permission of the + Apache Software Foundation. + + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, + INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- + DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + This software consists of voluntary contributions made by many individuals + on behalf of the Apache Software Foundation and was originally created by + Stefano Mazzocchi <[EMAIL PROTECTED]>. For more information on the Apache + Software Foundation, please see <http://www.apache.org/>. + +*/ package org.apache.cocoon.components.flow.javascript; import org.mozilla.javascript.Context; 1.2 +50 -0 xml-cocoon2/src/java/org/apache/cocoon/components/flow/javascript/JSLog.java Index: JSLog.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/flow/javascript/JSLog.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- JSLog.java 19 May 2002 19:19:39 -0000 1.1 +++ JSLog.java 2 Jul 2002 08:32:07 -0000 1.2 @@ -1,3 +1,53 @@ +/* + + ============================================================================ + The Apache Software License, Version 1.1 + ============================================================================ + + Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved. + + Redistribution and use in source and binary forms, with or without modifica- + tion, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + 3. The end-user documentation included with the redistribution, if any, must + include the following acknowledgment: "This product includes software + developed by the Apache Software Foundation (http://www.apache.org/)." + Alternately, this acknowledgment may appear in the software itself, if + and wherever such third-party acknowledgments normally appear. + + 4. The names "Apache Cocoon" and "Apache Software Foundation" must not be + used to endorse or promote products derived from this software without + prior written permission. For written permission, please contact + [EMAIL PROTECTED] + + 5. Products derived from this software may not be called "Apache", nor may + "Apache" appear in their name, without prior written permission of the + Apache Software Foundation. + + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, + INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- + DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + This software consists of voluntary contributions made by many individuals + on behalf of the Apache Software Foundation and was originally created by + Stefano Mazzocchi <[EMAIL PROTECTED]>. For more information on the Apache + Software Foundation, please see <http://www.apache.org/>. + +*/ package org.apache.cocoon.components.flow.javascript; import org.apache.log.Logger; 1.2 +50 -0 xml-cocoon2/src/java/org/apache/cocoon/components/flow/javascript/JSWebContinuation.java Index: JSWebContinuation.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/flow/javascript/JSWebContinuation.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- JSWebContinuation.java 19 May 2002 19:19:39 -0000 1.1 +++ JSWebContinuation.java 2 Jul 2002 08:32:07 -0000 1.2 @@ -1,3 +1,53 @@ +/* + + ============================================================================ + The Apache Software License, Version 1.1 + ============================================================================ + + Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved. + + Redistribution and use in source and binary forms, with or without modifica- + tion, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + 3. The end-user documentation included with the redistribution, if any, must + include the following acknowledgment: "This product includes software + developed by the Apache Software Foundation (http://www.apache.org/)." + Alternately, this acknowledgment may appear in the software itself, if + and wherever such third-party acknowledgments normally appear. + + 4. The names "Apache Cocoon" and "Apache Software Foundation" must not be + used to endorse or promote products derived from this software without + prior written permission. For written permission, please contact + [EMAIL PROTECTED] + + 5. Products derived from this software may not be called "Apache", nor may + "Apache" appear in their name, without prior written permission of the + Apache Software Foundation. + + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, + INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- + DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + This software consists of voluntary contributions made by many individuals + on behalf of the Apache Software Foundation and was originally created by + Stefano Mazzocchi <[EMAIL PROTECTED]>. For more information on the Apache + Software Foundation, please see <http://www.apache.org/>. + +*/ package org.apache.cocoon.components.flow.javascript; import org.apache.avalon.framework.component.ComponentManager; 1.3 +50 -0 xml-cocoon2/src/java/org/apache/cocoon/components/flow/javascript/JavaScriptInterpreter.java Index: JavaScriptInterpreter.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/flow/javascript/JavaScriptInterpreter.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- JavaScriptInterpreter.java 13 Jun 2002 09:28:14 -0000 1.2 +++ JavaScriptInterpreter.java 2 Jul 2002 08:32:07 -0000 1.3 @@ -1,3 +1,53 @@ +/* + + ============================================================================ + The Apache Software License, Version 1.1 + ============================================================================ + + Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved. + + Redistribution and use in source and binary forms, with or without modifica- + tion, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + 3. The end-user documentation included with the redistribution, if any, must + include the following acknowledgment: "This product includes software + developed by the Apache Software Foundation (http://www.apache.org/)." + Alternately, this acknowledgment may appear in the software itself, if + and wherever such third-party acknowledgments normally appear. + + 4. The names "Apache Cocoon" and "Apache Software Foundation" must not be + used to endorse or promote products derived from this software without + prior written permission. For written permission, please contact + [EMAIL PROTECTED] + + 5. Products derived from this software may not be called "Apache", nor may + "Apache" appear in their name, without prior written permission of the + Apache Software Foundation. + + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, + INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- + DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + This software consists of voluntary contributions made by many individuals + on behalf of the Apache Software Foundation and was originally created by + Stefano Mazzocchi <[EMAIL PROTECTED]>. For more information on the Apache + Software Foundation, please see <http://www.apache.org/>. + +*/ package org.apache.cocoon.components.flow.javascript; import java.io.BufferedReader; 1.2 +57 -0 xml-cocoon2/src/java/org/apache/cocoon/components/flow/javascript/system.js Index: system.js =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/flow/javascript/system.js,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- system.js 19 May 2002 19:19:39 -0000 1.1 +++ system.js 2 Jul 2002 08:32:07 -0000 1.2 @@ -40,3 +40,60 @@ { kont.continuation(kont); } + + +// Action Support +// +// call an action from JS +function act(type, src, param) +{ + if (type == undefined || src == undefined || param == undefined) { + log.error("Signature does not match act(type,src,param)"); + return undefined; + } + return cocoon.callAction(type,src,param); +} + +// InputModule Support +// +// obtain value form InputModule +function inputValue(type, name) +{ + if (type == undefined || name == undefined) { + log.error("Signature does not match inputValue(type,name)"); + return undefined; + } + return cocoon.inputModuleGetAttribute(type, name); +} + +// OutputModule Support +// +// set an attribute (starts transaction, commit or rollback required!) +function outputSet(type, name, value) +{ + if (type == undefined || name == undefined || value == undefined) { + log.error("Signature does not match outputSet(type,name,value)"); + } else { + cocoon.outputModuleSetAttribute(type, name, value); + } +} + +// makes attributes permanent (ends transaction) +function outputCommit(type) +{ + if (type == undefined) { + log.error("Signature does not match outputCommit(type)"); + } else { + cocoon.outputModuleCommit(type); + } +} + +// deletes attributes (ends transaction) +function outputRollback(type) +{ + if (type == undefined) { + log.error("Signature does not match outputCommit(type)"); + } else { + cocoon.outputModuleRollback(type); + } +} 1.1 xml-cocoon2/src/java/org/apache/cocoon/components/flow/javascript/ScriptableMap.java Index: ScriptableMap.java =================================================================== /* ============================================================================ The Apache Software License, Version 1.1 ============================================================================ Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved. Redistribution and use in source and binary forms, with or without modifica- tion, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. The end-user documentation included with the redistribution, if any, must include the following acknowledgment: "This product includes software developed by the Apache Software Foundation (http://www.apache.org/)." Alternately, this acknowledgment may appear in the software itself, if and wherever such third-party acknowledgments normally appear. 4. The names "Apache Cocoon" and "Apache Software Foundation" must not be used to endorse or promote products derived from this software without prior written permission. For written permission, please contact [EMAIL PROTECTED] 5. Products derived from this software may not be called "Apache", nor may "Apache" appear in their name, without prior written permission of the Apache Software Foundation. THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. This software consists of voluntary contributions made by many individuals on behalf of the Apache Software Foundation and was originally created by Stefano Mazzocchi <[EMAIL PROTECTED]>. For more information on the Apache Software Foundation, please see <http://www.apache.org/>. */ package org.apache.cocoon.components.flow.javascript; import org.mozilla.javascript.Scriptable; import org.mozilla.javascript.NativeJavaObject; import org.mozilla.javascript.Wrapper; import java.util.Map; import java.util.Iterator; /** * Wrap a java.util.Map for JavaScript. */ public class ScriptableMap implements Scriptable, Wrapper { private Map map; private Scriptable prototype, parent; public ScriptableMap() { } public ScriptableMap(Map map) { this.map = map; } public String getClassName() { return "Map"; } /** * Add pseudo-property "length" as map.size(). Any existing key * "length" will be hidden by this and only accessible by index * number. */ public boolean has(String name, Scriptable start) { return name.equals("length") || this.map.containsKey(name); } public boolean has(int index, Scriptable start) { return 0 <= index && index < this.map.size(); } /** * Add pseudo-property "length" as map.size(). Any existing key * "length" will be hidden by this and only accessible by index * number. */ public Object get(String name, Scriptable start) { if (name.equals("length")) return new Integer(this.map.size()); if (this.map.containsKey(name)) return this.map.get(name); return NOT_FOUND; } /** * Access an entry by index number. The position is determined * through the position of the key in the enumeration * map.values().iterator() */ public Object get(int index, Scriptable start) { if (0 <= index && index < this.map.size()) { Iterator iter = this.map.values().iterator(); Object result = null; for (int i = 0; i < index; i++) iter.next(); result = iter.next(); return result; } return NOT_FOUND; } public void put(String name, Scriptable start, Object value) { if (value instanceof NativeJavaObject) { value = ((NativeJavaObject)value).unwrap(); } map.put(name, value); } /** * Allow only to change an existing entry. The position is * determined through the position of the key in the enumeration * map.values().iterator() */ public void put(int index, Scriptable start, Object value) { if (0 <= index && index < this.map.size()) { Iterator iter = this.map.keySet().iterator(); Object key = null; for (int i = 0; i < index; i++) iter.next(); key = iter.next(); if (value instanceof NativeJavaObject) { value = ((NativeJavaObject)value).unwrap(); } this.map.put(key,value); } } public void delete(String id) { map.remove(id); } /** * Allow only to change an existing entry. The position is * determined through the position of the key in the enumeration * map.values().iterator() */ public void delete(int index) { if (0 <= index && index < this.map.size()) { Iterator iter = this.map.keySet().iterator(); Object key = null; for (int i = 0; i < index; i++) iter.next(); key = iter.next(); this.map.remove(key); } } public Scriptable getPrototype() { return prototype; } public void setPrototype(Scriptable prototype) { this.prototype = prototype; } public Scriptable getParentScope() { return parent; } public void setParentScope(Scriptable parent) { this.parent = parent; } public Object[] getIds() { return this.map.keySet().toArray(); } public Object getDefaultValue(Class typeHint) { return this.map.toString(); } public boolean hasInstance(Scriptable value) { Scriptable proto = value.getPrototype(); while (proto != null) { if (proto.equals(this)) return true; proto = proto.getPrototype(); } return false; } /** * Return the java.util.Map that is wrapped by this class. */ public Object unwrap() { return this.map; } }
---------------------------------------------------------------------- In case of troubles, e-mail: [EMAIL PROTECTED] To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]