camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ningji...@apache.org
Subject svn commit: r734340 - /activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/component/xslt/XsltComponent.java
Date Wed, 14 Jan 2009 06:01:44 GMT
Author: ningjiang
Date: Tue Jan 13 22:01:43 2009
New Revision: 734340

URL: http://svn.apache.org/viewvc?rev=734340&view=rev
Log:
CAMEL-1253 added support to set the TransformerFactory for the camel-xslt endponint

Modified:
    activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/component/xslt/XsltComponent.java

Modified: activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/component/xslt/XsltComponent.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/component/xslt/XsltComponent.java?rev=734340&r1=734339&r2=734340&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/component/xslt/XsltComponent.java
(original)
+++ activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/component/xslt/XsltComponent.java
Tue Jan 13 22:01:43 2009
@@ -18,11 +18,14 @@
 
 import java.util.Map;
 
+import javax.xml.transform.TransformerFactory;
+
 import org.apache.camel.Endpoint;
 import org.apache.camel.builder.xml.XsltBuilder;
 import org.apache.camel.component.ResourceBasedComponent;
 import org.apache.camel.converter.jaxp.XmlConverter;
 import org.apache.camel.impl.ProcessorEndpoint;
+import org.apache.camel.util.ObjectHelper;
 import org.springframework.core.io.Resource;
 
 /**
@@ -51,7 +54,7 @@
 
         // lets allow the converter to be configured
         XmlConverter converter = null;
-        String converterName = getAndRemoveParameter(parameters, "converter", String.class);
+        String converterName = getAndRemoveParameter(parameters, "converter", String.class);
       
         if (converterName != null) {
             converter = mandatoryLookup(converterName, XmlConverter.class);
         }
@@ -61,7 +64,26 @@
         if (converter != null) {
             xslt.setConverter(converter);
         }
-
+        
+        String transformerFactoryClassName = getAndRemoveParameter(parameters, "transformerFactoryClass",
String.class);
+        TransformerFactory factory = null;
+        if (transformerFactoryClassName != null) {
+            Class factoryClass = ObjectHelper.loadClass(transformerFactoryClassName);
+            if (factoryClass != null) {
+                factory = (TransformerFactory) newInstance(factoryClass);
+            } else {
+                log.warn("Can't find the TransformerFactoryClass with the class name " +
transformerFactoryClassName);
+            }
+        }
+        
+        String transformerFactoryName = getAndRemoveParameter(parameters, "transformerFactory",
String.class);        
+        if (transformerFactoryName != null) {
+            factory = mandatoryLookup(transformerFactoryName, TransformerFactory.class);
+        }
+        
+        if (factory != null) {
+            xslt.getConverter().setTransformerFactory(factory);
+        }
         xslt.setTransformerInputStream(resource.getInputStream());
         configureXslt(xslt, uri, remaining, parameters);
         return new ProcessorEndpoint(uri, this, xslt);



Mime
View raw message