cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From anto...@apache.org
Subject cvs commit: cocoon-2.1/src/blocks/bsf/java/org/apache/cocoon/generation ScriptGenerator.java
Date Sun, 04 Apr 2004 04:44:09 GMT
antonio     2004/04/03 20:44:09

  Modified:    .        status.xml
               src/blocks/bsf/conf bsf.xmap
               lib      jars.xml
               src/documentation/xdocs/userdocs/generators
                        script-generator.xml
               src/blocks/bsf/java/org/apache/cocoon/generation
                        ScriptGenerator.java
  Added:       legal    asm-1.4.2.jar.license.txt
                        groovy-1.0-beta-4.jar.license.txt
               src/blocks/bsf/samples sitemap.xmap samples.xml
               src/blocks/bsf/lib groovy-1.0-beta-4.jar asm-1.4.2.jar
               src/blocks/bsf/conf bsf.xsamples
  Log:
  Add Groovy script generator under BSF block
  
  Revision  Changes    Path
  1.297     +4 -1      cocoon-2.1/status.xml
  
  Index: status.xml
  ===================================================================
  RCS file: /home/cvs//cocoon-2.1/status.xml,v
  retrieving revision 1.296
  retrieving revision 1.297
  diff -u -r1.296 -r1.297
  --- status.xml	3 Apr 2004 03:01:35 -0000	1.296
  +++ status.xml	4 Apr 2004 04:44:09 -0000	1.297
  @@ -212,6 +212,9 @@
     <changes>
   
    <release version="@version@" date="@date@">
  +   <action dev="AG" type="add">
  +     Groovy script generator support in BSF block
  +   </action>
      <action dev="JH" type="fix" due-to="Derek Hohls">
        Renamed validate-set to constraint-set for consistency (the element name is also constraint-set).
      </action>
  
  
  
  1.1                  cocoon-2.1/legal/asm-1.4.2.jar.license.txt
  
  Index: asm-1.4.2.jar.license.txt
  ===================================================================
  Taken from the build.properties file in asm-1.4.2 src distribution:
  
  ###############################################################################
  #ASM: a very small and fast Java bytecode manipulation framework
  #Copyright (c) 2000,2002,2003 INRIA, France Telecom
  #All rights reserved.
  #
  #Redistribution and use in source and binary forms, with or without
  #modification, 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. Neither the name of the copyright holders nor the names of its
  #   contributors may be used to endorse or promote products derived from
  #   this software without specific prior written permission.
  #
  #THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  #AND ANY EXPRESS 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 COPYRIGHT OWNER OR CONTRIBUTORS BE
  #LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  #CONSEQUENTIAL DAMAGES (INCLUDING, 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.
  ###############################################################################
  
  
  1.1                  cocoon-2.1/legal/groovy-1.0-beta-4.jar.license.txt
  
  Index: groovy-1.0-beta-4.jar.license.txt
  ===================================================================
  
  
  /*
   $Id: groovy-1.0-beta-4.jar.license.txt,v 1.1 2004/04/04 04:44:09 antonio Exp $
  
   Copyright 2003 (C) James Strachan and Bob Mcwhirter. All Rights Reserved.
  
   Redistribution and use of this software and associated documentation
   ("Software"), with or without modification, are permitted provided
   that the following conditions are met:
  
   1. Redistributions of source code must retain copyright
      statements and notices.  Redistributions must also contain a
      copy of this document.
  
   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 name "groovy" must not be used to endorse or promote
      products derived from this Software without prior written
      permission of The Codehaus.  For written permission,
      please contact info@codehaus.org.
  
   4. Products derived from this Software may not be called "groovy"
      nor may "groovy" appear in their names without prior written
      permission of The Codehaus. "groovy" is a registered
      trademark of The Codehaus.
  
   5. Due credit should be given to The Codehaus -
      http://groovy.codehaus.org/
  
   THIS SOFTWARE IS PROVIDED BY THE CODEHAUS AND CONTRIBUTORS
   ``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 CODEHAUS OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
   INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
   (INCLUDING, 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.
  
   */
  
  
  
  1.1                  cocoon-2.1/src/blocks/bsf/samples/sitemap.xmap
  
  Index: sitemap.xmap
  ===================================================================
  <?xml version="1.0"?>
  <!--
    Copyright 1999-2004 The Apache Software Foundation
  
    Licensed 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.
  -->
  
  <!--+
      | Batik block samples sitemap
      |
      | CVS $Id: sitemap.xmap,v 1.1 2004/04/04 04:44:09 antonio Exp $
      +-->
  
  <map:sitemap xmlns:map="http://apache.org/cocoon/sitemap/1.0">
  
  <!-- =========================== Components ================================ -->
  
    <map:components/>
  
  <!-- =========================== Views =================================== -->
  
    <map:views>
      <map:view from-label="content" name="content">
        <map:serialize type="xml"/>
      </map:view>
  
      <map:view from-label="content" name="pretty-content">
        <map:transform src="context://stylesheets/system/xml2html.xslt"/>
        <map:serialize type="html"/>
      </map:view>
  
      <map:view from-position="last" name="links">
        <map:serialize type="links"/>
      </map:view>
    </map:views>
  
  <!-- =========================== Pipelines ================================= -->
  
    <map:pipelines>
      <map:pipeline type="caching">
        <map:match pattern="">
          <map:redirect-to uri="welcome"/>
        </map:match>
  
        <map:match pattern="welcome">
          <map:generate src="samples.xml"/>
          <map:transform src="context://samples/common/style/xsl/html/simple-samples2html.xsl">
            <map:parameter name="contextPath" value="{request:contextPath}"/>
          </map:transform>
          <map:serialize/>
        </map:match>
  
        <!-- ========================== BSF Groovy ========================== -->
  
        <map:match pattern="hello.gy">
          <map:generate type="script" src="generator/hello.gy"/>
          <map:transform src="context://samples/hello-world/style/xsl/page2html.xsl"/>
          <map:serialize type="html"/>
        </map:match>
      </map:pipeline>
    </map:pipelines>
  </map:sitemap>
  
  
  
  1.1                  cocoon-2.1/src/blocks/bsf/samples/samples.xml
  
  Index: samples.xml
  ===================================================================
  <?xml version="1.0"?>
  <!--
    Copyright 1999-2004 The Apache Software Foundation
  
    Licensed 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.
  -->
  
  <!-- CVS $Id: samples.xml,v 1.1 2004/04/04 04:44:09 antonio Exp $ -->
  
  <samples name="BSF Samples" xmlns:xlink="http://www.w3.org/1999/xlink">
  
    <group name="Main examples page.">
      <sample name="Back" href="..">to Cocoon examples main page</sample>
    </group>
  
    <group name="Hello World!">
      <sample name="Groovy" href="hello.gy">
        Simple Groovy generator sample
      </sample>
    </group>
  </samples>
  
  
  
  1.1                  cocoon-2.1/src/blocks/bsf/lib/groovy-1.0-beta-4.jar
  
  	<<Binary file>>
  
  
  1.1                  cocoon-2.1/src/blocks/bsf/lib/asm-1.4.2.jar
  
  	<<Binary file>>
  
  
  1.4       +10 -2     cocoon-2.1/src/blocks/bsf/conf/bsf.xmap
  
  Index: bsf.xmap
  ===================================================================
  RCS file: /home/cvs//cocoon-2.1/src/blocks/bsf/conf/bsf.xmap,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- bsf.xmap	6 Mar 2004 02:26:12 -0000	1.3
  +++ bsf.xmap	4 Apr 2004 04:44:09 -0000	1.4
  @@ -19,6 +19,14 @@
         unless="generator[@name='script']">
   
       <map:generator name="script"
  -                   src="org.apache.cocoon.generation.ScriptGenerator"
  -                   label="content"/>
  +         src="org.apache.cocoon.generation.ScriptGenerator"
  +         logger="sitemap.generation.scriptgenerator">
  +        <!-- Groovy support -->
  +        <add-languages>
  +            <language name="groovy" src="org.codehaus.groovy.bsf.GroovyEngine">
  +              <extension>groovy</extension>
  +              <extension>gy</extension>
  +            </language>
  +        </add-languages>
  +    </map:generator>
   </xmap>
  
  
  
  1.1                  cocoon-2.1/src/blocks/bsf/conf/bsf.xsamples
  
  Index: bsf.xsamples
  ===================================================================
  <?xml version="1.0"?>
  <!--
    Copyright 1999-2004 The Apache Software Foundation
  
    Licensed 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.
  -->
  
  <xsamples xpath="/samples" unless="group[@name='BSF']">
    <group name="BSF">
      <sample name="BSF Block" href="bsf/">
        Examples using script generator and script action.
      </sample>
    </group>
  </xsamples>
  
  
  
  1.201     +27 -2     cocoon-2.1/lib/jars.xml
  
  Index: jars.xml
  ===================================================================
  RCS file: /home/cvs//cocoon-2.1/lib/jars.xml,v
  retrieving revision 1.200
  retrieving revision 1.201
  diff -u -r1.200 -r1.201
  --- jars.xml	3 Apr 2004 01:32:32 -0000	1.200
  +++ jars.xml	4 Apr 2004 04:44:09 -0000	1.201
  @@ -385,9 +385,34 @@
         supports additional languages, the application will automatically
         support the additional languages.
       </description>
  -    <used-by>Script generator, script action (bsf block)</used-by>
  +    <used-by>BSF Block (Script generator, script action)</used-by>
       <lib>bsf/lib/bsf-2.3.0.jar</lib>
       <homepage>http://jakarta.apache.org/bsf/</homepage>
  +  </file>
  +
  +  <file>
  +    <title>Groovy language engine</title>
  +    <description>
  +      Groovy is a new agile dynamic language for the JVM combining lots of great
  +      features from languages like Python, Ruby and Smalltalk and making them
  +      available to the Java developers using a Java-like syntax.
  +    </description>
  +    <used-by>BSF Block (Script generator, script action)</used-by>
  +    <lib>bsf/lib/groovy-1.0-beta-4.jar</lib>
  +    <homepage>http://groovy.codehaus.org/</homepage>
  +  </file>
  +
  +  <file>
  +    <title>ASM </title>
  +    <description>
  +      ASM is a Java bytecode manipulation framework. It can be used to
  +	  dynamically generate stub classes or other proxy classes, directly in
  +	  binary form, or to dynamically modify classes at load time, i.e., just
  +	  before they are loaded into the Java Virtual Machine.
  +    </description>
  +    <used-by>BSF Block (Script generator, script action)</used-by>
  +    <lib>bsf/lib/asm-1.4.2.jar</lib>
  +    <homepage>http://asm.objectweb.org/</homepage>
     </file>
   
     <file>
  
  
  
  1.6       +4 -4      cocoon-2.1/src/documentation/xdocs/userdocs/generators/script-generator.xml
  
  Index: script-generator.xml
  ===================================================================
  RCS file: /home/cvs//cocoon-2.1/src/documentation/xdocs/userdocs/generators/script-generator.xml,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- script-generator.xml	6 Mar 2004 02:25:35 -0000	1.5
  +++ script-generator.xml	4 Apr 2004 04:44:09 -0000	1.6
  @@ -1,4 +1,4 @@
  -<?xml version="1.0" encoding="ISO-8859-1"?>
  +<?xml version="1.0"?>
   <!--
     Copyright 1999-2004 The Apache Software Foundation
   
  @@ -118,8 +118,8 @@
           associated with the extensions <code>foo</code>, and <code>bar</code>.</p>
           <source>&#60;add-language&#62;
     &#60;language name=&#34;foobar&#34; src=&#34;foo.bar.ScriptLanguage&#34;&#62;
  -    &#60;extension=&#34;foo&#34;/&#62;
  -    &#60;extension=&#34;bar&#34;/&#62;
  +    &#60;extension&#62;foo&#60;/extension&#62;
  +    &#60;extension&#62;bar&#60;/extension&#62;
     &#60;/language&#62;
     ...
   &#60;/add-language&#62;
  
  
  
  1.6       +14 -28    cocoon-2.1/src/blocks/bsf/java/org/apache/cocoon/generation/ScriptGenerator.java
  
  Index: ScriptGenerator.java
  ===================================================================
  RCS file: /home/cvs//cocoon-2.1/src/blocks/bsf/java/org/apache/cocoon/generation/ScriptGenerator.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- ScriptGenerator.java	3 Apr 2004 01:32:32 -0000	1.5
  +++ ScriptGenerator.java	4 Apr 2004 04:44:09 -0000	1.6
  @@ -59,8 +59,7 @@
    */
   public class ScriptGenerator extends ServiceableGenerator implements Configurable {
   
  -    protected class BSFLanguage
  -    {
  +    protected class BSFLanguage {
           public String name;
           public String engineSrc;
           public String[] extensions;
  @@ -71,19 +70,15 @@
       /** The source */
       private Source inputSource;
   
  -    public void configure(Configuration conf) throws ConfigurationException
  -    {
  -        if (conf != null)
  -        {
  +    public void configure(Configuration conf) throws ConfigurationException {
  +        if (conf != null) {
               //add optional support for additional languages
               Configuration languagesToAdd = conf.getChild("add-languages");
   
               Configuration[] languages = languagesToAdd.getChildren("language");
               this.additionalLanguages = new BSFLanguage[languages.length];
   
  -
  -            for (int i = 0; i < languages.length; ++i)
  -            {
  +            for (int i = 0; i < languages.length; i++) {
                   Configuration language = languages[i];
                   BSFLanguage bsfLanguage = new BSFLanguage();
   
  @@ -93,16 +88,13 @@
                   getLogger().debug("Configuring ScriptGenerator with additional BSF language
" + bsfLanguage.name);
                   getLogger().debug("Configuring ScriptGenerator with BSF engine " + bsfLanguage.engineSrc);
   
  -
                   Configuration[] extensions = language.getChildren("extension");
                   bsfLanguage.extensions = new String[extensions.length];
   
  -                for (int j = 0; j < extensions.length; ++j)
  -                {
  -                    bsfLanguage.extensions[i] = extensions[i].getValue();
  -                    getLogger().debug("Configuring ScriptGenerator with lang extension
" + bsfLanguage.extensions[i]);
  +                for (int j = 0; j < extensions.length; j++) {
  +                    bsfLanguage.extensions[j] = extensions[j].getValue();
  +                    getLogger().debug("Configuring ScriptGenerator with lang extension
" + bsfLanguage.extensions[j]);
                   }
  -
                   this.additionalLanguages[i] = bsfLanguage;
               }
           }
  @@ -130,20 +122,17 @@
               // Set up the BSF manager and register relevant helper "beans"
               BSFManager mgr = new BSFManager();
   
  -            // add support for additional languages
  -
  -            if (this.additionalLanguages != null)
  -            {
  -                for (int i = 0; i < this.additionalLanguages.length; ++i)
  -                {
  -                    getLogger().debug("adding BSF language " + this.additionalLanguages[i].name
+ " with engine " + this.additionalLanguages[i].engineSrc);
  +            // add BSF support for additional languages
  +            if (this.additionalLanguages != null) {
  +                for (int i = 0; i < this.additionalLanguages.length; ++i) {
  +                    getLogger().debug("adding BSF language " + this.additionalLanguages[i].name
+
  +                            " with engine " + this.additionalLanguages[i].engineSrc);
   
                       BSFManager.registerScriptingEngine(this.additionalLanguages[i].name,
                                                   this.additionalLanguages[i].engineSrc,
                                                   this.additionalLanguages[i].extensions);
                   }
               }
  -
               StringBuffer output = new StringBuffer();
   
               mgr.registerBean("resolver", this.resolver);
  @@ -156,7 +145,6 @@
               getLogger().debug("BSFManager execution begining");
   
               // Execute the script
  -
               mgr.exec(BSFManager.getLangFromFilename(this.inputSource.getURI()),
                        this.inputSource.getURI(), 0, 0, IOUtils.getStringFromReader(in));
   
  @@ -164,9 +152,7 @@
               getLogger().debug("output = [" + output.toString() + "]");
   
               // Extract the XML string from the BSFManager and parse it
  -
  -            InputSource xmlInput =
  -                    new InputSource(new StringReader(output.toString()));
  +            InputSource xmlInput = new InputSource(new StringReader(output.toString()));
               parser = (SAXParser)(this.manager.lookup(SAXParser.ROLE));
               parser.parse(xmlInput, this.xmlConsumer);
           } catch (SourceException se) {
  
  
  

Mime
View raw message