cziegeler 2003/02/28 06:26:53
Modified: src/java/org/apache/cocoon/transformation CIncludeTransformer.java Log: Remove the need of the cache manager Revision Changes Path 1.25 +20 -10 xml-cocoon2/src/java/org/apache/cocoon/transformation/CIncludeTransformer.java Index: CIncludeTransformer.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/transformation/CIncludeTransformer.java,v retrieving revision 1.24 retrieving revision 1.25 diff -u -r1.24 -r1.25 --- CIncludeTransformer.java 28 Feb 2003 14:14:25 -0000 1.24 +++ CIncludeTransformer.java 28 Feb 2003 14:26:53 -0000 1.25 @@ -220,7 +220,9 @@ throws ProcessingException, SAXException, IOException { super.setup(resolver, objectModel, source, parameters); this.state = STATE_OUTSIDE; - this.cachingSession = this.cacheManager.getSession( this.parameters ); + if ( null != this.cacheManager ) { + this.cachingSession = this.cacheManager.getSession( this.parameters ); + } this.compiling = false; this.supportCaching = parameters.getParameterAsBoolean("support-caching", false); if (this.getLogger().isErrorEnabled()) { @@ -234,7 +236,9 @@ */ public void compose(ComponentManager manager) throws ComponentException { super.compose(manager); - this.cacheManager = (IncludeCacheManager) this.manager.lookup( IncludeCacheManager.ROLE ); + if ( this.manager.hasComponent( IncludeCacheManager.ROLE )) { + this.cacheManager = (IncludeCacheManager) this.manager.lookup( IncludeCacheManager.ROLE ); + } } /** @@ -250,7 +254,9 @@ * Recycle the component */ public void recycle() { - this.cacheManager.terminateSession( this.cachingSession ); + if ( null != this.cachingSession ) { + this.cacheManager.terminateSession( this.cachingSession ); + } this.cachingSession = null; if ( null != this.recorder) { this.manager.release( this.recorder ); @@ -323,11 +329,11 @@ } else if (name.equals(CINCLUDE_CACHED_INCLUDE_ELEMENT)) { String src = this.processCIncludeElement(attr.getValue("",CINCLUDE_INCLUDE_ELEMENT_SRC_ATTRIBUTE), - attr.getValue("",CINCLUDE_INCLUDE_ELEMENT_ELEMENT_ATTRIBUTE), null, - attr.getValue("",CINCLUDE_INCLUDE_ELEMENT_NS_ATTRIBUTE), - attr.getValue("",CINCLUDE_INCLUDE_ELEMENT_PREFIX_ATTRIBUTE), - true); + null, + null, + null, + this.cacheManager != null); if (this.compiling) { this.srcAttributes.addAttribute("", "src", "src", "CDATA", src); super.startTransformingElement(uri, @@ -637,7 +643,9 @@ * @see org.apache.cocoon.caching.CacheableProcessingComponent#generateKey() */ public Serializable generateKey() { - if (this.supportCaching && this.cachingSession.getExpires() > 0) { + if (this.supportCaching + && null != this.cacheManager + && this.cachingSession.getExpires() > 0) { return "1"; } return null; @@ -647,7 +655,9 @@ * @see org.apache.cocoon.caching.CacheableProcessingComponent#generateValidity() */ public SourceValidity generateValidity() { - if (this.supportCaching && this.cachingSession.getExpires() > 0 + if (this.supportCaching + && null != this.cacheManager + && this.cachingSession.getExpires() > 0 && !this.cachingSession.isPurging()) { return this.cachingSession.getExpiresValidity(); }