cziegeler    02/01/14 08:18:56

  Modified:    src/java/org/apache/cocoon/components/parser JaxpParser.java
                        XercesParser.java
               src/java/org/apache/cocoon/components/xslt
                        XSLTProcessorImpl.java
  Log:
  Making usage of resolver 'more' optional
  
  Revision  Changes    Path
  1.3       +14 -7     
xml-cocoon2/src/java/org/apache/cocoon/components/parser/JaxpParser.java
  
  Index: JaxpParser.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/parser/JaxpParser.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- JaxpParser.java   10 Jan 2002 15:32:24 -0000      1.2
  +++ JaxpParser.java   14 Jan 2002 16:18:55 -0000      1.3
  @@ -8,6 +8,7 @@
   package org.apache.cocoon.components.parser;
   
   import org.apache.avalon.excalibur.pool.Poolable;
  +import org.apache.avalon.framework.activity.Disposable;
   import org.apache.avalon.framework.component.ComponentException;
   import org.apache.avalon.framework.component.ComponentManager;
   import org.apache.avalon.framework.component.Composable;
  @@ -58,10 +59,10 @@
    * @author <a href="mailto:[EMAIL PROTECTED]";>Berin Loritsch</a>
    * @author <a href="mailto:[EMAIL PROTECTED]";>Carsten Ziegeler</a>
    * @author <a href="mailto:[EMAIL PROTECTED]";>Sylvain Wallez</a>
  - * @version CVS $Revision: 1.2 $ $Date: 2002/01/10 15:32:24 $
  + * @version CVS $Revision: 1.3 $ $Date: 2002/01/14 16:18:55 $
    */
   public class JaxpParser extends AbstractXMLProducer
  -implements Parser, ErrorHandler, Composable, Parameterizable, Poolable {
  +implements Parser, ErrorHandler, Composable, Parameterizable, Disposable, Poolable {
   
       /** the SAX Parser factory */
       protected SAXParserFactory factory;
  @@ -94,13 +95,19 @@
        */
       public void compose(ComponentManager manager)
       throws ComponentException {
  -        try {
  -            this.manager = manager;
  +        this.manager = manager;
  +        if ( manager.hasComponent( Resolver.ROLE ) ) {
               getLogger().debug("Looking up " + Resolver.ROLE);
               this.resolver = (Resolver)manager.lookup(Resolver.ROLE);
  -        } catch(ComponentException e) {
  -            // This exception is ok during initialization/startup.
  -            getLogger().debug("JaxpParser: Could not yet find " + Resolver.ROLE);
  +        }
  +    }
  +
  +    /**
  +     * Dispose
  +     */
  +    public void dispose() {
  +        if (this.manager != null) {
  +            this.manager.release( this.resolver );
           }
       }
   
  
  
  
  1.2       +15 -8     
xml-cocoon2/src/java/org/apache/cocoon/components/parser/XercesParser.java
  
  Index: XercesParser.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/parser/XercesParser.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- XercesParser.java 3 Jan 2002 12:31:12 -0000       1.1
  +++ XercesParser.java 14 Jan 2002 16:18:55 -0000      1.2
  @@ -7,6 +7,7 @@
    *****************************************************************************/
   package org.apache.cocoon.components.parser;
   
  +import org.apache.avalon.framework.activity.Disposable;
   import org.apache.avalon.framework.component.ComponentException;
   import org.apache.avalon.framework.component.ComponentManager;
   import org.apache.avalon.framework.component.Composable;
  @@ -29,10 +30,10 @@
    *
    * @author <a href="mailto:[EMAIL PROTECTED]";>Pierpaolo Fumagalli</a>
    *         (Apache Software Foundation, Exoffice Technologies)
  - * @version CVS $Revision: 1.1 $ $Date: 2002/01/03 12:31:12 $
  + * @version CVS $Revision: 1.2 $ $Date: 2002/01/14 16:18:55 $
    */
   public class XercesParser extends AbstractXMLProducer
  -implements Parser, ErrorHandler, Composable, SingleThreaded {
  +implements Parser, ErrorHandler, Composable, Disposable, SingleThreaded {
   
       /** the SAX Parser */
       final SAXParser parser;
  @@ -55,14 +56,20 @@
        * Get the Entity Resolver from the component manager
        */
       public void compose(ComponentManager manager) throws ComponentException {
  -      try {
           this.manager = manager;
           getLogger().debug("Looking up " + Resolver.ROLE);
  -        this.resolver = (Resolver)manager.lookup(Resolver.ROLE);
  -      } catch(ComponentException e) {
  -             // This exception is ok during initialization/startup.
  -        getLogger().debug("XercesParser: Could not yet find " + Resolver.ROLE);
  -      }
  +        if ( manager.hasComponent( Resolver.ROLE ) ) {
  +            this.resolver = (Resolver)manager.lookup(Resolver.ROLE);
  +        }
  +    }
  +
  +    /**
  +     * Dispose
  +     */
  +    public void dispose() {
  +        if (this.manager != null) {
  +            this.manager.release( this.resolver );
  +        }
       }
   
       public void parse(InputSource in)
  
  
  
  1.3       +30 -20    
xml-cocoon2/src/java/org/apache/cocoon/components/xslt/XSLTProcessorImpl.java
  
  Index: XSLTProcessorImpl.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/xslt/XSLTProcessorImpl.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- XSLTProcessorImpl.java    3 Jan 2002 14:56:56 -0000       1.2
  +++ XSLTProcessorImpl.java    14 Jan 2002 16:18:56 -0000      1.3
  @@ -87,7 +87,7 @@
   
     /** The trax TransformerFactory */
     SAXTransformerFactory tfactory;
  -  
  +
     /** The factory class used to create tfactory */
     Class tfactoryClass;
   
  @@ -101,37 +101,47 @@
     /** the Entity Resolver */
     protected Resolver entityResolver;
   
  -  public void compose(ComponentManager manager)
  -    throws ComponentException
  -  {
  -    this.manager = manager;
  -    getLogger().debug("XSLTProcessorImpl component initialized.");
  -    store = (Store)manager.lookup(Store.ROLE);
  -    getLogger().debug("Looking up " + Resolver.ROLE);
  -    this.entityResolver = (Resolver)manager.lookup(Resolver.ROLE);
  -  }
  +    /**
  +     * Compose.
  +     * Try to get the store and the entity resolver (optional)
  +     */
  +    public void compose(ComponentManager manager)
  +    throws ComponentException {
  +        this.manager = manager;
  +        getLogger().debug("XSLTProcessorImpl component initialized.");
  +        store = (Store)manager.lookup(Store.ROLE);
  +        if ( manager.hasComponent( Resolver.ROLE ) ) {
  +            getLogger().debug("Looking up " + Resolver.ROLE);
  +            this.entityResolver = (Resolver)manager.lookup(Resolver.ROLE);
  +        }
  +    }
   
  -  public void dispose()
  -  {
  -    if (this.manager != null) {
  -      this.manager.release((Component)store);
  -      this.manager.release((Component)entityResolver);
  +    /**
  +     * Dispose
  +     */
  +    public void dispose() {
  +        if (this.manager != null) {
  +            this.manager.release((Component)store);
  +            this.manager.release((Component)entityResolver);
  +        }
       }
  -  }
   
  +    /**
  +     * Configure the component
  +     */
     public void configure(Configuration conf)
       throws ConfigurationException
     {
       Parameters params = Parameters.fromConfiguration(conf);
       useStore = params.getParameterAsBoolean("use-store", true);
       incrementalProcessing = params.getParameterAsBoolean("incremental-processing", 
false);
  -    
  +
       String factoryName = params.getParameter("transformer-factory", null);
  -    
  +
       if (factoryName == null) {
         // Will use default TRAX mechanism
         this.tfactoryClass = null;
  -      
  +
       } else {
         // Will use specific class
         getLogger().debug("Using factory " + factoryName);
  @@ -140,7 +150,7 @@
         } catch(ClassNotFoundException cnfe) {
           throw new ConfigurationException("Cannot load TransformerFactory class", 
cnfe);
         }
  -    
  +
         if (! TransformerFactory.class.isAssignableFrom(tfactoryClass)) {
           throw new ConfigurationException("Class " + factoryName + " isn't a 
TransformerFactory");
         }
  
  
  

----------------------------------------------------------------------
In case of troubles, e-mail:     [EMAIL PROTECTED]
To unsubscribe, e-mail:          [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to