cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sylv...@apache.org
Subject cvs commit: cocoon-2.1/src/java/org/apache/cocoon/serialization AbstractTextSerializer.java
Date Wed, 19 Mar 2003 17:37:12 GMT
sylvain     2003/03/19 09:37:12

  Modified:    src/java/org/apache/cocoon/serialization
                        AbstractTextSerializer.java
  Log:
  Allow the TransformerFactory class to be specified in the configuration
  
  Revision  Changes    Path
  1.3       +20 -5     cocoon-2.1/src/java/org/apache/cocoon/serialization/AbstractTextSerializer.java
  
  Index: AbstractTextSerializer.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/java/org/apache/cocoon/serialization/AbstractTextSerializer.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- AbstractTextSerializer.java	19 Mar 2003 15:42:16 -0000	1.2
  +++ AbstractTextSerializer.java	19 Mar 2003 17:37:12 -0000	1.3
  @@ -55,6 +55,7 @@
   import org.apache.avalon.framework.configuration.ConfigurationException;
   import org.apache.cocoon.Constants;
   import org.apache.cocoon.caching.CacheableProcessingComponent;
  +import org.apache.cocoon.util.ClassUtils;
   import org.apache.cocoon.util.TraxErrorHandler;
   import org.apache.cocoon.xml.AbstractXMLPipe;
   import org.apache.cocoon.xml.XMLConsumer;
  @@ -162,10 +163,6 @@
        */
       protected SAXTransformerFactory getTransformerFactory()
       {
  -        if(tfactory == null)  {
  -            tfactory = (SAXTransformerFactory) TransformerFactory.newInstance();
  -            tfactory.setErrorListener(new TraxErrorHandler(getLogger()));
  -        }
           return tfactory;
       }
   
  @@ -250,6 +247,24 @@
           if (! version.getLocation().equals("-")) {
               format.put(OutputKeys.VERSION,version.getValue());
           }
  +
  +        Configuration tFactoryConf = conf.getChild("transformer-factory", false);
  +        if (tFactoryConf != null) {
  +            String tFactoryClass = tFactoryConf.getValue();
  +            try {
  +            	this.tfactory = (SAXTransformerFactory)ClassUtils.newInstance(tFactoryClass);
  +            	if (getLogger().isDebugEnabled()) {
  +            	   getLogger().debug("Using transformer factory " + tFactoryClass);
  +            	}
  +            } catch(Exception e) {
  +            	throw new ConfigurationException("Cannot load transformer factory " + tFactoryClass,
e);
  +            }
  +        } else {
  +           // Standard TrAX behaviour
  +           this.tfactory = (SAXTransformerFactory)TransformerFactory.newInstance();
  +        }
  +        
  +        tfactory.setErrorListener(new TraxErrorHandler(getLogger()));
   
           // Check if we need namespace as attributes.
           try {
  
  
  

Mime
View raw message