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/scratchpad/src/org/apache/cocoon/treeprocessor/sitemap PipelineNode.java
Date Tue, 15 Jan 2002 07:42:02 GMT
cziegeler    02/01/14 23:42:02

  Modified:    .        changes.xml
               src/java/org/apache/cocoon/components/language/markup/sitemap/java
                        sitemap.xsl
               src/java/org/apache/cocoon/environment
                        AbstractEnvironment.java Environment.java
               src/java/org/apache/cocoon/environment/http
                        HttpEnvironment.java
               src/java/org/apache/cocoon/sitemap AbstractSitemap.java
               src/scratchpad/src/org/apache/cocoon/treeprocessor/sitemap
                        PipelineNode.java
  Added:       lib/optional jstyle.jar servlet_2_2.jar
  Removed:     lib/core jstyle.jar servlet_2_2.jar
  Log:
  Finished first separation of optional and core jars. For compilation are only
  the core jars necessary. However for running the sample webapp, some of
  the optional ones are still required (as some of the components are
  hard-coded into the cocoon.xconf).
  (Even the servlet.jar is now optional)
  
  Revision  Changes    Path
  1.71      +6 -1      xml-cocoon2/changes.xml
  
  Index: changes.xml
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/changes.xml,v
  retrieving revision 1.70
  retrieving revision 1.71
  diff -u -r1.70 -r1.71
  --- changes.xml	15 Jan 2002 05:14:14 -0000	1.70
  +++ changes.xml	15 Jan 2002 07:42:02 -0000	1.71
  @@ -4,7 +4,7 @@
   
   <!--
     History of Cocoon changes
  -  $Id: changes.xml,v 1.70 2002/01/15 05:14:14 crossley Exp $
  +  $Id: changes.xml,v 1.71 2002/01/15 07:42:02 cziegeler Exp $
   -->
   
   <changes title="History of Changes">
  @@ -29,6 +29,11 @@
    </devs>
   
    <release version="@version@" date="@date@">
  +  <action dev="CZ" type="update">
  +    Separated the jars into core and optional. For compiling only the
  +    core jars are necessary. However, the sample webapp still needs some
  +    optional jars.
  +  </action>
     <action dev="VG" type="add">
       Added matchers: 
       RegexpHeaderMatcher, RegexpRequestAttributeMatcher,
  
  
  
  1.3       +0 -0      xml-cocoon2/lib/optional/jstyle.jar
  
  	<<Binary file>>
  
  
  1.1                  xml-cocoon2/lib/optional/servlet_2_2.jar
  
  	<<Binary file>>
  
  
  1.4       +2 -2      xml-cocoon2/src/java/org/apache/cocoon/components/language/markup/sitemap/java/sitemap.xsl
  
  Index: sitemap.xsl
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/language/markup/sitemap/java/sitemap.xsl,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- sitemap.xsl	14 Jan 2002 03:07:52 -0000	1.3
  +++ sitemap.xsl	15 Jan 2002 07:42:02 -0000	1.4
  @@ -214,7 +214,7 @@
        * @author &lt;a href="mailto:bloritsch@apache.org"&gt;Berin Loritsch&lt;/a&gt;
        * @author &lt;a href="mailto:barozzi@nicolaken.com"&gt;Nicola Ken Barozzi&lt;/a&gt;
        * @author &lt;a href="mailto:proyal@managingpartners.com"&gt;Peter Royal&lt;/a&gt;
  -     * @version CVS $Id: sitemap.xsl,v 1.3 2002/01/14 03:07:52 vgritsenko Exp $
  +     * @version CVS $Id: sitemap.xsl,v 1.4 2002/01/15 07:42:02 cziegeler Exp $
        */
       public class <xsl:value-of select="@file-name"/> extends AbstractSitemap {
         static final String LOCATION = "<xsl:value-of select="translate(@file-path, '/',
'.')"/>.<xsl:value-of select="@file-name"/>";
  @@ -740,7 +740,7 @@
               EventPipeline eventPipeline = null;
               StreamPipeline pipeline = null;
               try {
  -              tryResetResponse(objectModel);
  +              environment.tryResetResponse();
                 eventPipeline = (EventPipeline)this.manager.lookup(EventPipeline.ROLE);
                 pipeline = (StreamPipeline)this.manager.lookup(StreamPipeline.ROLE);
                 pipeline.setEventPipeline(eventPipeline);
  
  
  
  1.3       +18 -6     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.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- AbstractEnvironment.java	9 Jan 2002 21:30:10 -0000	1.2
  +++ AbstractEnvironment.java	15 Jan 2002 07:42:02 -0000	1.3
  @@ -26,7 +26,7 @@
    *
    * @author <a href="mailto:Giacomo.Pati@pwr.ch">Giacomo Pati</a>
    * @author <a href="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
  - * @version CVS $Revision: 1.2 $ $Date: 2002/01/09 21:30:10 $
  + * @version CVS $Revision: 1.3 $ $Date: 2002/01/15 07:42:02 $
    */
   public abstract class AbstractEnvironment extends AbstractLoggable implements Environment
{
   
  @@ -56,7 +56,7 @@
   
       /** The attributes */
       private Map attributes = new HashMap();
  -    
  +
       /**
        * Constructs the abstract enviornment
        */
  @@ -229,7 +229,7 @@
                   this.context = f.toURL();
               }
           }
  -        
  +
           if (getLogger().isDebugEnabled()) {
               getLogger().debug("New context is " + this.context.toExternalForm());
           }
  @@ -301,7 +301,7 @@
           } else {
               source = this.sourceHandler.getSource(this, this.context, systemId);
           }
  -        
  +
           if (getLogger().isDebugEnabled()) {
               this.getLogger().debug("Resolved to '"+source.getSystemId()+"'");
           }
  @@ -334,12 +334,24 @@
       public void setAttribute(String name, Object value) {
           this.attributes.put(name, value);
       }
  -    
  +
       public void removeAttribute(String name) {
           this.attributes.remove(name);
       }
  -    
  +
       public Enumeration getAttributeNames() {
           return new IteratorEnumeration(this.attributes.keySet().iterator());
       }
  +
  +    /**
  +     * Reset the response if possible. This allows error handlers to have
  +     * a higher chance to produce clean output if the pipeline that raised
  +     * the error has already output some data.
  +     *
  +     * @return true if the response was successfully reset
  +    */
  +    public boolean tryResetResponse() {
  +        return false;
  +    }
  +
   }
  
  
  
  1.2       +14 -5     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.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Environment.java	3 Jan 2002 12:31:15 -0000	1.1
  +++ Environment.java	15 Jan 2002 07:42:02 -0000	1.2
  @@ -21,7 +21,7 @@
    *
    * @author <a href="mailto:Giacomo.Pati@pwr.ch">Giacomo Pati</a>
    * @author <a href="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
  - * @version CVS $Revision: 1.1 $ $Date: 2002/01/03 12:31:15 $
  + * @version CVS $Revision: 1.2 $ $Date: 2002/01/15 07:42:02 $
    */
   
   public interface Environment extends SourceResolver {
  @@ -126,7 +126,7 @@
        * Mark the response as not modified.
        */
       void setResponseIsNotModified();
  -    
  +
       /**
        * Binds an object to this environment, using the name specified. This allows
        * the pipeline assembly engine to store for its own use objects that souldn't
  @@ -139,7 +139,7 @@
        * @param value the object to be bound
        */
       void setAttribute(String name, Object value);
  -    
  +
       /**
        * Returns the object bound with the specified name, or <code>null</code>
        * if no object is bound under the name.
  @@ -148,7 +148,7 @@
        * @return                        the object with the specified name
        */
       Object getAttribute(String name);
  -    
  +
       /**
        * Removes the object bound with the specified name from
        * this environment. If the environment does not have an object
  @@ -157,7 +157,7 @@
        * @param name the name of the object to remove
        */
       void removeAttribute(String name);
  -    
  +
       /**
        * Returns an <code>Enumeration</code> of <code>String</code>
objects
        * containing the names of all the objects bound to this environment.
  @@ -165,6 +165,15 @@
        * @return an <code>Enumeration</code> of <code>String</code>s.
        */
       Enumeration getAttributeNames();
  +
  +    /**
  +     * Reset the response if possible. This allows error handlers to have
  +     * a higher chance to produce clean output if the pipeline that raised
  +     * the error has already output some data.
  +     *
  +     * @return true if the response was successfully reset
  +    */
  +    boolean tryResetResponse();
   
   }
   
  
  
  
  1.2       +23 -1     xml-cocoon2/src/java/org/apache/cocoon/environment/http/HttpEnvironment.java
  
  Index: HttpEnvironment.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/environment/http/HttpEnvironment.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- HttpEnvironment.java	3 Jan 2002 12:31:16 -0000	1.1
  +++ HttpEnvironment.java	15 Jan 2002 07:42:02 -0000	1.2
  @@ -46,7 +46,7 @@
        * Constructs a HttpEnvironment object from a HttpServletRequest
        * and HttpServletResponse objects
        */
  -    public HttpEnvironment (String uri, 
  +    public HttpEnvironment (String uri,
                               URL rootURL,
                               HttpServletRequest req,
                               HttpServletResponse res,
  @@ -158,6 +158,28 @@
        */
       public void setResponseIsNotModified() {
           this.response.setStatus(HttpServletResponse.SC_NOT_MODIFIED);
  +    }
  +
  +    /**
  +     * Reset the response if possible. This allows error handlers to have
  +     * a higher chance to produce clean output if the pipeline that raised
  +     * the error has already output some data.
  +     *
  +     * @return true if the response was successfully reset
  +    */
  +    public boolean tryResetResponse() {
  +        try {
  +            if ( !this.response.isCommitted() ) {
  +                this.response.reset();
  +                getLogger().debug("Response successfully reset");
  +                return true;
  +            }
  +        } catch(Exception e) {
  +            // Log the error, but don't transmit it
  +            getLogger().warn("Problem resetting response", e);
  +        }
  +        getLogger().debug("Response wasn't reset");
  +        return false;
       }
   
   }
  
  
  
  1.3       +3 -18     xml-cocoon2/src/java/org/apache/cocoon/sitemap/AbstractSitemap.java
  
  Index: AbstractSitemap.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/sitemap/AbstractSitemap.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- AbstractSitemap.java	7 Jan 2002 12:34:13 -0000	1.2
  +++ AbstractSitemap.java	15 Jan 2002 07:42:02 -0000	1.3
  @@ -27,7 +27,6 @@
   import org.apache.cocoon.components.pipeline.StreamPipeline;
   import org.apache.cocoon.components.url.URLFactory;
   import org.apache.cocoon.environment.Environment;
  -import org.apache.cocoon.environment.http.HttpResponse;
   import org.apache.cocoon.generation.Generator;
   import org.apache.cocoon.matching.Matcher;
   import org.apache.cocoon.reading.Reader;
  @@ -48,7 +47,7 @@
    * Base class for generated <code>Sitemap</code> classes
    *
    * @author <a href="mailto:Giacomo.Pati@pwr.ch">Giacomo Pati</a>
  - * @version CVS $Revision: 1.2 $ $Date: 2002/01/07 12:34:13 $
  + * @version CVS $Revision: 1.3 $ $Date: 2002/01/15 07:42:02 $
    */
   public abstract class AbstractSitemap extends AbstractLoggable implements Sitemap, Disposable,
ThreadSafe {
       private Context context;
  @@ -422,26 +421,12 @@
   
         @param objectModel the object model
         @return true if the response was successfully reset
  +      @deprecated Use the tryResetResponse on the Environment instead.
         */
   
       protected boolean tryResetResponse(Map objectModel)
       {
  -        try {
  -            Object responseObj = objectModel.get(Constants.RESPONSE_OBJECT);
  -            if (responseObj instanceof HttpResponse) {
  -                HttpResponse response = (HttpResponse)responseObj;
  -                if (! response.isCommitted()) {
  -                    response.reset();
  -                    getLogger().debug("Response successfully reset");
  -                    return true;
  -                }
  -            }
  -        } catch(Exception e) {
  -            // Log the error, but don't transmit it
  -            getLogger().warn("Problem resetting response", e);
  -        }
  -
  -        getLogger().debug("Response wasn't reset");
  +        getLogger().warn("tryResetResponse in AbstractSitemap is deprecated!");
           return false;
       }
   }
  
  
  
  1.2       +32 -47    xml-cocoon2/src/scratchpad/src/org/apache/cocoon/treeprocessor/sitemap/PipelineNode.java
  
  Index: PipelineNode.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/scratchpad/src/org/apache/cocoon/treeprocessor/sitemap/PipelineNode.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- PipelineNode.java	3 Jan 2002 12:31:37 -0000	1.1
  +++ PipelineNode.java	15 Jan 2002 07:42:02 -0000	1.2
  @@ -17,7 +17,6 @@
   
   import org.apache.cocoon.environment.Environment;
   import org.apache.cocoon.environment.ObjectModelHelper;
  -import org.apache.cocoon.environment.http.HttpResponse;
   import org.apache.cocoon.components.pipeline.EventPipeline;
   import org.apache.cocoon.components.pipeline.StreamPipeline;
   import org.apache.cocoon.treeprocessor.AbstractParentProcessingNode;
  @@ -28,70 +27,70 @@
   import java.util.*;
   
   /**
  - * 
  + *
    *
    * @author <a href="mailto:sylvain@apache.org">Sylvain Wallez</a>
  - * @version CVS $Revision: 1.1 $ $Date: 2002/01/03 12:31:37 $
  + * @version CVS $Revision: 1.2 $ $Date: 2002/01/15 07:42:02 $
    */
   
   public class PipelineNode extends AbstractParentProcessingNode implements Composable {
   
       // TODO : handle a 'fail-hard' environment attribute
       // can be useful to stop off-line generation when there's an error
  -    
  +
       private ProcessingNode[] children;
  -    
  +
       private ProcessingNode error404;
  -    
  +
       private ProcessingNode error500;
   
       private ComponentManager manager;
  -    
  +
       private boolean internalOnly = false;
  -    
  +
       /** Is it the last <pipeline> in the enclosing <pipelines> ? */
       private boolean isLast = false;
  -    
  +
       /**
        * The component manager is used to create error pipelines
        */
       public void compose(ComponentManager manager) {
           this.manager = manager;
       }
  -    
  +
       public void setChildren(ProcessingNode[] nodes)
       {
           this.children = nodes;
       }
  -    
  +
       public void setLast(boolean isLast) {
           this.isLast = isLast;
       }
  -    
  +
       public void set404Handler(ProcessingNode node)
       {
           this.error404 = node;
       }
  -    
  +
       public void set500Handler(ProcessingNode node)
       {
           this.error500 = node;
       }
  -    
  +
       public void setInternalOnly(boolean internalOnly) {
           this.internalOnly = internalOnly;
       }
   
       public final boolean invoke(Environment env, InvokeContext context)
         throws Exception {
  -        
  +
           // Always fail on external resquests if internal only.
           if (this.internalOnly && !context.isInternalRequest()) {
               return false;
           }
  -        
  +
           try {
  -            
  +
               if (invokeNodes(children, env, context)) {
                   return true;
               } else if (this.isLast) {
  @@ -100,62 +99,62 @@
               } else {
                   return false;
               }
  -            
  +
           } catch (ConnectionResetException cre) {
               // Will be reported by CocoonServlet, rethrowing
               throw cre;
   
           } catch(ResourceNotFoundException rnfe) {
               getLogger().warn("Resource not found in pipeline at " + getLocation(), rnfe);
  -            
  +
               if (error404 != null) {
                   // There's a handler
                   return invokeErrorHandler(error404, rnfe, env);
  -                
  +
               } else {
                   // No handler : propagate
                   throw rnfe;
               }
   
           } catch(Exception e) {
  -            
  +
               // Rethrow exception for internal requests
               if (error500 != null && !context.isInternalRequest()) {
  -                
  +
                   getLogger().warn("Error while processing pipeline at " + getLocation(),
e);
  -                
  +
                   return invokeErrorHandler(error500, e, env);
  -                
  +
               } else {
                   // No handler : propagate
  -                
  +
                   getLogger().error("Error while processing pipeline at " + getLocation(),
e);
                   throw e;
               }
           }
       }
  -    
  +
       private boolean invokeErrorHandler(ProcessingNode node, Exception ex, Environment env)
         throws Exception {
   
           InvokeContext errorContext = null;
  -        
  +
           try {
               tryResetResponse(env);
  -            
  +
               // Build a new context
               errorContext = new InvokeContext();
               errorContext.compose(this.manager);
  -            
  +
               errorContext.getEventPipeline().setGenerator("!error-notifier!", ex.getMessage(),
                   MapStackResolver.EMPTY_PARAMETERS, ex);
  -            
  +
               return node.invoke(env, errorContext);
  -            
  +
           } catch (Exception subEx) {
               getLogger().error("error notifier barfs", subEx);
               return false;
  -            
  +
           } finally {
               if (errorContext != null) {
                   errorContext.dispose();
  @@ -173,20 +172,6 @@
        */
       private void tryResetResponse(Environment env)
       {
  -        try {
  -            Object responseObj = ObjectModelHelper.getRequest(env.getObjectModel());
  -            if (responseObj instanceof HttpResponse) {
  -                HttpResponse response = (HttpResponse)responseObj;
  -                if (! response.isCommitted()) {
  -                    response.reset();
  -                    getLogger().debug("Response successfully reset");
  -                }
  -            }
  -        } catch(Exception e) {
  -            // Log the error, but don't transmit it
  -            getLogger().warn("Problem resetting response", e);
  -        }
  -        
  -        getLogger().debug("Response wasn't reset");
  +        env.tryResetResponse();
       }
   }
  
  
  

----------------------------------------------------------------------
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