cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject cvs commit: xml-cocoon2/src/webapp/WEB-INF cocoon.xconf
Date Wed, 24 Apr 2002 09:59:49 GMT
cziegeler    02/04/24 02:59:49

  Modified:    src/java/org/apache/cocoon/components
                        CocoonComponentManager.java
               src/java/org/apache/cocoon/components/source
                        SitemapSource.java
               src/java/org/apache/cocoon/components/source/impl
                        ContextSourceFactory.java
               src/java/org/apache/cocoon/components/treeprocessor
                        TreeProcessor.java
               src/java/org/apache/cocoon/sitemap Handler.java
               src/java/org/apache/cocoon/xml XMLizable.java
               src/webapp/WEB-INF cocoon.xconf
  Added:       src/java/org/apache/cocoon/components/source/impl
                        CocoonSourceFactory.java SitemapSource.java
  Log:
  Adding new cocoon source factory
  
  Revision  Changes    Path
  1.15      +17 -4     xml-cocoon2/src/java/org/apache/cocoon/components/CocoonComponentManager.java
  
  Index: CocoonComponentManager.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/CocoonComponentManager.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- CocoonComponentManager.java	19 Apr 2002 11:02:57 -0000	1.14
  +++ CocoonComponentManager.java	24 Apr 2002 09:59:48 -0000	1.15
  @@ -75,7 +75,7 @@
    * and by handling the lookup of the <code>SourceResolver</code> (in development)
    *
    * @author <a href="mailto:cziegeler@org.com">Carsten Ziegeler</a>
  - * @version CVS $Id: CocoonComponentManager.java,v 1.14 2002/04/19 11:02:57 cziegeler Exp
$
  + * @version CVS $Id: CocoonComponentManager.java,v 1.15 2002/04/24 09:59:48 cziegeler Exp
$
    */
   public final class CocoonComponentManager
   extends ExcaliburComponentManager
  @@ -117,7 +117,9 @@
       /**
        * This hook must be called by the sitemap each time a sitemap is entered
        */
  -    public static void enterEnvironment(Environment env, Map objectModel) {
  +    public static void enterEnvironment(Environment env,
  +                                        Map         objectModel,
  +                                        Object      processor) {
           if (environmentStack.get() == null) {
               environmentStack.set(new Stack());
           }
  @@ -125,11 +127,11 @@
           if ( !stack.empty() ) {
               final Object[] objects = (Object[])stack.peek();
               if ( objects[1] == objectModel ) {
  -                stack.push(new Object[] {env, objectModel, objects[2], TWO});
  +                stack.push(new Object[] {env, objectModel, objects[2], TWO, processor});
                   return;
               }
           }
  -        stack.push(new Object[] {env, objectModel, new HashMap(5), ONE});
  +        stack.push(new Object[] {env, objectModel, new HashMap(5), ONE, processor});
       }
   
       /**
  @@ -149,6 +151,17 @@
                   }
               }
           }
  +    }
  +
  +    /**
  +     * Return the current stack state (for the cocoon: protocol
  +     */
  +    public static Object[] getCurrentEnvironment() {
  +        final Stack stack = (Stack)environmentStack.get();
  +        if ( null != stack && !stack.empty()) {
  +            return (Object[])stack.pop();
  +        }
  +        return null;
       }
   
       /**
  
  
  
  1.12      +3 -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.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- SitemapSource.java	19 Apr 2002 23:48:40 -0000	1.11
  +++ SitemapSource.java	24 Apr 2002 09:59:48 -0000	1.12
  @@ -89,7 +89,7 @@
    * Description of a source which is defined by a pipeline.
    *
    * @author <a href="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
  - * @version CVS $Id: SitemapSource.java,v 1.11 2002/04/19 23:48:40 vgritsenko Exp $
  + * @version CVS $Id: SitemapSource.java,v 1.12 2002/04/24 09:59:48 cziegeler Exp $
    */
   
   public final class SitemapSource
  @@ -348,7 +348,8 @@
               } else {
                   try {
                       CocoonComponentManager.enterEnvironment(this.environment,
  -                                                            this.environment.getObjectModel());
  +                                                            this.environment.getObjectModel(),
  +                                                            this.processor);
                       ((XMLProducer)eventPipeline).setConsumer(consumer);
                       eventPipeline.process(this.environment);
                   } finally {
  
  
  
  1.2       +3 -2      xml-cocoon2/src/java/org/apache/cocoon/components/source/impl/ContextSourceFactory.java
  
  Index: ContextSourceFactory.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/source/impl/ContextSourceFactory.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ContextSourceFactory.java	24 Apr 2002 08:55:32 -0000	1.1
  +++ ContextSourceFactory.java	24 Apr 2002 09:59:48 -0000	1.2
  @@ -55,6 +55,7 @@
   import java.net.URL;
   import java.util.Map;
   import org.apache.excalibur.source.Source;
  +import org.apache.excalibur.source.SourceFactory;
   import org.apache.excalibur.source.impl.URLSource;
   import org.apache.avalon.framework.context.ContextException;
   import org.apache.avalon.framework.context.Contextualizable;
  @@ -67,11 +68,11 @@
    * A factory for the context protocol using the context of the servlet api
    *
    * @author <a href="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
  - * @version $Id: ContextSourceFactory.java,v 1.1 2002/04/24 08:55:32 cziegeler Exp $
  + * @version $Id: ContextSourceFactory.java,v 1.2 2002/04/24 09:59:48 cziegeler Exp $
    */
   public class ContextSourceFactory
       extends AbstractLogEnabled
  -    implements org.apache.excalibur.source.SourceFactory, ThreadSafe
  +    implements SourceFactory, ThreadSafe
   {
   
       /**
  
  
  
  1.1                  xml-cocoon2/src/java/org/apache/cocoon/components/source/impl/CocoonSourceFactory.java
  
  Index: CocoonSourceFactory.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
      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.cocoon.components.source.impl;
  
  import java.io.IOException;
  import java.net.MalformedURLException;
  import java.util.Map;
  import org.apache.avalon.framework.component.ComponentManager;
  import org.apache.avalon.framework.component.Composable;
  import org.apache.excalibur.source.Source;
  import org.apache.excalibur.source.SourceFactory;
  import org.apache.avalon.framework.logger.AbstractLoggable;
  import org.apache.avalon.framework.thread.ThreadSafe;
  import org.apache.cocoon.Processor;
  import org.apache.cocoon.components.CocoonComponentManager;
  import org.apache.cocoon.environment.Environment;
  
  /**
   * This class implements the cocoon: protocol.
   * It cannot be configured like the other source factories
   * as it needs the current <code>Sitemap</code> as input.
   *
   * @author <a href="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
   * @version CVS $Id: CocoonSourceFactory.java,v 1.1 2002/04/24 09:59:48 cziegeler Exp $
   */
  
  public final class CocoonSourceFactory
      extends AbstractLoggable
      implements SourceFactory, ThreadSafe, Composable
  {
      /** The <code>ComponentManager</code> */
      private ComponentManager manager;
  
      /**
       * Composable
       */
      public void compose(ComponentManager manager) {
          this.manager = manager;
      }
  
      /**
       * Get a <code>Source</code> object.
       * @param parameters This is optional.
       */
      public Source getSource( String location, Map parameters )
          throws MalformedURLException, IOException
      {
          if( this.getLogger().isDebugEnabled() )
          {
              this.getLogger().debug( "Creating source object for " + location );
          }
  
          Object[] currentEnv = CocoonComponentManager.getCurrentEnvironment();
          if ( currentEnv == null ) {
              throw new MalformedURLException("The cocoon protocol can not be used outside
an environment.");
          }
          return new SitemapSource( (Environment)currentEnv[0],
                                    this.manager,
                                    (Processor)currentEnv[4],
                                    location,
                                    parameters,
                                    this.getLogger() );
      }
  }
  
  
  
  1.1                  xml-cocoon2/src/java/org/apache/cocoon/components/source/impl/SitemapSource.java
  
  Index: SitemapSource.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
      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.cocoon.components.source.impl;
  
  import org.apache.excalibur.source.Source;
  import org.apache.excalibur.source.SourceValidity;
  import org.apache.excalibur.source.impl.validity.TimeStampValidity;
  import org.apache.avalon.excalibur.pool.Recyclable;
  import org.apache.avalon.excalibur.xml.XMLizable;
  import org.apache.avalon.framework.component.ComponentException;
  import org.apache.avalon.framework.component.ComponentManager;
  import org.apache.avalon.framework.component.ComponentSelector;
  import org.apache.cocoon.Constants;
  import org.apache.cocoon.ProcessingException;
  import org.apache.cocoon.Processor;
  import org.apache.cocoon.caching.PipelineCacheKey;
  import org.apache.cocoon.components.CocoonComponentManager;
  import org.apache.cocoon.components.pipeline.CacheableEventPipeline;
  import org.apache.cocoon.components.pipeline.EventPipeline;
  import org.apache.cocoon.components.pipeline.StreamPipeline;
  import org.apache.cocoon.environment.Environment;
  import org.apache.cocoon.environment.ModifiableSource;
  import org.apache.cocoon.environment.Request;
  import org.apache.cocoon.environment.wrapper.EnvironmentWrapper;
  import org.apache.cocoon.serialization.Serializer;
  import org.apache.cocoon.util.HashUtil;
  import org.apache.cocoon.xml.AbstractXMLConsumer;
  import org.apache.cocoon.xml.ContentHandlerWrapper;
  import org.apache.cocoon.xml.XMLConsumer;
  import org.apache.cocoon.xml.XMLProducer;
  import org.apache.log.Logger;
  import org.xml.sax.ContentHandler;
  import org.xml.sax.InputSource;
  import org.xml.sax.SAXException;
  import org.xml.sax.ext.LexicalHandler;
  
  import java.io.ByteArrayInputStream;
  import java.io.ByteArrayOutputStream;
  import java.io.IOException;
  import java.io.InputStream;
  import java.io.OutputStream;
  import java.net.MalformedURLException;
  import java.util.Map;
  
  /**
   * Description of a source which is defined by a pipeline.
   *
   * @author <a href="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
   * @version CVS $Id: SitemapSource.java,v 1.1 2002/04/24 09:59:48 cziegeler Exp $
   */
  
  public final class SitemapSource
  extends AbstractXMLConsumer
  implements Source, XMLizable, Recyclable {
  
      /** The last modification date or 0 */
      private long lastModificationDate;
  
      /** The system id */
      private String systemId;
  
      /** The uri */
      private String uri;
  
      /** The current ComponentManager */
      private ComponentManager manager;
  
      /** The processor */
      private Processor processor;
  
      /** The environment */
      private EnvironmentWrapper environment;
  
      /** The prefix for the processing */
      private String prefix;
  
      /** The <code>EventPipeline</code> */
      private EventPipeline eventPipeline;
  
      /** The <code>StreamPipeline</code> */
      private StreamPipeline pipeline;
  
      /** The redirect <code>Source</code> */
      private Source redirectSource;
  
      /** The <code>SAXException</code> if unable to get resource */
      private SAXException exception;
  
      /** Do I need a refresh ? */
      private boolean needsRefresh;
  
      /**
       * Construct a new object
       */
      public SitemapSource(Environment      env,
                           ComponentManager manager,
                           Processor        sitemap,
                           String           uri,
                           Map              parameters,
                           Logger           logger)
      throws MalformedURLException {
  
          this.manager = manager;
          this.setLogger(logger);
          boolean rawMode = false;
  
          // remove the protocol
          int position = uri.indexOf(':') + 1;
          if (position != 0) {
              // check for subprotocol
              if (uri.startsWith("raw:", position)) {
                  position += 4;
                  rawMode = true;
              }
          }
  
          // does the uri point to this sitemap or to the root sitemap?
          if (uri.startsWith("//", position)) {
              position += 2;
              Processor processor = null;
              try {
                  processor = (Processor)this.manager.lookup(Processor.ROLE);
              } catch (ComponentException e) {
                  throw new MalformedURLException("Cannot get Processor instance");
              }
              this.prefix = ""; // start at the root
              this.processor = processor;
          } else if (uri.startsWith("/", position)) {
              position ++;
              this.prefix = null;
              this.processor = sitemap;
          } else {
              throw new MalformedURLException("Malformed cocoon URI.");
          }
  
          // create the queryString (if available)
          String queryString = null;
          int queryStringPos = uri.indexOf('?', position);
          if (queryStringPos != -1) {
              queryString = uri.substring(queryStringPos + 1);
              uri = uri.substring(position, queryStringPos);
          } else if (position > 0) {
              uri = uri.substring(position);
          }
  
          // build the request uri which is relative to the context
          String requestURI = (this.prefix == null ? env.getURIPrefix() + uri : uri);
  
          // create system ID
          this.systemId = queryString == null ?
              "cocoon://" + requestURI :
              "cocoon://" + requestURI + "?" + queryString;
  
          this.environment = new EnvironmentWrapper(env, requestURI, queryString, logger,
rawMode);
          this.uri = uri;
          this.discardValidity();
      }
  
      /**
       * Get the last modification date of the source or 0 if it
       * is not possible to determine the date.
       */
      public long getLastModified() {
          if (this.needsRefresh) {
              this.discardValidity();
          }
          return this.lastModificationDate;
      }
  
      /**
       * Get the content length of the source or -1 if it
       * is not possible to determine the length.
       */
      public long getContentLength() {
          return -1;
      }
  
      /**
       * Return an <code>InputStream</code> object to read from the source.
       */
      public InputStream getInputStream()
        throws IOException {
  
          if (this.needsRefresh) {
              this.discardValidity();
          }
          // VG: Why exception is not thrown in constructor?
          if (this.exception != null) {
              throw new IOException("SAXException: " + this.exception);
          }
  
          if (this.redirectSource != null) {
              return this.redirectSource.getInputStream();
          }
  
          try {
              ByteArrayOutputStream os = new ByteArrayOutputStream();
              this.environment.setOutputStream(os);
              this.pipeline.process(this.environment);
              return new ByteArrayInputStream(os.toByteArray());
  
          } catch (IOException e) {
              throw e;
          } catch (Exception e) {
              throw new IOException("Exception during processing of " + this.systemId);
          } finally {
              // Unhide wrapped environment output stream
              this.environment.setOutputStream(null);
              reset();
          }
      }
  
      /**
       * Return the unique identifer for this source
       */
      public String getSystemId() {
          return this.systemId;
      }
  
      /**
       *  Get the Validity object. This can either wrap the last modification
       *  date or the expires information or...
       *  If it is currently not possible to calculate such an information
       *  <code>null</code> is returned.
       */
      public SourceValidity getValidity() {
          if (this.needsRefresh) {
              this.discardValidity();
          }
          if (this.lastModificationDate < 1) {
              return null;
          } else {
              return new TimeStampValidity( this.lastModificationDate );
          }
      }
  
      /**
       * The mime-type of the content described by this object.
       * If the source is not able to determine the mime-type by itself
       * this can be null.
       */
       public String getMimeType() {
          return "text/xml";
       }
  
      /**
       * Refresh this object and update the last modified date
       * and content length.
       */
      public void discardValidity() {
          reset();
          try {
              // initialize the pipelines
              this.eventPipeline = (EventPipeline)this.manager.lookup(EventPipeline.ROLE);
              this.pipeline = (StreamPipeline)this.manager.lookup(StreamPipeline.ROLE);
  
              this.pipeline.setEventPipeline(eventPipeline);
              // set dummy consumer
              ((XMLProducer)eventPipeline).setConsumer(this);
  
              this.environment.setURI(this.prefix, this.uri);
              this.processor.process(this.environment, pipeline, eventPipeline);
              this.environment.changeToLastContext();
                  String redirectURL = this.environment.getRedirectURL();
                  if (redirectURL == null) {
                      if (this.eventPipeline.getGenerator() != null &&
                          this.eventPipeline instanceof CacheableEventPipeline) {
                          CacheableEventPipeline cep = (CacheableEventPipeline)this.eventPipeline;
                          PipelineCacheKey pck = cep.generateKey(this.environment);
                          Map validity = null;
                          if (pck != null) {
                              validity = cep.generateValidity(this.environment);
                              if (validity != null) {
                                  // the event pipeline is cacheable
                                  // now calculate a last modification date
                                  String hashKey = pck.toString() + validity.toString();
                                  this.lastModificationDate = HashUtil.hash(hashKey);
                              }
                          }
                      }
                  } else {
                      if (redirectURL.indexOf(":") == -1) {
                          redirectURL = "cocoon:/" + redirectURL;
                      }
                      this.redirectSource = this.environment.resolveURI(redirectURL);
                      // FIXME (CZ)
                      //this.lastModificationDate = this.redirectSource.getLastModified();
                  }
          } catch (SAXException e) {
              reset();
              this.exception = e;
          } catch (Exception e) {
              reset();
              this.exception = new SAXException("Could not get sitemap source "
                                                       + this.systemId, e);
          }
          this.needsRefresh = false;
      }
  
      /**
       * Return a new <code>InputSource</code> object
       */
      public InputSource getInputSource()
      throws IOException {
          InputSource newObject = new InputSource(this.getInputStream());
          newObject.setSystemId(this.systemId);
          return newObject;
      }
  
      /**
       * Stream content to the content handler
       */
      public void toSAX(ContentHandler contentHandler)
          throws SAXException
      {
          if (this.needsRefresh) {
              this.discardValidity();
          }
          if (this.exception != null) {
              throw this.exception;
          }
          try {
              XMLConsumer consumer;
              if (contentHandler instanceof XMLConsumer) {
                  consumer = (XMLConsumer)contentHandler;
              } else if (contentHandler instanceof LexicalHandler) {
                  consumer = new ContentHandlerWrapper(contentHandler, (LexicalHandler)contentHandler);
              } else {
                  consumer = new ContentHandlerWrapper(contentHandler);
              }
              if (this.redirectSource != null) {
                  // FIXME (CZ)
                  // this.redirectSource.toSAX(consumer);
              } else {
                  try {
                      CocoonComponentManager.enterEnvironment(this.environment,
                                                              this.environment.getObjectModel(),
                                                              this.processor);
                      ((XMLProducer)eventPipeline).setConsumer(consumer);
                      eventPipeline.process(this.environment);
                  } finally {
                      CocoonComponentManager.leaveEnvironment();
                  }
              }
          } catch (ComponentException cme) {
              throw new SAXException("Could not lookup pipeline components", cme);
          } catch (SAXException e) {
              // Preserve original exception
              throw e;
          } catch (Exception e) {
              throw new SAXException("Exception during processing of "
                                            + this.systemId, e);
          } finally {
              reset();
          }
      }
  
      private void reset() {
          if (this.eventPipeline != null) this.manager.release(this.eventPipeline);
          if (this.pipeline != null) this.manager.release(this.pipeline);
          this.eventPipeline = null;
          this.pipeline = null;
          this.lastModificationDate = 0;
          if (this.redirectSource != null) this.environment.release(this.redirectSource);
          this.environment.reset();
          this.redirectSource = null;
          this.exception = null;
          this.needsRefresh = true;
      }
  
      public void recycle() {
          reset();
      }
  }
  
  
  
  1.5       +9 -9      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.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- TreeProcessor.java	31 Mar 2002 21:48:15 -0000	1.4
  +++ TreeProcessor.java	24 Apr 2002 09:59:48 -0000	1.5
  @@ -99,14 +99,14 @@
    * Interpreted tree-traversal implementation of a pipeline assembly language.
    *
    * @author <a href="mailto:sylvain@apache.org">Sylvain Wallez</a>
  - * @version CVS $Id: TreeProcessor.java,v 1.4 2002/03/31 21:48:15 sylvain Exp $
  + * @version CVS $Id: TreeProcessor.java,v 1.5 2002/04/24 09:59:48 cziegeler Exp $
    */
   
   public class TreeProcessor extends AbstractLoggable implements ThreadSafe, Processor,
     Composable, Configurable, LogKitManageable, RoleManageable, Initializable, Contextualizable,
Disposable {
   
       private static final String XCONF_URL =
  -    	"resource://org/apache/cocoon/components/treeprocessor/treeprocessor-builtins.xml";
  +        "resource://org/apache/cocoon/components/treeprocessor/treeprocessor-builtins.xml";
   
       /** The parent TreeProcessor, if any */
       protected TreeProcessor parent;
  @@ -187,7 +187,7 @@
           String language,
           Source source)
         throws Exception {
  -        
  +
           TreeProcessor child = new TreeProcessor(this, manager, language);
           child.setLogger(getLogger());
           child.initialize();
  @@ -255,7 +255,7 @@
               getLogger().error(msg, e);
               throw new ConfigurationException(msg, e);
           }
  -        
  +
           // Create a selector for tree builders of all languages
           this.builderSelector = new ExtendedComponentSelector(Thread.currentThread().getContextClassLoader());
           try {
  @@ -313,7 +313,7 @@
         throws Exception {
   
           SourceHandler oldSourceHandler = environment.getSourceHandler();
  -        CocoonComponentManager.enterEnvironment(environment, environment.getObjectModel());
  +        CocoonComponentManager.enterEnvironment(environment, environment.getObjectModel(),
this);
   
           try {
               environment.setSourceHandler(this.sourceHandler);
  @@ -340,7 +340,7 @@
   
           // Dispose the previous tree, if any
           disposeTree();
  -        
  +
           // Get a builder
           TreeBuilder builder = (TreeBuilder)this.builderSelector.select(this.language);
           ProcessingNode root;
  @@ -349,7 +349,7 @@
                   ((Recomposable)builder).recompose(this.manager);
               }
               builder.setProcessor(this);
  -            
  +
               if (this.source == null) {
                   // FIXME : make the delay configurable
                   this.source = new DelayedRefreshSourceWrapper(env.resolve(builder.getFileName()),
1000L);
  @@ -357,8 +357,8 @@
               root = builder.build(this.source);
   
               this.disposableNodes = builder.getDisposableNodes();
  -            
  -        } finally {        
  +
  +        } finally {
               this.builderSelector.release(builder);
           }
   
  
  
  
  1.16      +3 -3      xml-cocoon2/src/java/org/apache/cocoon/sitemap/Handler.java
  
  Index: Handler.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/sitemap/Handler.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- Handler.java	19 Apr 2002 11:02:57 -0000	1.15
  +++ Handler.java	24 Apr 2002 09:59:48 -0000	1.16
  @@ -86,7 +86,7 @@
    * @author <a href="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
    * @author <a href="mailto:Giacomo.Pati@pwr.ch">Giacomo Pati</a>
    * @author <a href="mailto:stefano@apache.org">Stefano Mazzocchi</a>
  - * @version CVS $Id: Handler.java,v 1.15 2002/04/19 11:02:57 cziegeler Exp $
  + * @version CVS $Id: Handler.java,v 1.16 2002/04/24 09:59:48 cziegeler Exp $
    */
   public class Handler extends AbstractLoggable
   implements Runnable, Contextualizable, Composable, Processor, Disposable, SourceResolver
{
  @@ -218,7 +218,7 @@
       public boolean process(Environment environment) throws Exception {
           checkSanity();
           SourceHandler oldSourceHandler = environment.getSourceHandler();
  -        CocoonComponentManager.enterEnvironment(environment, environment.getObjectModel());
  +        CocoonComponentManager.enterEnvironment(environment, environment.getObjectModel(),
this);
           try {
               environment.setSourceHandler(this.sourceHandler);
               return sitemap.process(environment);
  @@ -232,7 +232,7 @@
           EventPipeline eventPipeline) throws Exception {
           checkSanity();
           SourceHandler oldSourceHandler = environment.getSourceHandler();
  -        CocoonComponentManager.enterEnvironment(environment, environment.getObjectModel());
  +        CocoonComponentManager.enterEnvironment(environment, environment.getObjectModel(),
this);
           try {
               environment.setSourceHandler(this.sourceHandler);
               return sitemap.process(environment, pipeline, eventPipeline);
  
  
  
  1.6       +3 -1      xml-cocoon2/src/java/org/apache/cocoon/xml/XMLizable.java
  
  Index: XMLizable.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/xml/XMLizable.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- XMLizable.java	22 Feb 2002 07:03:58 -0000	1.5
  +++ XMLizable.java	24 Apr 2002 09:59:49 -0000	1.6
  @@ -58,8 +58,10 @@
    * This interface can be implemented by classes willing to provide an XML representation
    * of their current state as SAX events.
    *
  + * @deprecated Use org.apache.avalon.excalibur.xml.XMLizable instead
  + *
    * @author <a href="mailto:sylvain@apache.org">Sylvain Wallez</a>
  - * @version CVS $Id: XMLizable.java,v 1.5 2002/02/22 07:03:58 cziegeler Exp $
  + * @version CVS $Id: XMLizable.java,v 1.6 2002/04/24 09:59:49 cziegeler Exp $
    */
   
   public interface XMLizable {
  
  
  
  1.9       +1 -0      xml-cocoon2/src/webapp/WEB-INF/cocoon.xconf
  
  Index: cocoon.xconf
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/webapp/WEB-INF/cocoon.xconf,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- cocoon.xconf	24 Apr 2002 08:55:32 -0000	1.8
  +++ cocoon.xconf	24 Apr 2002 09:59:49 -0000	1.9
  @@ -177,6 +177,7 @@
     <source-factories>
         <component-instance class="org.apache.excalibur.source.impl.ResourceSourceFactory"
name="resource"/>
         <component-instance class="org.apache.cocoon.components.source.impl.ContextSourceFactory"
name="context"/>
  +      <component-instance class="org.apache.cocoon.components.source.impl.CocoonSourceFactory"
name="cocoon"/>
     </source-factories>
   
   
  
  
  

----------------------------------------------------------------------
In case of troubles, e-mail:     webmaster@xml.apache.org
To unsubscribe, e-mail:          cocoon-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: cocoon-cvs-help@xml.apache.org


Mime
View raw message