Author: vgritsenko Date: Fri Mar 11 13:13:35 2005 New Revision: 157159 URL: http://svn.apache.org/viewcvs?view=rev&rev=157159 Log: whitespace / formatting
Modified: cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/pipeline/impl/AbstractCachingProcessingPipeline.java cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/pipeline/impl/BaseCachingProcessingPipeline.java cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/pipeline/impl/CachingProcessingPipeline.java Modified: cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/pipeline/impl/AbstractCachingProcessingPipeline.java URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/pipeline/impl/AbstractCachingProcessingPipeline.java?view=diff&r1=157158&r2=157159 ============================================================================== --- cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/pipeline/impl/AbstractCachingProcessingPipeline.java (original) +++ cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/pipeline/impl/AbstractCachingProcessingPipeline.java Fri Mar 11 13:13:35 2005 @@ -1,5 +1,5 @@ /* - * Copyright 1999-2004 The Apache Software Foundation. + * Copyright 1999-2005 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. @@ -49,10 +49,9 @@ * @since 2.1 * @author <a href="mailto:[EMAIL PROTECTED]">Carsten Ziegeler</a> * @author <a href="mailto:[EMAIL PROTECTED]">Michael Melhem</a> - * @version CVS $Id$ + * @version $Id$ */ -public abstract class AbstractCachingProcessingPipeline - extends BaseCachingProcessingPipeline { +public abstract class AbstractCachingProcessingPipeline extends BaseCachingProcessingPipeline { /** The role name of the generator */ protected String generatorRole; @@ -71,19 +70,23 @@ /** The index indicating the first transformer getting input from the cache */ protected int firstProcessedTransformerIndex; + /** Complete response is cached */ protected boolean completeResponseIsCached; /** This key indicates the response that is fetched from the cache */ protected PipelineCacheKey fromCacheKey; + /** This key indicates the response that will get into the cache */ protected PipelineCacheKey toCacheKey; + /** The source validities used for caching */ protected SourceValidity[] toCacheSourceValidities; /** The index indicating to the first transformer which is not cacheable */ protected int firstNotCacheableTransformerIndex; + /** Cache complete response */ protected boolean cacheCompleteResponse; @@ -93,18 +96,25 @@ /** Smart caching ? */ protected boolean doSmartCaching; + /** Default setting for smart caching */ protected boolean configuredDoSmartCaching; - /** - * Abstract methods defined in subclasses - */ + + /** Abstract method defined in subclasses */ protected abstract void cacheResults(Environment environment, - OutputStream os) throws Exception; + OutputStream os) + throws Exception; + + /** Abstract method defined in subclasses */ protected abstract ComponentCacheKey newComponentCacheKey(int type, - String role,Serializable key); + String role, + Serializable key); + + /** Abstract method defined in subclasses */ protected abstract void connectCachingPipeline(Environment environment) - throws ProcessingException; + throws ProcessingException; + /** * Parameterizable Interface - Configuration @@ -158,7 +168,8 @@ * Set the Reader. */ public void setReader (String role, String source, Parameters param, - String mimeType) throws ProcessingException { + String mimeType) + throws ProcessingException { super.setReader(role, source, param, mimeType); this.readerRole = role; } @@ -606,16 +617,17 @@ */ protected void setupPipeline(Environment environment) throws ProcessingException { - super.setupPipeline( environment ); + super.setupPipeline(environment); - // generate the key to fill the cache - this.generateCachingKey(environment); + // Generate the key to fill the cache + generateCachingKey(environment); - // test the cache for a valid response + // Test the cache for a valid response if (this.toCacheKey != null) { - this.validatePipeline(environment); + validatePipeline(environment); } - this.setupValidities(); + + setupValidities(); } /** @@ -690,7 +702,7 @@ readerValidity = ((CacheableProcessingComponent)super.reader).getValidity(); } else { CacheValidity cv = ((Cacheable)super.reader).generateValidity(); - if ( cv != null ) { + if (cv != null) { readerValidity = CacheValidityToSourceValidity.createValidity( cv ); } } @@ -804,7 +816,7 @@ public SourceValidity getValidityForEventPipeline() { if (this.cachedResponse != null) { if (this.toCacheSourceValidities != null) { - // This means that the pipeline is valid based on the validities + // This means that the pipeline is valid based on the validities // of the individual components final AggregatedValidity validity = new AggregatedValidity(); for (int i=0; i < this.toCacheSourceValidities.length; i++) { Modified: cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/pipeline/impl/BaseCachingProcessingPipeline.java URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/pipeline/impl/BaseCachingProcessingPipeline.java?view=diff&r1=157158&r2=157159 ============================================================================== --- cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/pipeline/impl/BaseCachingProcessingPipeline.java (original) +++ cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/pipeline/impl/BaseCachingProcessingPipeline.java Fri Mar 11 13:13:35 2005 @@ -1,12 +1,12 @@ /* - * Copyright 1999-2004 The Apache Software Foundation. - * + * Copyright 1999-2005 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. @@ -31,18 +31,18 @@ * * @since 2.1 * @author <a href="mailto:[EMAIL PROTECTED]">Carsten Ziegeler</a> - * @version CVS $Id: BaseCachingProcessingPipeline.java,v 1.2 2004/03/05 13:02:50 bdelacretaz Exp $ + * @version $Id$ */ -public abstract class BaseCachingProcessingPipeline - extends AbstractProcessingPipeline - implements Disposable { +public abstract class BaseCachingProcessingPipeline extends AbstractProcessingPipeline + implements Disposable { /** This is the Cache holding cached responses */ - protected Cache cache; + protected Cache cache; - /** The deserializer */ + /** The XML Deserializer */ protected XMLDeserializer xmlDeserializer; - /** The serializer */ + + /** The XML Serializer */ protected XMLSerializer xmlSerializer; /** @@ -51,27 +51,27 @@ 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); + if (getLogger().isDebugEnabled()) { + getLogger().debug("Using cache " + cacheRole); } - + try { - this.cache = (Cache)this.manager.lookup(cacheRole); + 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.manager.release(this.xmlDeserializer); this.xmlDeserializer = null; - this.manager.release( this.xmlSerializer ); + this.manager.release(this.xmlSerializer); this.xmlSerializer = null; super.recycle(); @@ -81,7 +81,7 @@ * Disposable Interface */ public void dispose() { - if ( null != this.manager ) { + if (null != this.manager) { this.manager.release(this.cache); } this.cache = null; Modified: cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/pipeline/impl/CachingProcessingPipeline.java URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/pipeline/impl/CachingProcessingPipeline.java?view=diff&r1=157158&r2=157159 ============================================================================== --- cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/pipeline/impl/CachingProcessingPipeline.java (original) +++ cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/pipeline/impl/CachingProcessingPipeline.java Fri Mar 11 13:13:35 2005 @@ -1,5 +1,5 @@ /* - * Copyright 1999-2004 The Apache Software Foundation. + * Copyright 1999-2005 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. @@ -37,37 +37,37 @@ * * @since 2.1 * @author <a href="mailto:[EMAIL PROTECTED]">Carsten Ziegeler</a> - * @version CVS $Id$ + * @version $Id$ */ -public class CachingProcessingPipeline - extends AbstractCachingProcessingPipeline { +public class CachingProcessingPipeline extends AbstractCachingProcessingPipeline { /** - * Cache longest cacheable key - */ - protected void cacheResults(Environment environment, OutputStream os) throws Exception { + * Cache longest cacheable key + */ + protected void cacheResults(Environment environment, OutputStream os) + throws Exception { if (this.toCacheKey != null) { // See if there is an expires object for this resource. Long expiresObj = (Long) environment.getObjectModel().get(ObjectModelHelper.EXPIRES_OBJECT); - if ( this.cacheCompleteResponse ) { - CachedResponse response = new CachedResponse(this.toCacheSourceValidities, - ((CachingOutputStream)os).getContent(), - expiresObj); + + CachedResponse response; + if (this.cacheCompleteResponse) { + response = new CachedResponse(this.toCacheSourceValidities, + ((CachingOutputStream) os).getContent(), + expiresObj); response.setContentType(environment.getContentType()); - this.cache.store(this.toCacheKey, - response); } else { - CachedResponse response = new CachedResponse(this.toCacheSourceValidities, - (byte[])this.xmlSerializer.getSAXFragment(), - expiresObj); - this.cache.store(this.toCacheKey, - response); + response = new CachedResponse(this.toCacheSourceValidities, + (byte[]) this.xmlSerializer.getSAXFragment(), + expiresObj); } + + this.cache.store(this.toCacheKey, response); } } /** - * create a new cache key + * Create a new cache key */ protected ComponentCacheKey newComponentCacheKey(int type, String role,Serializable key) { return new ComponentCacheKey(type, role, key); @@ -79,70 +79,73 @@ */ protected void connectCachingPipeline(Environment environment) throws ProcessingException { - try { - XMLSerializer localXMLSerializer = null; - if (!this.cacheCompleteResponse) { - this.xmlSerializer = (XMLSerializer)this.manager.lookup( XMLSerializer.ROLE ); - localXMLSerializer = this.xmlSerializer; - } + try { + XMLSerializer localXMLSerializer = null; + if (!this.cacheCompleteResponse) { + this.xmlSerializer = (XMLSerializer) this.manager.lookup(XMLSerializer.ROLE); + localXMLSerializer = this.xmlSerializer; + } - if (this.cachedResponse == null) { - XMLProducer prev = super.generator; - XMLConsumer next; - - int cacheableTransformerCount = this.firstNotCacheableTransformerIndex; - - Iterator itt = this.transformers.iterator(); - while ( itt.hasNext() ) { - next = (XMLConsumer) itt.next(); - if (localXMLSerializer != null) { - if (cacheableTransformerCount == 0) { - next = new XMLTeePipe(next, localXMLSerializer); - localXMLSerializer = null; - } else { - cacheableTransformerCount--; - } - } - this.connect(environment, prev, next); - prev = (XMLProducer) next; - } - next = super.lastConsumer; + if (this.cachedResponse == null) { + XMLProducer prev = super.generator; + XMLConsumer next; + + int cacheableTransformerCount = this.firstNotCacheableTransformerIndex; + Iterator itt = this.transformers.iterator(); + while (itt.hasNext()) { + next = (XMLConsumer) itt.next(); if (localXMLSerializer != null) { - next = new XMLTeePipe(next, localXMLSerializer); - localXMLSerializer = null; - } - this.connect(environment, prev, next); - } else { - this.xmlDeserializer = (XMLDeserializer)this.manager.lookup(XMLDeserializer.ROLE); - // connect the pipeline: - XMLProducer prev = xmlDeserializer; - XMLConsumer next; - int cacheableTransformerCount = 0; - Iterator itt = this.transformers.iterator(); - while ( itt.hasNext() ) { - next = (XMLConsumer) itt.next(); - if (cacheableTransformerCount >= this.firstProcessedTransformerIndex) { - if (localXMLSerializer != null - && cacheableTransformerCount == this.firstNotCacheableTransformerIndex) { - next = new XMLTeePipe(next, localXMLSerializer); - localXMLSerializer = null; - } - this.connect(environment, prev, next); - prev = (XMLProducer)next; + if (cacheableTransformerCount == 0) { + next = new XMLTeePipe(next, localXMLSerializer); + localXMLSerializer = null; + } else { + cacheableTransformerCount--; } - cacheableTransformerCount++; } - next = super.lastConsumer; - if (localXMLSerializer != null) { - next = new XMLTeePipe(next, localXMLSerializer); - localXMLSerializer = null; + connect(environment, prev, next); + prev = (XMLProducer) next; + } + + next = super.lastConsumer; + if (localXMLSerializer != null) { + next = new XMLTeePipe(next, localXMLSerializer); + localXMLSerializer = null; + } + connect(environment, prev, next); + + } else { + this.xmlDeserializer = (XMLDeserializer) this.manager.lookup(XMLDeserializer.ROLE); + + // connect the pipeline: + XMLProducer prev = xmlDeserializer; + XMLConsumer next; + + int cacheableTransformerCount = 0; + Iterator itt = this.transformers.iterator(); + while (itt.hasNext()) { + next = (XMLConsumer) itt.next(); + if (cacheableTransformerCount >= this.firstProcessedTransformerIndex) { + if (localXMLSerializer != null + && cacheableTransformerCount == this.firstNotCacheableTransformerIndex) { + next = new XMLTeePipe(next, localXMLSerializer); + localXMLSerializer = null; + } + connect(environment, prev, next); + prev = (XMLProducer) next; } - this.connect(environment, prev, next); + cacheableTransformerCount++; } - } catch ( ComponentException e ) { - throw new ProcessingException("Could not connect pipeline.", e); + next = super.lastConsumer; + if (localXMLSerializer != null) { + next = new XMLTeePipe(next, localXMLSerializer); + localXMLSerializer = null; + } + connect(environment, prev, next); } - } + } catch (ComponentException e) { + throw new ProcessingException("Could not connect pipeline.", e); + } + } }