Author: hadrian
Date: Wed Aug  6 10:09:14 2008
New Revision: 683331

URL: http://svn.apache.org/viewvc?rev=683331&view=rev
Log:
CAMEL-769.  Patch applied with thanks!

Modified:
    
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/converter/jaxp/XmlConverter.java
    
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/language/ExpressionType.java
    
activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/Main.java
    
activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/handler/CamelNamespaceHandler.java
    
activemq/camel/trunk/tooling/maven/camel-maven-plugin/src/main/java/org/apache/camel/maven/RunMojo.java

Modified: 
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/converter/jaxp/XmlConverter.java
URL: 
http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/converter/jaxp/XmlConverter.java?rev=683331&r1=683330&r2=683331&view=diff
==============================================================================
--- 
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/converter/jaxp/XmlConverter.java
 (original)
+++ 
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/converter/jaxp/XmlConverter.java
 Wed Aug  6 10:09:14 2008
@@ -26,6 +26,7 @@
 import java.io.StringWriter;
 import java.lang.reflect.Constructor;
 import java.nio.ByteBuffer;
+import java.util.Properties;
 
 import javax.xml.parsers.DocumentBuilder;
 import javax.xml.parsers.DocumentBuilderFactory;
@@ -97,21 +98,38 @@
     }
 
     /**
+     * Returns the default set of output properties for conversions.
+     */
+    public Properties defaultOutputProperties() {
+        Properties properties = new Properties();
+        properties.put(OutputKeys.ENCODING, defaultCharset);
+        properties.put(OutputKeys.OMIT_XML_DECLARATION, "yes");
+        return properties;
+    }
+
+    /**
      * Converts the given input Source into the required result
      */
     public void toResult(Source source, Result result) throws 
TransformerException {
+        toResult(source, result, defaultOutputProperties());
+    }   
+    
+    /**
+     * Converts the given input Source into the required result
+     */
+    public void toResult(Source source, Result result, Properties 
outputProperties) throws TransformerException {
         if (source == null) {
             return;
         }
+        
         Transformer transformer = createTransfomer();
         if (transformer == null) {
             throw new TransformerException("Could not create a transformer - 
JAXP is misconfigured!");
         }
-        transformer.setOutputProperty(OutputKeys.ENCODING, defaultCharset);
-        transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
+        transformer.setOutputProperties(outputProperties);
         transformer.transform(source, result);
-    }
-
+    } 
+    
     /**
      * Converts the given byte[] to a Source
      */

Modified: 
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/language/ExpressionType.java
URL: 
http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/language/ExpressionType.java?rev=683331&r1=683330&r2=683331&view=diff
==============================================================================
--- 
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/language/ExpressionType.java
 (original)
+++ 
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/language/ExpressionType.java
 Wed Aug  6 10:09:14 2008
@@ -22,6 +22,7 @@
 import javax.xml.bind.annotation.XmlAccessorType;
 import javax.xml.bind.annotation.XmlAttribute;
 import javax.xml.bind.annotation.XmlID;
+import javax.xml.bind.annotation.XmlRootElement;
 import javax.xml.bind.annotation.XmlTransient;
 import javax.xml.bind.annotation.XmlType;
 import javax.xml.bind.annotation.XmlValue;
@@ -45,6 +46,7 @@
  *
  * @version $Revision$
  */
[EMAIL PROTECTED]
 @XmlType(name = "expressionType")
 @XmlAccessorType(XmlAccessType.FIELD)
 public class ExpressionType implements Expression<Exchange>, 
Predicate<Exchange> {

Modified: 
activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/Main.java
URL: 
http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/Main.java?rev=683331&r1=683330&r2=683331&view=diff
==============================================================================
--- 
activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/Main.java
 (original)
+++ 
activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/Main.java
 Wed Aug  6 10:09:14 2008
@@ -33,6 +33,7 @@
 import org.apache.camel.impl.ServiceSupport;
 import org.apache.camel.model.RouteType;
 import org.apache.camel.processor.interceptor.Debugger;
+import org.apache.camel.spring.handler.ModelFileGenerator;
 import org.apache.camel.util.ObjectHelper;
 import org.apache.camel.view.RouteDotGenerator;
 import org.apache.commons.logging.Log;
@@ -61,6 +62,7 @@
     private long duration = -1;
     private TimeUnit timeUnit = TimeUnit.MILLISECONDS;
     private String dotOutputDir;
+    private String routesOutputFile;
     private boolean aggregateDot;
     private boolean debug;
     private boolean trace;
@@ -129,6 +131,12 @@
                 enableTrace();
             }
         });
+        addOption(new ParameterOption("out", "output", "Output all routes to 
the specified XML file", "filename") {
+            protected void doProcess(String arg, String parameter,
+                    LinkedList<String> remainingArgs) {
+                setRoutesOutputFile(parameter);
+            }
+        });
     }
 
     public static void main(String... args) {
@@ -195,7 +203,7 @@
     }
 
     /**
-     * Parses the commandl ine arguments
+     * Parses the command line arguments
      */
     public void parseArguments(String[] arguments) {
         LinkedList<String> args = new 
LinkedList<String>(Arrays.asList(arguments));
@@ -409,6 +417,14 @@
         
setParentApplicationContextUri("/META-INF/services/org/apache/camel/spring/trace.xml");
     }
 
+    public void setRoutesOutputFile(String routesOutputFile) {
+        this.routesOutputFile = routesOutputFile;         
+    }
+    
+    public String getRoutesOutputFile() {
+        return routesOutputFile;         
+    }    
+    
     /**
      * Returns the currently active debugger if one is enabled
      *
@@ -530,6 +546,18 @@
         if (isAggregateDot()) {
             generateDot("aggregate", 
aggregateSpringCamelContext(applicationContext), 1);
         }
+        
+        if (!"".equals(getRoutesOutputFile())) {
+            outputRoutesToFile();
+        }
+    }
+
+    private void outputRoutesToFile() throws IOException {
+        if (ObjectHelper.isNotNullAndNonEmpty(getRoutesOutputFile())) {
+            LOG.info("Generating routes as XML in the file named: " + 
getRoutesOutputFile());
+            ModelFileGenerator generator = new ModelFileGenerator();
+            generator.marshalRoutesUsingJaxb(getRoutesOutputFile(), 
getRouteDefinitions());
+        }
     }
 
     protected void generateDot(String name, SpringCamelContext camelContext, 
int size) throws IOException {

Modified: 
activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/handler/CamelNamespaceHandler.java
URL: 
http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/handler/CamelNamespaceHandler.java?rev=683331&r1=683330&r2=683331&view=diff
==============================================================================
--- 
activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/handler/CamelNamespaceHandler.java
 (original)
+++ 
activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/handler/CamelNamespaceHandler.java
 Wed Aug  6 10:09:14 2008
@@ -66,7 +66,7 @@
     protected Set<String> parserElementNames = new HashSet<String>();
     private JAXBContext jaxbContext;
     private Map<String, BeanDefinitionParser> parserMap = new HashMap<String, 
BeanDefinitionParser>();
-    private Binder<Node> binder;
+    protected Binder<Node> binder;
 
     public void init() {
         // remoting

Modified: 
activemq/camel/trunk/tooling/maven/camel-maven-plugin/src/main/java/org/apache/camel/maven/RunMojo.java
URL: 
http://svn.apache.org/viewvc/activemq/camel/trunk/tooling/maven/camel-maven-plugin/src/main/java/org/apache/camel/maven/RunMojo.java?rev=683331&r1=683330&r2=683331&view=diff
==============================================================================
--- 
activemq/camel/trunk/tooling/maven/camel-maven-plugin/src/main/java/org/apache/camel/maven/RunMojo.java
 (original)
+++ 
activemq/camel/trunk/tooling/maven/camel-maven-plugin/src/main/java/org/apache/camel/maven/RunMojo.java
 Wed Aug  6 10:09:14 2008
@@ -163,6 +163,13 @@
     private boolean trace;
 
     /**
+     * Output all routes to the specified XML file
+     *
+     * @parameter expression="${camel.routesOutputFile}"
+     */
+    private String routesOutputFile;    
+    
+    /**
      * The main class to execute.
      *
      * @parameter expression="${camel.mainClass}"
@@ -342,6 +349,11 @@
             args.add("-t");
         }
 
+        if (routesOutputFile != null) {
+            args.add("-output");
+            args.add(routesOutputFile);
+        }        
+        
         if (applicationContextUri != null) {
             args.add("-a");
             args.add(applicationContextUri);


Reply via email to