bloritsch 2003/10/16 08:00:37
Modified: src/java/org/apache/cocoon/transformation/helpers PreemptiveLoaderAction.java src/java/org/apache/cocoon/transformation CIncludeTransformer.java Log: Update to Serviceable contracts Revision Changes Path 1.5 +3 -3 cocoon-2.2/src/java/org/apache/cocoon/transformation/helpers/PreemptiveLoaderAction.java Index: PreemptiveLoaderAction.java =================================================================== RCS file: /home/cvs/cocoon-2.2/src/java/org/apache/cocoon/transformation/helpers/PreemptiveLoaderAction.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- PreemptiveLoaderAction.java 15 Oct 2003 20:16:44 -0000 1.4 +++ PreemptiveLoaderAction.java 16 Oct 2003 15:00:37 -0000 1.5 @@ -60,12 +60,12 @@ /** * This action starts the preemptive loader and runs forever. - * + * * @author <a href="mailto:[EMAIL PROTECTED]">Carsten Ziegeler</a> * @version CVS $Id$ * @since 2.1 */ -public class PreemptiveLoaderAction +public class PreemptiveLoaderAction extends ServiceableAction implements ThreadSafe { 1.7 +58 -58 cocoon-2.2/src/java/org/apache/cocoon/transformation/CIncludeTransformer.java Index: CIncludeTransformer.java =================================================================== RCS file: /home/cvs/cocoon-2.2/src/java/org/apache/cocoon/transformation/CIncludeTransformer.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- CIncludeTransformer.java 24 Sep 2003 21:41:12 -0000 1.6 +++ CIncludeTransformer.java 16 Oct 2003 15:00:37 -0000 1.7 @@ -112,14 +112,14 @@ * <!-- more can follow --> * </cinclude:parameters> * </cinclude:includexml> - * + * * * This transformer also supports caching of the included content. * Therefore it triggers for the element <code>cached-include</code> in the * namespace "http://apache.org/cocoon/include/1.0". * The <code>src</code> attribute contains the url which points to * an xml resource which is include instead of the element. - * First, it works like the usual include command. But it can be + * First, it works like the usual include command. But it can be * configured with various parameters: * The most important one is the <code>expires</code> parameter. * If (and only if) this is set to a value greater than zero, @@ -138,18 +138,18 @@ * in a series. * With the optional parameter <code>preemptive</code> set to <code>true</code> * a pre-emptive caching is activated. When a resource is requested with - * pre-emptive caching, this transformer always attempts to get the + * pre-emptive caching, this transformer always attempts to get the * content from the cache. If the content is not in the cache, it is * of course retrieved from the original source and cached. * If the cached resource has expired, it is still provided. The cache * is updated by a background task. This task has to be started * beforehand. - * + * * @author <a href="mailto:[EMAIL PROTECTED]">Carsten Ziegeler</a> * @author <a href="mailto:[EMAIL PROTECTED]">Andrew C. Oliver</a> * @version CVS $Id$ */ -public class CIncludeTransformer +public class CIncludeTransformer extends AbstractSAXTransformer implements Disposable, CacheableProcessingComponent { @@ -178,30 +178,30 @@ /** The configuration of includexml */ protected Parameters configurationParameters; - + /** The parameters for includexml */ protected SourceParameters resourceParameters; - + /** The current state: STATE_ */ protected int state; - + protected IncludeCacheManager cacheManager; protected IncludeCacheManagerSession cachingSession; protected boolean compiling; - + protected IncludeXMLConsumer filter; - + protected XMLSerializer recorder; - + protected AttributesImpl srcAttributes = new AttributesImpl(); - + protected boolean supportCaching; - + /** Remember the start time of the request for profiling */ protected long startTime; - + /** * Constructor * Set the namespace @@ -209,7 +209,7 @@ public CIncludeTransformer() { this.namespaceURI = CINCLUDE_NAMESPACE_URI; } - + /** * Setup the component. */ @@ -267,7 +267,7 @@ this.configurationParameters = null; this.resourceParameters = null; if (this.getLogger().isErrorEnabled()) { - this.getLogger().debug("Finishing CachingCIncludeTransformer, time: " + (System.currentTimeMillis() - this.startTime)); + this.getLogger().debug("Finishing CIncludeTransformer, time: " + (System.currentTimeMillis() - this.startTime)); this.startTime = 0; } this.filter = null; @@ -285,7 +285,7 @@ false); // Element: include - } else if (name.equals(CINCLUDE_INCLUDEXML_ELEMENT) + } else if (name.equals(CINCLUDE_INCLUDEXML_ELEMENT) && this.state == STATE_OUTSIDE) { this.state = STATE_INCLUDE; String ignoreErrors = attr.getValue("", CINCLUDE_INCLUDEXML_ELEMENT_IGNORE_ERRORS_ATTRIBUTE); @@ -300,26 +300,26 @@ this.ignoreWhitespaces = true; // target - } else if (name.equals(CINCLUDE_SRC_ELEMENT) + } else if (name.equals(CINCLUDE_SRC_ELEMENT) && this.state == STATE_INCLUDE) { this.startTextRecording(); // configparameters - } else if (name.equals(CINCLUDE_CONFIGURATION_ELEMENT) + } else if (name.equals(CINCLUDE_CONFIGURATION_ELEMENT) && this.state == STATE_INCLUDE) { stack.push("end"); // parameters - } else if (name.equals(CINCLUDE_PARAMETERS_ELEMENT) + } else if (name.equals(CINCLUDE_PARAMETERS_ELEMENT) && this.state == STATE_INCLUDE) { stack.push("end"); // parameter - } else if (name.equals(CINCLUDE_PARAMETER_ELEMENT) + } else if (name.equals(CINCLUDE_PARAMETER_ELEMENT) && this.state == STATE_INCLUDE) { // parameter name - } else if (name.equals(CINCLUDE_NAME_ELEMENT) + } else if (name.equals(CINCLUDE_NAME_ELEMENT) && this.state == STATE_INCLUDE) { this.startTextRecording(); @@ -338,18 +338,18 @@ this.cacheManager != null); if (this.compiling) { this.srcAttributes.addAttribute("", CINCLUDE_INCLUDE_ELEMENT_SRC_ATTRIBUTE, CINCLUDE_SRC_ELEMENT, "CDATA", src); - super.startTransformingElement(uri, - CINCLUDE_CACHED_INCLUDE_PLACEHOLDER_ELEMENT, - raw+"p", + super.startTransformingElement(uri, + CINCLUDE_CACHED_INCLUDE_PLACEHOLDER_ELEMENT, + raw+"p", this.srcAttributes); - this.srcAttributes.clear(); + this.srcAttributes.clear(); } } else { super.startTransformingElement(uri, name, raw, attr); } } - public void endTransformingElement(String uri, String name, String raw) + public void endTransformingElement(String uri, String name, String raw) throws ProcessingException, IOException, SAXException { if (name.equals(CINCLUDE_INCLUDE_ELEMENT)) { // do nothing @@ -358,7 +358,7 @@ // Element: includexml } else if (name.equals(CINCLUDE_INCLUDEXML_ELEMENT) && this.state == STATE_INCLUDE) { - + this.state = STATE_OUTSIDE; final String resource = (String)stack.pop(); @@ -372,13 +372,13 @@ + ", parameters=" + this.resourceParameters); } Source source = null; - + try { - source = SourceUtil.getSource(resource, - this.configurationParameters, + source = SourceUtil.getSource(resource, + this.configurationParameters, this.resourceParameters, this.resolver); - + XMLSerializer serializer = null; XMLDeserializer deserializer = null; try { @@ -397,7 +397,7 @@ } finally { this.manager.release( serializer ); this.manager.release( deserializer ); - } + } } catch (SourceException se) { if (!ignoreErrors) throw SourceUtil.handle(se); } catch (SAXException se) { @@ -415,7 +415,7 @@ // src element } else if (name.equals(CINCLUDE_SRC_ELEMENT) && this.state == STATE_INCLUDE) { - + this.stack.push(this.endTextRecording()); } else if (name.equals(CINCLUDE_PARAMETERS_ELEMENT) @@ -456,7 +456,7 @@ } else if (name.equals(CINCLUDE_PARAMETER_ELEMENT) == true && this.state == STATE_INCLUDE) { - + } else if (name.equals(CINCLUDE_NAME_ELEMENT) == true && this.state == STATE_INCLUDE) { stack.push(this.endTextRecording()); @@ -470,7 +470,7 @@ } else if (name.equals(CINCLUDE_CACHED_INCLUDE_ELEMENT)) { if (this.compiling) { - super.endTransformingElement(uri, + super.endTransformingElement(uri, CINCLUDE_CACHED_INCLUDE_PLACEHOLDER_ELEMENT, raw+"p"); } @@ -480,7 +480,7 @@ } } - protected String processCIncludeElement(String src, String element, + protected String processCIncludeElement(String src, String element, String select, String ns, String prefix, boolean cache) throws SAXException, IOException { @@ -510,7 +510,7 @@ } else { this.cacheManager.stream(src, this.cachingSession, this.filter); } - + return src; } @@ -532,10 +532,10 @@ if (!"".equals(select)) { - + DOMParser parser = null; XPathProcessor processor = null; - + try { parser = (DOMParser)this.manager.lookup(DOMParser.ROLE); processor = (XPathProcessor)this.manager.lookup(XPathProcessor.ROLE); @@ -547,7 +547,7 @@ int length = list.getLength(); for (int i=0; i<length; i++) { IncludeXMLConsumer.includeNode(list.item(i), - this, + this, this); } } finally { @@ -557,7 +557,7 @@ } else { String mimeType = null; if ( null != this.configurationParameters ) { - mimeType = this.configurationParameters.getParameter("mime-type", mimeType); + mimeType = this.configurationParameters.getParameter("mime-type", mimeType); } if ( this.compiling ) { SourceUtil.toSAX(source, mimeType, new IncludeXMLConsumer(this.contentHandler, this.lexicalHandler)); @@ -587,7 +587,7 @@ } return src; } - + /** * Start recording of compiled xml. * The incomming SAX events are recorded and a compiled representation @@ -602,9 +602,9 @@ try { this.recorder = (XMLSerializer)this.manager.lookup(XMLSerializer.ROLE); - + this.addRecorder(recorder); - + } catch (ComponentException ce) { throw new SAXException("Unable to lookup xml serializer for compiling xml.", ce); } @@ -639,7 +639,7 @@ this.filter = new MyFilter(this.xmlConsumer, this); super.startDocument(); } - + /** * @see org.xml.sax.ContentHandler#endDocument() */ @@ -664,8 +664,8 @@ * @see org.apache.cocoon.caching.CacheableProcessingComponent#getKey() */ public Serializable getKey() { - if (this.supportCaching - && null != this.cacheManager + if (this.supportCaching + && null != this.cacheManager && this.cachingSession.getExpires() > 0) { return "1"; } @@ -676,7 +676,7 @@ * @see org.apache.cocoon.caching.CacheableProcessingComponent#getValidity() */ public SourceValidity getValidity() { - if (this.supportCaching + if (this.supportCaching && null != this.cacheManager && this.cachingSession.getExpires() > 0 && !this.cachingSession.isPurging()) { @@ -684,13 +684,13 @@ } return null; } - + } final class MyFilter extends IncludeXMLConsumer { private CIncludeTransformer transformer; - + /** * This filter class post-processes the parallel fetching * @param consumer @@ -699,17 +699,17 @@ super(consumer); this.transformer = transformer; } - - + + public void endElement(String uri, String local, String qName) throws SAXException { - if (uri != null + if (uri != null && uri.equals(CIncludeTransformer.CINCLUDE_NAMESPACE_URI) && local.equals(CIncludeTransformer.CINCLUDE_CACHED_INCLUDE_PLACEHOLDER_ELEMENT)) { // this is the placeholder element: do nothing } else { super.endElement(uri, local, qName); - } + } } public void startElement(String uri, @@ -717,7 +717,7 @@ String qName, Attributes attr) throws SAXException { - if (uri != null + if (uri != null && uri.equals(CIncludeTransformer.CINCLUDE_NAMESPACE_URI) && local.equals(CIncludeTransformer.CINCLUDE_CACHED_INCLUDE_PLACEHOLDER_ELEMENT)) { // this is a placeholder @@ -729,7 +729,7 @@ } } else { super.startElement(uri, local, qName, attr); - } + } } }