You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by cz...@apache.org on 2003/07/31 14:39:04 UTC
cvs commit: cocoon-2.1/src/java/org/apache/cocoon/components/pipeline/impl BaseCachingProcessingPipeline.java AbstractCachingProcessingPipeline.java
cziegeler 2003/07/31 05:39:04
Modified: src/java/org/apache/cocoon/components/pipeline/impl
AbstractCachingProcessingPipeline.java
Added: src/java/org/apache/cocoon/components/pipeline/impl
BaseCachingProcessingPipeline.java
Log:
Create new base class for caching, remove unused method
Revision Changes Path
1.10 +6 -54 cocoon-2.1/src/java/org/apache/cocoon/components/pipeline/impl/AbstractCachingProcessingPipeline.java
Index: AbstractCachingProcessingPipeline.java
===================================================================
RCS file: /home/cvs/cocoon-2.1/src/java/org/apache/cocoon/components/pipeline/impl/AbstractCachingProcessingPipeline.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- AbstractCachingProcessingPipeline.java 31 Jul 2003 03:54:22 -0000 1.9
+++ AbstractCachingProcessingPipeline.java 31 Jul 2003 12:39:04 -0000 1.10
@@ -57,17 +57,11 @@
import java.util.ArrayList;
import java.util.Date;
-import org.apache.avalon.framework.activity.Disposable;
-import org.apache.avalon.framework.component.ComponentException;
-import org.apache.avalon.framework.component.ComponentManager;
import org.apache.avalon.framework.parameters.ParameterException;
import org.apache.avalon.framework.parameters.Parameters;
import org.apache.cocoon.ConnectionResetException;
import org.apache.cocoon.ProcessingException;
import org.apache.cocoon.caching.*;
-import org.apache.cocoon.components.pipeline.AbstractProcessingPipeline;
-import org.apache.cocoon.components.sax.XMLDeserializer;
-import org.apache.cocoon.components.sax.XMLSerializer;
import org.apache.cocoon.environment.Environment;
import org.apache.cocoon.transformation.Transformer;
import org.apache.cocoon.util.HashUtil;
@@ -76,8 +70,8 @@
import org.apache.excalibur.source.impl.validity.DeferredValidity;
/**
- * This is the base class for all caching pipeline implementations.
- *
+ * This is the base class for all caching pipeline implementations
+ * that check the different pipeline components.
*
* @since 2.1
* @author <a href="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
@@ -85,11 +79,7 @@
* @version CVS $Id$
*/
public abstract class AbstractCachingProcessingPipeline
- extends AbstractProcessingPipeline
- implements Disposable {
-
- /** This is the Cache holding cached responses */
- protected Cache cache;
+ extends BaseCachingProcessingPipeline {
/** The role name of the generator */
protected String generatorRole;
@@ -103,11 +93,6 @@
/** The role name of the reader */
protected String readerRole;
- /** The deserializer */
- protected XMLDeserializer xmlDeserializer;
- /** The serializer */
- protected XMLSerializer xmlSerializer;
-
/** The cached byte stream */
protected byte[] cachedResponse;
/** The timestamp of the cached byte stream */
@@ -148,30 +133,12 @@
protected abstract void connectCachingPipeline(Environment environment) throws ProcessingException;
/**
- * Composable Interface
- */
- public void compose (ComponentManager manager)
- throws ComponentException {
- super.compose(manager);
- }
-
- /**
* Parameterizable Interface - Configuration
*/
public void parameterize(Parameters params)
throws ParameterException {
super.parameterize(params);
this.configuredDoSmartCaching = params.getParameterAsBoolean("smart-caching", true);
- String cacheRole = params.getParameter("cache-role", Cache.ROLE);
- if ( this.getLogger().isDebugEnabled()) {
- this.getLogger().debug("Using cache " + cacheRole);
- }
-
- try {
- this.cache = (Cache)this.manager.lookup(cacheRole);
- } catch (ComponentException ce) {
- throw new ParameterException("Unable to lookup cache: " + cacheRole, ce);
- }
}
/**
@@ -970,13 +937,6 @@
* Recyclable Interface
*/
public void recycle() {
- super.recycle();
-
- this.manager.release( this.xmlDeserializer );
- this.xmlDeserializer = null;
-
- this.manager.release( this.xmlSerializer );
- this.xmlSerializer = null;
this.generatorRole = null;
this.transformerRoles.clear();
@@ -989,18 +949,10 @@
this.transformerIsCacheableProcessingComponent = null;
this.toCacheKey = null;
this.toCacheSourceValidities = null;
- }
- /**
- * Disposable Interface
- */
- public void dispose() {
- if ( null != this.manager ) {
- this.manager.release(this.cache);
- }
- this.cache = null;
- this.manager = null;
+ super.recycle();
}
+
}
final class DeferredPipelineValidity implements DeferredValidity {
1.1 cocoon-2.1/src/java/org/apache/cocoon/components/pipeline/impl/BaseCachingProcessingPipeline.java
Index: BaseCachingProcessingPipeline.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 <st...@apache.org>. For more information on the Apache
Software Foundation, please see <http://www.apache.org/>.
*/
package org.apache.cocoon.components.pipeline.impl;
import org.apache.avalon.framework.activity.Disposable;
import org.apache.avalon.framework.component.ComponentException;
import org.apache.avalon.framework.parameters.ParameterException;
import org.apache.avalon.framework.parameters.Parameters;
import org.apache.cocoon.caching.Cache;
import org.apache.cocoon.components.pipeline.AbstractProcessingPipeline;
import org.apache.cocoon.components.sax.XMLDeserializer;
import org.apache.cocoon.components.sax.XMLSerializer;
/**
* This is the base class for all caching pipeline implementations.
* The pipeline can be configured with the {@link Cache} to use
* by specifying the <code>cache-role</code> parameter.
*
* @since 2.1
* @author <a href="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
* @version CVS $Id: BaseCachingProcessingPipeline.java,v 1.1 2003/07/31 12:39:04 cziegeler Exp $
*/
public abstract class BaseCachingProcessingPipeline
extends AbstractProcessingPipeline
implements Disposable {
/** This is the Cache holding cached responses */
protected Cache cache;
/** The deserializer */
protected XMLDeserializer xmlDeserializer;
/** The serializer */
protected XMLSerializer xmlSerializer;
/**
* Parameterizable Interface - Configuration
*/
public void parameterize(Parameters params)
throws ParameterException {
super.parameterize(params);
String cacheRole = params.getParameter("cache-role", Cache.ROLE);
if ( this.getLogger().isDebugEnabled()) {
this.getLogger().debug("Using cache " + cacheRole);
}
try {
this.cache = (Cache)this.manager.lookup(cacheRole);
} catch (ComponentException ce) {
throw new ParameterException("Unable to lookup cache: " + cacheRole, ce);
}
}
/**
* Recyclable Interface
*/
public void recycle() {
this.manager.release( this.xmlDeserializer );
this.xmlDeserializer = null;
this.manager.release( this.xmlSerializer );
this.xmlSerializer = null;
super.recycle();
}
/**
* Disposable Interface
*/
public void dispose() {
if ( null != this.manager ) {
this.manager.release(this.cache);
}
this.cache = null;
this.manager = null;
}
}