cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From coli...@apache.org
Subject cvs commit: cocoon-2.1/src/java/org/apache/cocoon/generation JXTemplateGenerator.java
Date Thu, 01 Apr 2004 16:50:32 GMT
coliver     2004/04/01 08:50:32

  Modified:    src/java/org/apache/cocoon/generation
                        JXTemplateGenerator.java
  Log:
  Set up service manager on generator when called from transformer
  
  Revision  Changes    Path
  1.39      +41 -10    cocoon-2.1/src/java/org/apache/cocoon/generation/JXTemplateGenerator.java
  
  Index: JXTemplateGenerator.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/java/org/apache/cocoon/generation/JXTemplateGenerator.java,v
  retrieving revision 1.38
  retrieving revision 1.39
  diff -u -r1.38 -r1.39
  --- JXTemplateGenerator.java	5 Mar 2004 13:02:55 -0000	1.38
  +++ JXTemplateGenerator.java	1 Apr 2004 16:50:32 -0000	1.39
  @@ -40,6 +40,8 @@
   import java.util.TimeZone;
   
   import org.apache.avalon.framework.parameters.Parameters;
  +import org.apache.avalon.framework.service.ServiceManager;
  +import org.apache.avalon.framework.service.ServiceException;
   import org.apache.cocoon.ProcessingException;
   import org.apache.cocoon.components.flow.FlowHelper;
   import org.apache.cocoon.components.flow.WebContinuation;
  @@ -48,7 +50,7 @@
   import org.apache.cocoon.environment.ObjectModelHelper;
   import org.apache.cocoon.environment.Request;
   import org.apache.cocoon.environment.SourceResolver;
  -import org.apache.cocoon.transformation.AbstractTransformer;
  +import org.apache.cocoon.transformation.ServiceableTransformer;
   import org.apache.cocoon.xml.XMLConsumer;
   import org.apache.cocoon.xml.IncludeXMLConsumer;
   import org.apache.cocoon.xml.dom.DOMBuilder;
  @@ -2248,6 +2250,16 @@
               return this.startEvent;
           }
   
  +
  +        void recycle() {
  +            startEvent = null;
  +            lastEvent = null;
  +            stack.clear();
  +            locator = null;
  +            charLocation = null;
  +            charBuf = null;
  +        }
  +
           private void addEvent(Event ev) throws SAXException {
               if (ev == null) {
                   throw new NullPointerException("null event");
  @@ -2680,16 +2692,24 @@
        * you effectively recompile the template for every instance document)
        */
   
  -    public static class TransformerAdapter extends AbstractTransformer {
  +    public static class TransformerAdapter extends ServiceableTransformer {
           static class TemplateConsumer extends Parser implements XMLConsumer {
   
  -            public TemplateConsumer(SourceResolver resolver, Map objectModel,
  -                                    String src, Parameters parameters)
  -                throws ProcessingException, SAXException, IOException {
  +            public TemplateConsumer() {
                   this.gen = new JXTemplateGenerator();
  +            }
  +
  +            public void setup(SourceResolver resolver, Map objectModel,
  +                              String src, Parameters parameters) 
  +                throws ProcessingException, SAXException, IOException {
                   this.gen.setup(resolver, objectModel, null, parameters);
               }
   
  +            public void service(ServiceManager manager) 
  +                throws ServiceException {
  +                this.gen.service(manager);
  +            }
  +
               public void endDocument() throws SAXException {
                   super.endDocument();
                   gen.performGeneration(gen.getConsumer(), gen.getJexlContext(),
  @@ -2700,21 +2720,32 @@
                   gen.setConsumer(consumer);
               }
   
  +            void recycle() {
  +                super.recycle();
  +                gen.recycle();
  +            }
  +
               JXTemplateGenerator gen;
           }
   
  -        TemplateConsumer templateConsumer;
  +        TemplateConsumer templateConsumer = new TemplateConsumer();
   
           public void recycle() {
               super.recycle();
  -            templateConsumer = null;
  +            templateConsumer.recycle();
           }
   
           public void setup(SourceResolver resolver, Map objectModel,
                             String src, Parameters parameters)
               throws ProcessingException, SAXException, IOException {
  -            templateConsumer = new TemplateConsumer(resolver, objectModel,
  -                                                    src, parameters);
  +            super.setup(resolver, objectModel, src, parameters);
  +            templateConsumer.setup(resolver, objectModel, src, parameters);
  +        }
  +
  +        public void service(ServiceManager manager) 
  +            throws ServiceException {
  +            super.service(manager);
  +            templateConsumer.service(manager);
           }
   
           public void setConsumer(XMLConsumer xmlConsumer) {
  
  
  

Mime
View raw message