dims 01/04/17 08:33:35
Modified: src/org/apache/cocoon/caching Tag: xml-cocoon2
CachingOutputStream.java
src/org/apache/cocoon/components/pipeline Tag: xml-cocoon2
CachingStreamPipeline.java
src/org/apache/cocoon/generation Tag: xml-cocoon2
FragmentExtractorGenerator.java
VelocityGenerator.java
src/org/apache/cocoon/serialization Tag: xml-cocoon2
AbstractTextSerializer.java HTMLSerializer.java
src/org/apache/cocoon/transformation Tag: xml-cocoon2
FragmentExtractorTransformer.java
Log:
- HTML/Text/XML Serializers are now Cacheable
- FragmentExtractorGenerator/FragmentExtractorTransformer is now Cacheable
- Minor fix to CacheOutputStream added another member function.
Revision Changes Path
No revision
No revision
1.1.2.2 +6 -1
xml-cocoon/src/org/apache/cocoon/caching/Attic/CachingOutputStream.java
Index: CachingOutputStream.java
===================================================================
RCS file:
/home/cvs/xml-cocoon/src/org/apache/cocoon/caching/Attic/CachingOutputStream.java,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -u -r1.1.2.1 -r1.1.2.2
--- CachingOutputStream.java 2001/04/17 10:32:52 1.1.2.1
+++ CachingOutputStream.java 2001/04/17 15:32:56 1.1.2.2
@@ -17,7 +17,7 @@
* TeeOutputStream.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Carsten Ziegeler</a>
- * @version CVS $Revision: 1.1.2.1 $ $Date: 2001/04/17 10:32:52 $
+ * @version CVS $Revision: 1.1.2.2 $ $Date: 2001/04/17 15:32:56 $
*/
public final class CachingOutputStream
@@ -36,6 +36,11 @@
}
public void write(int b) throws IOException {
+ this.receiver.write(b);
+ this.baOutputStream.write(b);
+ }
+
+ public void write( byte b[] ) throws IOException {
this.receiver.write(b);
this.baOutputStream.write(b);
}
No revision
No revision
1.1.2.2 +8 -8
xml-cocoon/src/org/apache/cocoon/components/pipeline/Attic/CachingStreamPipeline.java
Index: CachingStreamPipeline.java
===================================================================
RCS file:
/home/cvs/xml-cocoon/src/org/apache/cocoon/components/pipeline/Attic/CachingStreamPipeline.java,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -u -r1.1.2.1 -r1.1.2.2
--- CachingStreamPipeline.java 2001/04/17 10:33:14 1.1.2.1
+++ CachingStreamPipeline.java 2001/04/17 15:33:02 1.1.2.2
@@ -43,7 +43,7 @@
* </ul>
*
* @author <a href="mailto:[EMAIL PROTECTED]">Carsten Ziegeler</a>
- * @version CVS $Revision: 1.1.2.1 $ $Date: 2001/04/17 10:33:14 $
+ * @version CVS $Revision: 1.1.2.2 $ $Date: 2001/04/17 15:33:02 $
*/
public final class CachingStreamPipeline extends AbstractStreamPipeline {
@@ -98,10 +98,10 @@
this.connectPipeline();
// test if serializer and event pipeline are cacheable
- long serializerKey;
- PipelineCacheKey eventPipelineKey;
- CacheValidity serializerValidity;
- Map eventPipelineValidity;
+ long serializerKey = 0;
+ PipelineCacheKey eventPipelineKey = null;
+ CacheValidity serializerValidity = null;
+ Map eventPipelineValidity = null;
if (this.serializer instanceof Cacheable
&& this.eventPipeline instanceof CacheableEventPipeline
&& (serializerKey =
((Cacheable)this.serializer).generateKey()) != 0
@@ -141,20 +141,20 @@
} else {
getLogger().debug("Cached content is invalid.");
+
// remove invalid cached object
this.streamCache.remove(pcKey);
cachedObject = null;
}
}
if (cachedObject == null) {
-
getLogger().debug("Caching content for further
requests.");
outputStream = new CachingOutputStream(outputStream);
}
}
-
if (usedCache == false) {
+
// set the output stream
this.serializer.setOutputStream(outputStream);
@@ -186,7 +186,7 @@
getLogger().debug("Recycling of CachingStreamPipeline");
super.recycle();
- this.serializerRole = null;
+ //this.serializerRole = null;
}
}
No revision
No revision
1.1.2.11 +30 -7
xml-cocoon/src/org/apache/cocoon/generation/Attic/FragmentExtractorGenerator.java
Index: FragmentExtractorGenerator.java
===================================================================
RCS file:
/home/cvs/xml-cocoon/src/org/apache/cocoon/generation/Attic/FragmentExtractorGenerator.java,v
retrieving revision 1.1.2.10
retrieving revision 1.1.2.11
diff -u -r1.1.2.10 -r1.1.2.11
--- FragmentExtractorGenerator.java 2001/03/19 21:20:33 1.1.2.10
+++ FragmentExtractorGenerator.java 2001/04/17 15:33:08 1.1.2.11
@@ -7,12 +7,16 @@
*****************************************************************************/
package org.apache.cocoon.generation;
+import org.apache.cocoon.caching.Cacheable;
+import org.apache.cocoon.caching.CacheValidity;
+import org.apache.cocoon.caching.NOPCacheValidity;
import org.apache.cocoon.ResourceNotFoundException;
import org.apache.cocoon.ProcessingException;
import org.apache.cocoon.generation.AbstractGenerator;
import org.apache.cocoon.xml.dom.DOMStreamer;
import org.apache.cocoon.environment.AbstractEnvironment;
import org.apache.cocoon.Constants;
+import org.apache.cocoon.util.HashUtil;
import org.apache.avalon.configuration.Parameters;
import org.apache.avalon.Poolable;
@@ -37,9 +41,10 @@
* This is by no means complete yet, but it should prove useful, particularly
* for offline generation.
* @author <a href="mailto:[EMAIL PROTECTED]">Paul Russell</a>
- * @version CVS $Revision: 1.1.2.10 $ $Date: 2001/03/19 21:20:33 $
+ * @version CVS $Revision: 1.1.2.11 $ $Date: 2001/04/17 15:33:08 $
*/
-public class FragmentExtractorGenerator extends AbstractGenerator implements
Poolable {
+public class FragmentExtractorGenerator extends AbstractGenerator
+ implements Poolable, Cacheable {
/** The fragment store. */
private static Map fragmentStore = new HashMap();
@@ -64,12 +69,26 @@
String view = env.getView();
if(view != null && view.equals(Constants.LINK_VIEW))
cleanupStore = false;
+ }
- synchronized (FragmentExtractorGenerator.fragmentStore) {
- if ( FragmentExtractorGenerator.fragmentStore.get(source) ==
null ) {
- throw new ResourceNotFoundException("Could not find fragment
" + source + ".");
- }
- }
+ /**
+ * Generate the unique key.
+ * This key must be unique inside the space of this component.
+ *
+ * @return The generated key hashes the src
+ */
+ public long generateKey() {
+ return HashUtil.hash(source);
+ }
+
+ /**
+ * Generate the validity object.
+ *
+ * @return The generated validity object or <code>null</code> if the
+ * component is currently not cacheable.
+ */
+ public CacheValidity generateValidity() {
+ return new NOPCacheValidity();
}
public void generate() throws SAXException {
@@ -78,6 +97,10 @@
synchronized (FragmentExtractorGenerator.fragmentStore) {
Document doc = (Document)
FragmentExtractorGenerator.fragmentStore.get(source);
+
+ if(doc == null)
+ throw new SAXException("Could not find fragment " + source +
".");
+
DOMStreamer streamer = new
DOMStreamer(this.contentHandler,this.lexicalHandler);
streamer.stream(doc);
1.1.2.3 +1 -5
xml-cocoon/src/org/apache/cocoon/generation/Attic/VelocityGenerator.java
Index: VelocityGenerator.java
===================================================================
RCS file:
/home/cvs/xml-cocoon/src/org/apache/cocoon/generation/Attic/VelocityGenerator.java,v
retrieving revision 1.1.2.2
retrieving revision 1.1.2.3
diff -u -r1.1.2.2 -r1.1.2.3
--- VelocityGenerator.java 2001/04/12 12:30:34 1.1.2.2
+++ VelocityGenerator.java 2001/04/17 15:33:12 1.1.2.3
@@ -28,7 +28,7 @@
/**
* @author <a href="mailto:[EMAIL PROTECTED]">Davanum Srinivas</a>
- * @version CVS $Revision: 1.1.2.2 $ $Date: 2001/04/12 12:30:34 $
+ * @version CVS $Revision: 1.1.2.3 $ $Date: 2001/04/17 15:33:12 $
*/
public class VelocityGenerator extends ServletGenerator implements Poolable {
@@ -77,19 +77,15 @@
parser.setLexicalHandler(this.lexicalHandler);
parser.parse(xmlInput);
} catch (IOException e){
- e.printStackTrace();
getLogger().warn("VelocityGenerator.generate()", e);
throw new ResourceNotFoundException("Could not get Resource for
VelocityGenerator", e);
} catch (SAXException e){
- e.printStackTrace();
getLogger().error("VelocityGenerator.generate()", e);
throw(e);
} catch (org.apache.avalon.ComponentManagerException e){
- e.printStackTrace();
getLogger().error("Could not get parser", e);
throw new ProcessingException("Exception in
VelocityGenerator.generate()",e);
} catch (Exception e){
- e.printStackTrace();
getLogger().error("Could not get parser", e);
throw new ProcessingException("Exception in
VelocityGenerator.generate()",e);
} finally {
No revision
No revision
1.1.2.11 +30 -2
xml-cocoon/src/org/apache/cocoon/serialization/Attic/AbstractTextSerializer.java
Index: AbstractTextSerializer.java
===================================================================
RCS file:
/home/cvs/xml-cocoon/src/org/apache/cocoon/serialization/Attic/AbstractTextSerializer.java,v
retrieving revision 1.1.2.10
retrieving revision 1.1.2.11
diff -u -r1.1.2.10 -r1.1.2.11
--- AbstractTextSerializer.java 2001/04/05 15:03:26 1.1.2.10
+++ AbstractTextSerializer.java 2001/04/17 15:33:18 1.1.2.11
@@ -14,6 +14,10 @@
import org.apache.avalon.configuration.Configuration;
import org.apache.avalon.configuration.ConfigurationException;
+import org.apache.cocoon.caching.Cacheable;
+import org.apache.cocoon.caching.CacheValidity;
+import org.apache.cocoon.caching.NOPCacheValidity;
+
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.OutputKeys;
import javax.xml.transform.sax.SAXTransformerFactory;
@@ -22,9 +26,9 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Pierpaolo Fumagalli</a>
* (Apache Software Foundation, Exoffice Technologies)
* @author <a href="mailto:[EMAIL PROTECTED]">Stefano Mazzocchi</a>
- * @version CVS $Revision: 1.1.2.10 $ $Date: 2001/04/05 15:03:26 $
+ * @version CVS $Revision: 1.1.2.11 $ $Date: 2001/04/17 15:33:18 $
*/
-public abstract class AbstractTextSerializer extends AbstractSerializer
implements Configurable {
+public abstract class AbstractTextSerializer extends AbstractSerializer
implements Configurable, Cacheable {
/**
* The trax <code>TransformerFactory</code> used by this serializer.
@@ -83,6 +87,30 @@
if (! version.getLocation().equals("-")) {
format.put(OutputKeys.VERSION,version.getValue());
}
+ }
+
+ /**
+ * Generate the unique key.
+ * This key must be unique inside the space of this component.
+ * This method must be invoked before the generateValidity() method.
+ *
+ * @return The generated key or <code>0</code> if the component
+ * is currently not cacheable.
+ */
+ public long generateKey() {
+ return 1;
+ }
+
+ /**
+ * Generate the validity object.
+ * Before this method can be invoked the generateKey() method
+ * must be invoked.
+ *
+ * @return The generated validity object or <code>null</code> if the
+ * component is currently not cacheable.
+ */
+ public CacheValidity generateValidity() {
+ return new NOPCacheValidity();
}
/**
1.1.2.18 +1 -2
xml-cocoon/src/org/apache/cocoon/serialization/Attic/HTMLSerializer.java
Index: HTMLSerializer.java
===================================================================
RCS file:
/home/cvs/xml-cocoon/src/org/apache/cocoon/serialization/Attic/HTMLSerializer.java,v
retrieving revision 1.1.2.17
retrieving revision 1.1.2.18
diff -u -r1.1.2.17 -r1.1.2.18
--- HTMLSerializer.java 2001/03/12 10:57:21 1.1.2.17
+++ HTMLSerializer.java 2001/04/17 15:33:20 1.1.2.18
@@ -20,7 +20,7 @@
/**
* @author <a href="mailto:[EMAIL PROTECTED]">Stefano Mazzocchi</a>
- * @version CVS $Revision: 1.1.2.17 $ $Date: 2001/03/12 10:57:21 $
+ * @version CVS $Revision: 1.1.2.18 $ $Date: 2001/04/17 15:33:20 $
*/
public class HTMLSerializer extends AbstractTextSerializer implements
Poolable {
@@ -52,5 +52,4 @@
super.recycle();
this.handler = null;
}
-
}
No revision
No revision
1.1.2.8 +27 -2
xml-cocoon/src/org/apache/cocoon/transformation/Attic/FragmentExtractorTransformer.java
Index: FragmentExtractorTransformer.java
===================================================================
RCS file:
/home/cvs/xml-cocoon/src/org/apache/cocoon/transformation/Attic/FragmentExtractorTransformer.java,v
retrieving revision 1.1.2.7
retrieving revision 1.1.2.8
diff -u -r1.1.2.7 -r1.1.2.8
--- FragmentExtractorTransformer.java 2001/04/13 16:02:26 1.1.2.7
+++ FragmentExtractorTransformer.java 2001/04/17 15:33:29 1.1.2.8
@@ -7,9 +7,13 @@
*****************************************************************************/
package org.apache.cocoon.transformation;
+import org.apache.cocoon.caching.Cacheable;
+import org.apache.cocoon.caching.CacheValidity;
+import org.apache.cocoon.caching.NOPCacheValidity;
import org.apache.cocoon.xml.dom.DOMBuilder;
import org.apache.cocoon.xml.dom.DOMFactory;
import org.apache.cocoon.Roles;
+import org.apache.cocoon.util.HashUtil;
import org.apache.cocoon.transformation.AbstractTransformer;
import org.apache.cocoon.generation.FragmentExtractorGenerator;
import org.apache.cocoon.ProcessingException;
@@ -41,9 +45,10 @@
* <a href="http://c2.com/cgi/wiki?YouArentGonnaNeedIt">you aren't gonna
need it</a>,
* so I've just used very simple extraction based on a URI and local name.
* @author <a href="mailto:[EMAIL PROTECTED]">Paul Russell</a>
- * @version CVS $Revision: 1.1.2.7 $ $Date: 2001/04/13 16:02:26 $
+ * @version CVS $Revision: 1.1.2.8 $ $Date: 2001/04/17 15:33:29 $
*/
-public class FragmentExtractorTransformer extends AbstractTransformer
implements Composer, Disposable {
+public class FragmentExtractorTransformer extends AbstractTransformer
+ implements Composer, Disposable, Cacheable {
private static String EXTRACT_URI="http://www.w3.org/2000/svg";
private static String EXTRACT_ELEMENT="svg";
@@ -77,6 +82,26 @@
extractLevel = 0;
imageID = 0;
prefixMap = new HashMap();
+ }
+
+ /**
+ * Generate the unique key.
+ * This key must be unique inside the space of this component.
+ *
+ * @return The generated key hashes the src
+ */
+ public long generateKey() {
+ return 1;
+ }
+
+ /**
+ * Generate the validity object.
+ *
+ * @return The generated validity object or <code>null</code> if the
+ * component is currently not cacheable.
+ */
+ public CacheValidity generateValidity() {
+ return new NOPCacheValidity();
}
/**
----------------------------------------------------------------------
In case of troubles, e-mail: [EMAIL PROTECTED]
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]