Clean up Apache Camel example

This commit is contained in:
David Morley
2016-02-18 21:31:51 -06:00
parent 9d6f56c40a
commit 54a1235d17
7 changed files with 147 additions and 148 deletions
@@ -1,12 +1,12 @@
package org.apache.camel.main;
import org.springframework.context.support.ClassPathXmlApplicationContext;
public class App {
public static void main(final String[] args) throws Exception {
ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext("camel-context.xml");
// Keep main thread alive for some time to let application finish processing the input files.
Thread.sleep(5000);
applicationContext.close();
}
package com.baeldung.camel.main;
import org.springframework.context.support.ClassPathXmlApplicationContext;
public class App {
public static void main(final String[] args) throws Exception {
ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext("camel-context.xml");
// Keep main thread alive for some time to let application finish processing the input files.
Thread.sleep(5000);
applicationContext.close();
}
}
@@ -0,0 +1,14 @@
package com.baeldung.camel.processor;
import org.apache.camel.Exchange;
import org.apache.camel.Processor;
public class FileProcessor implements Processor {
public void process(Exchange exchange) throws Exception {
String originalFileContent = exchange.getIn().getBody(String.class);
String upperCaseFileContent = originalFileContent.toUpperCase();
exchange.getIn().setBody(upperCaseFileContent);
}
}
@@ -1,14 +0,0 @@
package org.apache.camel.processor;
import org.apache.camel.Exchange;
import org.apache.camel.Processor;
public class FileProcessor implements Processor {
public void process(Exchange exchange) throws Exception {
String originalFileContent = exchange.getIn().getBody(String.class);
String upperCaseFileContent = originalFileContent.toUpperCase();
exchange.getIn().setBody(upperCaseFileContent);
}
}
@@ -1,40 +1,39 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">
<camelContext xmlns="http://camel.apache.org/schema/spring">
<camelContext xmlns="http://camel.apache.org/schema/spring">
<route customId="true" id="route1">
<route customId="true" id="route1">
<!-- Read files from input directory -->
<from uri="file://src/test/data/input" />
<!-- Read files from input directory -->
<from uri="file://src/test/data/input"/>
<!-- Transform content to UpperCase -->
<process ref="myFileProcessor" />
<!-- Transform content to UpperCase -->
<process ref="myFileProcessor"/>
<!-- Write converted file content -->
<to uri="file://src/test/data/outputUpperCase" />
<!-- Write converted file content -->
<to uri="file://src/test/data/outputUpperCase"/>
<!-- Transform content to LowerCase -->
<transform>
<simple>${body.toLowerCase()}</simple>
</transform>
<!-- Transform content to LowerCase -->
<transform>
<simple>${body.toLowerCase()}</simple>
</transform>
<!-- Write converted file content -->
<to uri="file://src/test/data/outputLowerCase" />
<!-- Write converted file content -->
<to uri="file://src/test/data/outputLowerCase"/>
<!-- Display process completion message on console -->
<transform>
<simple> .......... File content conversion completed ..........
</simple>
</transform>
<to uri="stream:out" />
<!-- Display process completion message on console -->
<transform>
<simple>.......... File content conversion completed ..........</simple>
</transform>
<to uri="stream:out"/>
</route>
</route>
</camelContext>
</camelContext>
<bean id="myFileProcessor" class="org.apache.camel.processor.FileProcessor" />
<bean id="myFileProcessor" class="com.baeldung.camel.processor.FileProcessor"/>
</beans>