cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@locus.apache.org
Subject cvs commit: xml-cocoon/src/org/apache/cocoon/transformation XalanTransformer.java
Date Wed, 01 Nov 2000 15:01:53 GMT
dims        00/11/01 07:01:48

  Modified:    src/org/apache/cocoon/transformation Tag: xml-cocoon2
                        XalanTransformer.java
  Log:
  patch from Carsten Ziegeler for XalanTransformer - this allows turning on/off
  the cache using a configuration in the sitemap
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.17  +25 -6     xml-cocoon/src/org/apache/cocoon/transformation/Attic/XalanTransformer.java
  
  Index: XalanTransformer.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/transformation/Attic/XalanTransformer.java,v
  retrieving revision 1.1.2.16
  retrieving revision 1.1.2.17
  diff -u -r1.1.2.16 -r1.1.2.17
  --- XalanTransformer.java	2000/10/19 20:21:22	1.1.2.16
  +++ XalanTransformer.java	2000/11/01 15:01:42	1.1.2.17
  @@ -18,6 +18,8 @@
   import org.apache.avalon.Component;
   import org.apache.avalon.ComponentManager;
   import org.apache.avalon.Composer;
  +import org.apache.avalon.Configurable;
  +import org.apache.avalon.Configuration;
   import org.apache.avalon.Poolable;
   import org.apache.avalon.Parameters;
   
  @@ -42,10 +44,11 @@
    *
    * @author <a href="mailto:fumagalli@exoffice.com">Pierpaolo Fumagalli</a>
    *         (Apache Software Foundation, Exoffice Technologies)
  - * @version CVS $Revision: 1.1.2.16 $ $Date: 2000/10/19 20:21:22 $
  + * @author <a href="mailto:dims@yahoo.com">Davanum Srinivas</a>
  + * @version CVS $Revision: 1.1.2.17 $ $Date: 2000/11/01 15:01:42 $
    */
   public class XalanTransformer extends ContentHandlerWrapper
  -implements Transformer, Composer, Poolable {
  +implements Transformer, Composer, Poolable, Configurable {
   
       /** The store service instance */
       private Store store = null;
  @@ -56,17 +59,33 @@
       /** Hash table for Templates */
       private static Hashtable templatesCache = new Hashtable();
   
  -    private static org.apache.trax.Transformer getTransformer(EntityResolver resolver,
String xsluri)
  +    /** Is the cache turned on? (default is on) */
  +    private boolean useCache = true;
  +
  +    private org.apache.trax.Transformer getTransformer(EntityResolver resolver, String
xsluri)
         throws SAXException, ProcessingException, IOException
       {
  -        Templates templates = (Templates)templatesCache.get(xsluri);
  +        Templates templates = null;
  +        if (this.useCache == true) templates = (Templates)templatesCache.get(xsluri);
           if(templates == null)
           {
       	    Processor processor = Processor.newInstance("xslt");
  -	    templates = processor.process(resolver.resolveEntity(null, xsluri));
  -            templatesCache.put(xsluri,templates);
  +	        templates = processor.process(resolver.resolveEntity(null, xsluri));
  +            if (this.useCache == true) templatesCache.put(xsluri,templates);
           }
           return templates.newTransformer();
  +    }
  +
  +    /**
  +     * Configure this transformer.
  +     */
  +    public void configure(Configuration conf) {
  +        if (conf != null) {
  +            Configuration child = conf.getChild("use-cache");
  +            if (child != null) {
  +                this.useCache = child.getValueAsBoolean(true);
  +            }
  +        }
       }
   
       /**
  
  
  

Mime
View raw message