cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject cvs commit: cocoon-2.1/src/blocks/scratchpad/mocks/org/apache/commons/jelly/impl XMLParser.java
Date Tue, 23 Dec 2003 12:54:09 GMT
cziegeler    2003/12/23 04:54:09

  Modified:    src/blocks/scratchpad/java/org/apache/cocoon/generation
                        JellyGenerator.java
  Added:       src/blocks/scratchpad/mocks/org/apache/commons/jelly
                        JellyTagException.java Script.java
               src/blocks/scratchpad/mocks/org/apache/commons/jelly/impl
                        XMLParser.java
  Log:
  JellyGenerator can now use any Source
  
  Revision  Changes    Path
  1.5       +19 -9     cocoon-2.1/src/blocks/scratchpad/java/org/apache/cocoon/generation/JellyGenerator.java
  
  Index: JellyGenerator.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/scratchpad/java/org/apache/cocoon/generation/JellyGenerator.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- JellyGenerator.java	23 Dec 2003 11:35:17 -0000	1.4
  +++ JellyGenerator.java	23 Dec 2003 12:54:09 -0000	1.5
  @@ -57,11 +57,14 @@
   import org.apache.avalon.framework.parameters.Parameters;
   import org.apache.cocoon.ProcessingException;
   import org.apache.cocoon.ResourceNotFoundException;
  +import org.apache.cocoon.components.source.SourceUtil;
   import org.apache.cocoon.environment.ObjectModelHelper;
   import org.apache.cocoon.environment.Request;
   import org.apache.cocoon.environment.SourceResolver;
   import org.apache.commons.jelly.JellyContext;
  +import org.apache.commons.jelly.Script;
   import org.apache.commons.jelly.XMLOutput;
  +import org.apache.commons.jelly.impl.XMLParser;
   import org.apache.excalibur.source.Source;
   import org.xml.sax.SAXException;
   
  @@ -70,13 +73,17 @@
    * as a Cocoon Generator. 
    *
    * @author <a href="mailto:amal.sirvisetti@sirvisetti.com">Amal Sirvisetti</a>
  + * @author <a href="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
    */
  -public class JellyGenerator extends ServiceableGenerator 
  -{
  +public class JellyGenerator 
  +    extends AbstractGenerator {
   
       /** The Jelly Context */
       protected JellyContext jellyContext;  
   
  +    /** The Jelly Parser */
  +    protected XMLParser jellyParser = new XMLParser();
  +    
       /**
        * Recycle this component.
        * All instance variables are set to <code>null</code>.
  @@ -90,7 +97,7 @@
        * @see org.apache.cocoon.sitemap.SitemapModelComponent#setup
        */
       public void setup(SourceResolver resolver, Map objectModel, String src, Parameters
params) 
  -                throws ProcessingException,SAXException,IOException {
  +    throws ProcessingException,SAXException,IOException {
   
           super.setup(resolver, objectModel, src, params);
   
  @@ -104,7 +111,8 @@
       /**
        * Generate XML data from Jelly script.
        */
  -    public void generate() throws IOException, SAXException, ProcessingException {
  +    public void generate() 
  +    throws IOException, SAXException, ProcessingException {
           Source scriptSource = null;
           try {
               
  @@ -116,16 +124,18 @@
               // Execute Jelly script
               XMLOutput xmlOutput = new XMLOutput(this.contentHandler, this.lexicalHandler);
               
  -            // TODO - get the Jelly parser and feed an input stream into the parser
  -            //        This allows us to use our own protocols (like cocoon:)
  -            //        Compile the script and cache the compiled version
  +            // TODO - Compile the script and cache the compiled version
               
               scriptSource = this.resolver.resolveURI(this.source);
  +            
  +            Script script = this.jellyParser.parse(SourceUtil.getInputSource(scriptSource));
  +            script = script.compile();
  +            
               // the script does not output startDocument/endDocument events
               this.contentHandler.startDocument();
  -            this.jellyContext.runScript(scriptSource.getURI(), xmlOutput);
  -            this.contentHandler.endDocument();
  +            script.run(this.jellyContext, xmlOutput);
               xmlOutput.flush();
  +            this.contentHandler.endDocument();
               
           } catch (IOException e) {
               getLogger().error("JellyGenerator.generate()", e);
  
  
  
  1.1                  cocoon-2.1/src/blocks/scratchpad/mocks/org/apache/commons/jelly/JellyTagException.java
  
  Index: JellyTagException.java
  ===================================================================
  /*
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) 1999-2003 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
      apache@apache.org.
  
   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  <stefano@apache.org>. For more  information on the Apache
   Software Foundation, please see <http://www.apache.org/>.
  
  */
  package org.apache.commons.jelly;
  
  /**
   * Mock class providing the declarations required to compile the Cocoon code when
   * the actual library is not present.
   * 
   * @version CVS $Id: JellyTagException.java,v 1.1 2003/12/23 12:54:09 cziegeler Exp $
   */
  public class JellyTagException extends JellyException {
      
      public JellyTagException() {
      }
      
  }
  
  
  
  1.1                  cocoon-2.1/src/blocks/scratchpad/mocks/org/apache/commons/jelly/Script.java
  
  Index: Script.java
  ===================================================================
  /*
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) 1999-2003 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
      apache@apache.org.
  
   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  <stefano@apache.org>. For more  information on the Apache
   Software Foundation, please see <http://www.apache.org/>.
  
  */
  package org.apache.commons.jelly;
  
  /**
   * Mock class providing the declarations required to compile the Cocoon code when
   * the actual library is not present.
   * 
   * @version CVS $Id: Script.java,v 1.1 2003/12/23 12:54:09 cziegeler Exp $
   */
  public interface Script {
  
      Script compile() throws JellyException;
  
      void run(JellyContext context, XMLOutput output) throws JellyTagException;
  
  }
  
  
  
  1.1                  cocoon-2.1/src/blocks/scratchpad/mocks/org/apache/commons/jelly/impl/XMLParser.java
  
  Index: XMLParser.java
  ===================================================================
  /*
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) 1999-2003 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
      apache@apache.org.
  
   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  <stefano@apache.org>. For more  information on the Apache
   Software Foundation, please see <http://www.apache.org/>.
  
  */
  package org.apache.commons.jelly.impl;
  
  import java.io.IOException;
  
  import org.apache.commons.jelly.Script;
  import org.xml.sax.InputSource;
  import org.xml.sax.SAXException;
  import org.xml.sax.helpers.DefaultHandler;
  
  /**
   * Mock class providing the declarations required to compile the Cocoon code when
   * the actual library is not present.
   * 
   * @version CVS $Id: XMLParser.java,v 1.1 2003/12/23 12:54:09 cziegeler Exp $
   */
  public class XMLParser extends DefaultHandler {
  
      public XMLParser() {
      }
  
      public Script parse(InputSource input) throws IOException, SAXException {
          return null;
      }
  
  }
  
  
  

Mime
View raw message