diff --git a/code/01_file-split-and-transform-sb/features/pom.xml b/code/01_file-split-and-transform-sb/features/pom.xml
deleted file mode 100644
index f985428..0000000
--- a/code/01_file-split-and-transform-sb/features/pom.xml
+++ /dev/null
@@ -1,73 +0,0 @@
-
-
- 4.0.0
-
-
- org.fuse.usecase1
- parent
- 1.0
- ../parent/pom.xml
-
-
- features
- Fuse :: Use Case 1 :: Features
-
- pom
-
-
-
-
-
- ${pom.basedir}/src/main/filtered-resources
- true
-
- **/*
-
-
-
-
-
-
- org.apache.maven.plugins
- maven-resources-plugin
- ${maven-resources-plugin.version}
-
-
- filter
- generate-resources
-
- resources
-
-
-
-
-
-
- org.codehaus.mojo
- build-helper-maven-plugin
- ${build-helper-maven-plugin.version}
-
-
- attach-artifacts
- package
-
- attach-artifact
-
-
-
-
- target/classes/features.xml
- xml
- features
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/code/01_file-split-and-transform-sb/features/src/main/filtered-resources/features.xml b/code/01_file-split-and-transform-sb/features/src/main/filtered-resources/features.xml
deleted file mode 100644
index eb8ca65..0000000
--- a/code/01_file-split-and-transform-sb/features/src/main/filtered-resources/features.xml
+++ /dev/null
@@ -1,10 +0,0 @@
-
-
-
- camel
- camel-bindy
- camel-jackson
- camel-dozer
- mvn:org.fuse.usecase1/routing/${project.version}
-
-
\ No newline at end of file
diff --git a/code/01_file-split-and-transform-sb/parent/pom.xml b/code/01_file-split-and-transform-sb/parent/pom.xml
index 968989e..705977e 100644
--- a/code/01_file-split-and-transform-sb/parent/pom.xml
+++ b/code/01_file-split-and-transform-sb/parent/pom.xml
@@ -34,11 +34,6 @@
pom
import
-
- org.springframework.boot
- spring-boot-starter-test
- 1.5.13.RELEASE
-
@@ -63,28 +58,6 @@
-
-
-
- org.apache.camel
- camel-core
-
-
- org.apache.camel
- camel-spring
-
-
-
- org.slf4j
- slf4j-api
-
-
- log4j
- log4j
-
-
-
-
diff --git a/code/01_file-split-and-transform-sb/routing/pom.xml b/code/01_file-split-and-transform-sb/routing/pom.xml
index 0438dcb..91a00d9 100644
--- a/code/01_file-split-and-transform-sb/routing/pom.xml
+++ b/code/01_file-split-and-transform-sb/routing/pom.xml
@@ -62,10 +62,6 @@
camel-test-spring
test
-
- org.apache.camel
- camel-spring-javaconfig
-
diff --git a/code/01_file-split-and-transform-sb/routing/src/main/java/org/acme/routes/CustomerRoute.java b/code/01_file-split-and-transform-sb/routing/src/main/java/org/acme/routes/CustomerRoute.java
index f62f5c5..cf83656 100644
--- a/code/01_file-split-and-transform-sb/routing/src/main/java/org/acme/routes/CustomerRoute.java
+++ b/code/01_file-split-and-transform-sb/routing/src/main/java/org/acme/routes/CustomerRoute.java
@@ -8,7 +8,6 @@
import org.apache.camel.model.dataformat.JsonLibrary;
import org.apache.camel.model.language.ExpressionDefinition;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import org.globex.Account;
import org.globex.Company;
diff --git a/code/01_file-split-and-transform-sb/routing/src/test/java/org/fuse/usecase/ValidateTransformationTest.java b/code/01_file-split-and-transform-sb/routing/src/test/java/org/fuse/usecase/ValidateTransformationTest.java
index a507a04..77bb25e 100644
--- a/code/01_file-split-and-transform-sb/routing/src/test/java/org/fuse/usecase/ValidateTransformationTest.java
+++ b/code/01_file-split-and-transform-sb/routing/src/test/java/org/fuse/usecase/ValidateTransformationTest.java
@@ -1,74 +1,23 @@
package org.fuse.usecase;
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.DeserializationFeature;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
import org.acme.Application;
-import org.apache.camel.CamelContext;
import org.apache.camel.EndpointInject;
-import org.apache.camel.Produce;
-import org.apache.camel.ProducerTemplate;
-import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.test.spring.CamelSpringDelegatingTestContextLoader;
-import org.apache.camel.test.spring.CamelSpringJUnit4ClassRunner;
+import org.apache.camel.test.spring.CamelSpringRunner;
import org.junit.Test;
-import org.acme.routes.CustomerRoute;
import org.junit.runner.RunWith;
-import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.junit4.AbstractJUnit4SpringContextTests;
-import org.apache.camel.spring.javaconfig.SingleRouteCamelConfiguration;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.util.logging.Logger;
-@RunWith(CamelSpringJUnit4ClassRunner.class)
-//@ContextConfiguration(classes = {ValidateTransformationTest.ContextConfig.class}, loader = CamelSpringDelegatingTestContextLoader.class)
+@RunWith(CamelSpringRunner.class)
@SpringBootTest(classes = Application.class)
-public class ValidateTransformationTest extends AbstractJUnit4SpringContextTests {
+public class ValidateTransformationTest {
- @Autowired
- private CamelContext camelContext;
-
- @EndpointInject(uri = "mock:csv2json-test-output") private MockEndpoint resultEndpoint;
-
- @Produce(uri = "direct:csv2json-test-input") private ProducerTemplate startEndpoint;
-
-// private RouteBuilder createRouteBuilder() throws Exception {
-// return new CustomerRoute();
-// }
+ @EndpointInject(uri = "mock:csv2json-test-output")
+ private MockEndpoint resultEndpoint;
@Test
public void testMessageOutputCount() throws Exception {
resultEndpoint.expectedMessageCount(1);
resultEndpoint.assertIsSatisfied();
}
-
-// @Test
-// public void test() {
-// resultEndpoint.
-// }
-
-// private String readFile(String filePath) throws Exception {
-// String content;
-// FileInputStream fis = new FileInputStream(filePath);
-// try {
-// content = new CamelContext().getTypeConverter().convertTo(String.class, fis);
-// } finally {
-// fis.close();
-// }
-// return content;
-// }
-
- private String jsonUnprettyPrint(String jsonString) throws JsonProcessingException, IOException {
- ObjectMapper mapper = new ObjectMapper();
- mapper.configure(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS, true);
- JsonNode node = mapper.readTree(jsonString);
- return node.toString();
- }
}
diff --git a/code/01_file-split-and-transform-sb/routing/src/test/resources/config/application.yaml b/code/01_file-split-and-transform-sb/routing/src/test/resources/config/application.yaml
index 497a08e..c6953d7 100644
--- a/code/01_file-split-and-transform-sb/routing/src/test/resources/config/application.yaml
+++ b/code/01_file-split-and-transform-sb/routing/src/test/resources/config/application.yaml
@@ -1,5 +1,5 @@
org:
acme:
customer:
- input: file://src/test/data/inbox?fileName=customers.csv&noop=true
+ input: file://src/test/data/inbox?fileName=customer.csv&noop=true
output: mock:csv2json-test-output
\ No newline at end of file
diff --git a/code/02_enrich-content-REST-and-WS-sb/parent/pom.xml b/code/02_enrich-content-REST-and-WS-sb/parent/pom.xml
index d9652b8..61133b2 100644
--- a/code/02_enrich-content-REST-and-WS-sb/parent/pom.xml
+++ b/code/02_enrich-content-REST-and-WS-sb/parent/pom.xml
@@ -1,220 +1,170 @@
-
-
- 4.0.0
-
- project
- org.fuse.usecase2
- 1.0
-
-
- parent
- 1.0
- Fuse :: Use Case 2 :: Parent
- pom
-
-
-
- 6.2.1.redhat-084
-
-
- 2.15.1.redhat-621084
- 2.15.1.redhat-621084
-
-
- 1.9.1
- 2.3.2
- 2.5
- 2.19.1
- 2.3.1
- 2.3.7
- 1.2.0.redhat-621084
-
-
- *
-
-
-
-
-
-
-
-
- org.jboss.fuse.bom
- jboss-fuse-parent
- ${jboss.fuse.bom.version}
- pom
- import
-
-
- org.apache.camel
- camel-parent
- ${camel.version}
- pom
- import
-
-
-
-
-
-
-
- org.apache.camel
- camel-core
-
-
- org.apache.camel
- camel-spring
-
-
- org.apache.camel
- camel-cxf
-
-
- org.apache.camel
- camel-dozer
-
-
- org.apache.camel
- camel-jackson
-
-
- org.apache.camel
- camel-sql
-
-
-
- org.slf4j
- slf4j-api
-
-
- org.slf4j
- slf4j-log4j12
-
-
- log4j
- log4j
-
-
-
-
-
- install
-
-
-
-
- org.apache.camel
- camel-maven-plugin
- ${camel.version}
-
-
- org.apache.felix
- maven-bundle-plugin
- ${felix-maven-plugin.version}
-
-
- io.fabric8
- fabric8-maven-plugin
- ${fabric8-plugin.version}
-
-
- org.codehaus.mojo
- build-helper-maven-plugin
- ${build-helper-maven-plugin.version}
-
-
- org.apache.maven.plugins
- maven-resources-plugin
- ${maven-resources-plugin.version}
-
-
- org.apache.maven.plugins
- maven-surefire-plugin
- ${maven-surefire.version}
-
-
-
-
-
-
- maven-compiler-plugin
- ${maven-compiler-plugin.version}
-
-
- 1.7
-
-
-
- org.apache.felix
- maven-bundle-plugin
- ${felix-maven-plugin.version}
- true
-
-
- ${project.artifactId}
- ${osgi-import-package}
- ${osgi-private-package}
- ${osgi-export-package}
- ${osgi-dynamic-package}
-
-
-
-
-
-
-
-
- fusesource-public-repository
- FuseSource Release Repository
- http://repository.jboss.org/nexus/content/repositories/fs-public/
-
-
- jboss-public-repository
- JBoss.org Public Maven Repository Group
- http://repository.jboss.org/nexus/content/groups/public-jboss/
-
-
- jboss-fuse-ea
- http://repository.jboss.org/nexus/content/groups/ea
-
-
- jboss-releases
- JBoss.org Fuse Releases
- http://repository.jboss.org/nexus/content/repositories/fs-releases/
-
-
- Maven Central
- http://repo1.maven.org/maven2/
-
-
- Tech Preview
- http://maven.repository.redhat.com/techpreview/all
-
-
-
-
- fusesource-public-repository
- FuseSource Release Repository
- http://repository.jboss.org/nexus/content/repositories/fs-public/
-
-
- jboss-public-repository-group
- JBoss.org Public Maven Repository Group
- http://repository.jboss.org/nexus/content/groups/public-jboss/
-
-
- jboss-fuse-releases
- JBoss.org Fuse Releases
- http://repository.jboss.org/nexus/content/repositories/fs-releases
-
-
- jboss-fuse-ea
- http://repository.jboss.org/nexus/content/groups/ea
-
-
- Tech Preview
- http://maven.repository.redhat.com/techpreview/all
-
-
-
+
+
+ 4.0.0
+
+ project
+ org.fuse.usecase2
+ 1.0
+
+
+ parent
+ 1.0
+ Fuse :: Use Case 2 :: Parent
+ pom
+
+
+
+ 7.1.0.fuse-710019-redhat-00002
+
+ 3.0.0
+ 3.8.0
+ 3.1.0
+ 2.19.1
+ 2.3.1
+ 2.8.11.redhat-1
+ 1.4.197
+
+
+
+
+
+ org.jboss.redhat-fuse
+ fuse-springboot-bom
+ ${fuse.version}
+ pom
+ import
+
+
+ com.h2database
+ h2
+ ${h2-driver.version}
+
+
+
+
+
+
+
+
+ org.jboss.redhat-fuse
+ spring-boot-maven-plugin
+ ${fuse.version}
+
+
+ org.codehaus.mojo
+ build-helper-maven-plugin
+ ${build-helper-maven-plugin.version}
+
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+ ${maven-surefire.version}
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+ ${maven-compiler-plugin.version}
+
+
+ 1.8
+
+
+
+
+
+
+
+
+
+ org.apache.camel
+ camel-core
+
+
+ org.apache.camel
+ camel-spring
+
+
+ org.apache.camel
+ camel-cxf
+
+
+ org.apache.camel
+ camel-dozer
+
+
+ org.apache.camel
+ camel-jackson
+
+
+ org.apache.camel
+ camel-sql
+
+
+
+ org.slf4j
+ slf4j-api
+
+
+ log4j
+ log4j
+
+
+
+
+
+
+
+ fusesource-public-repository
+ FuseSource Release Repository
+ http://repository.jboss.org/nexus/content/repositories/fs-public/
+
+
+ jboss-public-repository
+ JBoss.org Public Maven Repository Group
+ http://repository.jboss.org/nexus/content/groups/public-jboss/
+
+
+ jboss-fuse-ea
+ http://repository.jboss.org/nexus/content/groups/ea
+
+
+ jboss-releases
+ JBoss.org Fuse Releases
+ http://repository.jboss.org/nexus/content/repositories/fs-releases/
+
+
+ Maven Central
+ http://repo1.maven.org/maven2/
+
+
+ Tech Preview
+ http://maven.repository.redhat.com/techpreview/all
+
+
+
+
+ fusesource-public-repository
+ FuseSource Release Repository
+ http://repository.jboss.org/nexus/content/repositories/fs-public/
+
+
+ jboss-public-repository-group
+ JBoss.org Public Maven Repository Group
+ http://repository.jboss.org/nexus/content/groups/public-jboss/
+
+
+ jboss-fuse-releases
+ JBoss.org Fuse Releases
+ http://repository.jboss.org/nexus/content/repositories/fs-releases
+
+
+ jboss-fuse-ea
+ http://repository.jboss.org/nexus/content/groups/ea
+
+
+ Tech Preview
+ http://maven.repository.redhat.com/techpreview/all
+
+
+
diff --git a/code/02_enrich-content-REST-and-WS-sb/routing/pom.xml b/code/02_enrich-content-REST-and-WS-sb/routing/pom.xml
index e1d39d9..590957b 100644
--- a/code/02_enrich-content-REST-and-WS-sb/routing/pom.xml
+++ b/code/02_enrich-content-REST-and-WS-sb/routing/pom.xml
@@ -19,6 +19,14 @@
org.apache.camel
camel-spring-boot-starter
+
+ org.apache.cxf
+ cxf-rt-transports-http-jetty
+
+
+ org.apache.camel
+ camel-cxf
+
org.apache.camel
camel-bindy
@@ -31,6 +39,16 @@
com.fasterxml.jackson.core
jackson-databind
+
+ com.fasterxml.jackson.jaxrs
+ jackson-jaxrs-json-provider
+
+
+
+
+ com.h2database
+ h2
+
@@ -51,16 +69,13 @@
org.springframework.boot
spring-boot-starter-test
+ test
org.apache.camel
camel-test-spring
test
-
- org.apache.camel
- camel-spring-javaconfig
-
diff --git a/code/02_enrich-content-REST-and-WS-sb/routing/src/main/java/org/acme/Application.java b/code/02_enrich-content-REST-and-WS-sb/routing/src/main/java/org/acme/Application.java
new file mode 100644
index 0000000..dacb9e3
--- /dev/null
+++ b/code/02_enrich-content-REST-and-WS-sb/routing/src/main/java/org/acme/Application.java
@@ -0,0 +1,13 @@
+package org.acme;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.context.annotation.ImportResource;
+
+@SpringBootApplication
+@ImportResource("classpath:META-INF/spring/camel-context.xml")
+public class Application {
+ public static void main(String... args) {
+ SpringApplication.run(org.acme.Application.class, args);
+ }
+}
diff --git a/code/02_enrich-content-REST-and-WS-sb/routing/src/main/java/org/acme/config/CustomerDbRouteProperties.java b/code/02_enrich-content-REST-and-WS-sb/routing/src/main/java/org/acme/config/CustomerDbRouteProperties.java
new file mode 100644
index 0000000..a468695
--- /dev/null
+++ b/code/02_enrich-content-REST-and-WS-sb/routing/src/main/java/org/acme/config/CustomerDbRouteProperties.java
@@ -0,0 +1,33 @@
+package org.acme.config;
+
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.stereotype.Component;
+
+@Component
+@ConfigurationProperties(prefix = "org.acme.customer.db")
+public class CustomerDbRouteProperties {
+ private String input = "direct:insertDb";
+
+ private String output = "sql:INSERT INTO USECASE.T_ACCOUNT(CLIENT_ID,SALES_CONTACT,COMPANY_NAME,COMPANY_GEO,COMPANY_ACTIVE,CONTACT_FIRST_NAME,CONTACT_LAST_NAME,CONTACT_ADDRESS," +
+ "CONTACT_CITY,CONTACT_STATE,CONTACT_ZIP,CONTACT_PHONE,CREATION_DATE,CREATION_USER) " +
+ "VALUES " +
+ "(:#CLIENT_ID,:#SALES_CONTACT,:#COMPANY_NAME,:#COMPANY_GEO,:#COMPANY_ACTIVE,:#CONTACT_FIRST_NAME,:#CONTACT_LAST_NAME,:#CONTACT_ADDRESS,:#CONTACT_CITY," +
+ ":#CONTACT_STATE,:#CONTACT_ZIP,:#CONTACT_PHONE,:#CREATION_DATE,:#CREATION_USER)";
+
+ public String getInput() {
+ return input;
+ }
+
+ public void setInput(String input) {
+ this.input = input;
+ }
+
+ public String getOutput() {
+ return output;
+ }
+
+ public void setOutput(String output) {
+ this.output = output;
+ }
+
+}
diff --git a/code/02_enrich-content-REST-and-WS-sb/routing/src/main/java/org/acme/config/CustomerLoadRouteProperties.java b/code/02_enrich-content-REST-and-WS-sb/routing/src/main/java/org/acme/config/CustomerLoadRouteProperties.java
new file mode 100644
index 0000000..413b4ee
--- /dev/null
+++ b/code/02_enrich-content-REST-and-WS-sb/routing/src/main/java/org/acme/config/CustomerLoadRouteProperties.java
@@ -0,0 +1,46 @@
+package org.acme.config;
+
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.stereotype.Component;
+
+@Component
+@ConfigurationProperties(prefix = "org.acme.customer.load")
+public class CustomerLoadRouteProperties {
+ private String input = "file://src/data/outbox?noop=true&idempotent=true";
+ private String restEndpoint = "direct:callRestEndpoint";
+ private String wsEndpoint = "direct:callWsEndpoint";
+ private String output = "direct:insertDb";
+
+
+ public String getOutput() {
+ return output;
+ }
+
+ public void setOutput(String output) {
+ this.output = output;
+ }
+
+ public String getInput() {
+ return input;
+ }
+
+ public void setInput(String input) {
+ this.input = input;
+ }
+
+ public String getRestEndpoint() {
+ return restEndpoint;
+ }
+
+ public void setRestEndpoint(String restEndpoint) {
+ this.restEndpoint = restEndpoint;
+ }
+
+ public String getWsEndpoint() {
+ return wsEndpoint;
+ }
+
+ public void setWsEndpoint(String wsEndpoint) {
+ this.wsEndpoint = wsEndpoint;
+ }
+}
diff --git a/code/02_enrich-content-REST-and-WS-sb/routing/src/main/java/org/acme/config/CustomerTransformRouteProperties.java b/code/02_enrich-content-REST-and-WS-sb/routing/src/main/java/org/acme/config/CustomerTransformRouteProperties.java
new file mode 100644
index 0000000..9b30240
--- /dev/null
+++ b/code/02_enrich-content-REST-and-WS-sb/routing/src/main/java/org/acme/config/CustomerTransformRouteProperties.java
@@ -0,0 +1,27 @@
+package org.acme.config;
+
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.stereotype.Component;
+
+@Component
+@ConfigurationProperties(prefix = "org.acme.customer.transform")
+public class CustomerTransformRouteProperties {
+ private String input = "file://src/data/inbox?fileName=customers.csv&noop=true";
+ private String output = "file://src/data/outbox?fileName=account-${property.CamelSplitIndex}.json";
+
+ public String getInput() {
+ return input;
+ }
+
+ public void setInput(String input) {
+ this.input = input;
+ }
+
+ public String getOutput() {
+ return output;
+ }
+
+ public void setOutput(String output) {
+ this.output = output;
+ }
+}
diff --git a/code/02_enrich-content-REST-and-WS-sb/routing/src/main/java/org/acme/config/rest/CustomerRestClientRouteProperties.java b/code/02_enrich-content-REST-and-WS-sb/routing/src/main/java/org/acme/config/rest/CustomerRestClientRouteProperties.java
new file mode 100644
index 0000000..061bf95
--- /dev/null
+++ b/code/02_enrich-content-REST-and-WS-sb/routing/src/main/java/org/acme/config/rest/CustomerRestClientRouteProperties.java
@@ -0,0 +1,28 @@
+package org.acme.config.rest;
+
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.stereotype.Component;
+
+@Component
+@ConfigurationProperties(prefix = "org.acme.customer.rest")
+public class CustomerRestClientRouteProperties {
+ private String input = "direct:callRestEndpoint";
+
+ private String output = "cxfrs:bean:customerRestServiceClient";
+
+ public String getInput() {
+ return input;
+ }
+
+ public void setInput(String input) {
+ this.input = input;
+ }
+
+ public String getOutput() {
+ return output;
+ }
+
+ public void setOutput(String output) {
+ this.output = output;
+ }
+}
diff --git a/code/02_enrich-content-REST-and-WS-sb/routing/src/main/java/org/acme/config/rest/CustomerRestServerRouteProperties.java b/code/02_enrich-content-REST-and-WS-sb/routing/src/main/java/org/acme/config/rest/CustomerRestServerRouteProperties.java
new file mode 100644
index 0000000..2d05aca
--- /dev/null
+++ b/code/02_enrich-content-REST-and-WS-sb/routing/src/main/java/org/acme/config/rest/CustomerRestServerRouteProperties.java
@@ -0,0 +1,28 @@
+package org.acme.config.rest;
+
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.stereotype.Component;
+
+@Component
+@ConfigurationProperties(prefix = "org.acme.customer.rest")
+public class CustomerRestServerRouteProperties {
+ private String input = "cxfrs:bean:customerRestService";
+
+ private String output = "cxfrs:bean:customerRestServiceClient";
+
+ public String getInput() {
+ return input;
+ }
+
+ public void setInput(String input) {
+ this.input = input;
+ }
+
+ public String getOutput() {
+ return output;
+ }
+
+ public void setOutput(String output) {
+ this.output = output;
+ }
+}
diff --git a/code/02_enrich-content-REST-and-WS-sb/routing/src/main/java/org/acme/config/ws/CustomerWsClientRouteProperties.java b/code/02_enrich-content-REST-and-WS-sb/routing/src/main/java/org/acme/config/ws/CustomerWsClientRouteProperties.java
new file mode 100644
index 0000000..c026a4e
--- /dev/null
+++ b/code/02_enrich-content-REST-and-WS-sb/routing/src/main/java/org/acme/config/ws/CustomerWsClientRouteProperties.java
@@ -0,0 +1,28 @@
+package org.acme.config.ws;
+
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.stereotype.Component;
+
+@Component
+@ConfigurationProperties(prefix = "org.acme.customer.ws")
+public class CustomerWsClientRouteProperties {
+ private String input = "direct:callWsEndpoint";
+
+ private String output = "cxf:bean:customerWebService";
+
+ public String getInput() {
+ return input;
+ }
+
+ public void setInput(String input) {
+ this.input = input;
+ }
+
+ public String getOutput() {
+ return output;
+ }
+
+ public void setOutput(String output) {
+ this.output = output;
+ }
+}
diff --git a/code/02_enrich-content-REST-and-WS-sb/routing/src/main/java/org/acme/config/ws/CustomerWsServerRouteProperties.java b/code/02_enrich-content-REST-and-WS-sb/routing/src/main/java/org/acme/config/ws/CustomerWsServerRouteProperties.java
new file mode 100644
index 0000000..3edebcd
--- /dev/null
+++ b/code/02_enrich-content-REST-and-WS-sb/routing/src/main/java/org/acme/config/ws/CustomerWsServerRouteProperties.java
@@ -0,0 +1,28 @@
+package org.acme.config.ws;
+
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.stereotype.Component;
+
+@Component
+@ConfigurationProperties(prefix = "org.acme.customer.ws")
+public class CustomerWsServerRouteProperties {
+ private String input = "cxf:bean:customerWebService";
+
+ public String getOutput() {
+ return output;
+ }
+
+ public void setOutput(String output) {
+ this.output = output;
+ }
+
+ private String output = "direct:insertDb";
+
+ public String getInput() {
+ return input;
+ }
+
+ public void setInput(String input) {
+ this.input = input;
+ }
+}
diff --git a/code/02_enrich-content-REST-and-WS-sb/routing/src/main/java/org/acme/routes/CustomerDbRoute.java b/code/02_enrich-content-REST-and-WS-sb/routing/src/main/java/org/acme/routes/CustomerDbRoute.java
new file mode 100644
index 0000000..563f2c1
--- /dev/null
+++ b/code/02_enrich-content-REST-and-WS-sb/routing/src/main/java/org/acme/routes/CustomerDbRoute.java
@@ -0,0 +1,22 @@
+package org.acme.routes;
+
+import org.acme.config.CustomerDbRouteProperties;
+import org.apache.camel.builder.RouteBuilder;
+import org.fuse.usecase.ProcessorBean;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+@Component
+public class CustomerDbRoute extends RouteBuilder {
+ @Autowired
+ private CustomerDbRouteProperties customerDbRouteProperties;
+
+ @Override
+ public void configure() {
+ from(customerDbRouteProperties.getInput()).routeId("customer-insert-db")
+ .to("log:picked-up-db")
+ .transform().method(ProcessorBean.class, "defineNamedParameters")
+ .to(customerDbRouteProperties.getOutput())
+ .to("log:inserted-db");
+ }
+}
diff --git a/code/02_enrich-content-REST-and-WS-sb/routing/src/main/java/org/acme/routes/CustomerLoadRoute.java b/code/02_enrich-content-REST-and-WS-sb/routing/src/main/java/org/acme/routes/CustomerLoadRoute.java
new file mode 100644
index 0000000..432ccc5
--- /dev/null
+++ b/code/02_enrich-content-REST-and-WS-sb/routing/src/main/java/org/acme/routes/CustomerLoadRoute.java
@@ -0,0 +1,29 @@
+package org.acme.routes;
+
+import org.acme.config.CustomerLoadRouteProperties;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.jackson.JacksonDataFormat;
+import org.fuse.usecase.AccountAggregator;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+@Component
+public class CustomerLoadRoute extends RouteBuilder {
+
+ @Autowired
+ private CustomerLoadRouteProperties customerLoadRouteProperties;
+
+ @Override
+ public void configure () throws Exception {
+ JacksonDataFormat format = new JacksonDataFormat(org.globex.Account.class);
+
+ from(customerLoadRouteProperties.getInput()).routeId("customer-load")
+ .to("log:loaded")
+ .unmarshal(format)
+ .to("log:unmarshalled")
+ .multicast(new AccountAggregator())
+ .to(customerLoadRouteProperties.getRestEndpoint(), customerLoadRouteProperties.getWsEndpoint()).end()
+ .to("log:enriched")
+ .to(customerLoadRouteProperties.getOutput());
+ }
+}
diff --git a/code/02_enrich-content-REST-and-WS-sb/routing/src/main/java/org/acme/routes/CustomerTransformRoute.java b/code/02_enrich-content-REST-and-WS-sb/routing/src/main/java/org/acme/routes/CustomerTransformRoute.java
new file mode 100644
index 0000000..e5ac215
--- /dev/null
+++ b/code/02_enrich-content-REST-and-WS-sb/routing/src/main/java/org/acme/routes/CustomerTransformRoute.java
@@ -0,0 +1,74 @@
+package org.acme.routes;
+
+import org.acme.Customer;
+import org.acme.config.CustomerTransformRouteProperties;
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.dataformat.bindy.csv.BindyCsvDataFormat;
+import org.apache.camel.model.dataformat.JsonLibrary;
+import org.globex.Account;
+import org.globex.Company;
+import org.globex.Contact;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+@Component
+public class CustomerTransformRoute extends RouteBuilder {
+
+ @Autowired
+ private CustomerTransformRouteProperties customerTransformRouteProperties;
+
+ @Override
+ public void configure () throws Exception {
+ onException(IllegalArgumentException.class)
+ .to("log:fail")
+ .to("file://src/data/error?fileName=csv-record-${date:now:yyyyMMdd}.txt")
+ .handled(true)
+ .stop();
+
+ BindyCsvDataFormat format = new BindyCsvDataFormat(org.acme.Customer.class);
+ format.setLocale("default");
+
+ from(customerTransformRouteProperties.getInput()).routeId("customer2account-transform")
+ .split()
+ .tokenize("\n")
+ .to("log:tokenized")
+ .unmarshal(format)
+ .to("log:unmarshalled")
+ .to("dozer:customerToAccount?mappingFile=transformation.xml&sourceModel=org.acme.Customer&targetModel=org.globex.Account")
+ /*
+ If you want to use a processor, uncomment the line below and comment the dozer line above
+ .process(new CustomerProcessor())
+ */
+ .to("log:transformed")
+ .marshal().json(JsonLibrary.Jackson)
+ .to(customerTransformRouteProperties.getOutput());
+ }
+
+ class CustomerProcessor implements Processor {
+ public void process(Exchange exchange) throws Exception {
+ Customer customer = exchange.getIn().getBody(Customer.class);
+ Account theAccount = new Account();
+ Company theCompany = new Company();
+ Contact theContact = new Contact();
+
+ theContact.setCity(customer.getCity());
+ theContact.setFirstName(customer.getFirstName());
+ theContact.setLastName(customer.getLastName());
+ theContact.setPhone(customer.getPhone());
+ theContact.setState(customer.getState());
+ theContact.setStreetAddr(customer.getStreetAddr());
+ theContact.setZip(customer.getZip());
+
+ theCompany.setActive(customer.isActive());
+ theCompany.setGeo(customer.getRegion());
+ theCompany.setName(customer.getCompanyName());
+
+ theAccount.setCompany(theCompany);
+ theAccount.setContact(theContact);
+
+ exchange.getIn().setBody(theAccount, Account.class);
+ }
+ }
+}
diff --git a/code/02_enrich-content-REST-and-WS-sb/routing/src/main/java/org/acme/routes/rest/CustomerRestClientRoute.java b/code/02_enrich-content-REST-and-WS-sb/routing/src/main/java/org/acme/routes/rest/CustomerRestClientRoute.java
new file mode 100644
index 0000000..056f3a8
--- /dev/null
+++ b/code/02_enrich-content-REST-and-WS-sb/routing/src/main/java/org/acme/routes/rest/CustomerRestClientRoute.java
@@ -0,0 +1,47 @@
+package org.acme.routes.rest;
+
+import org.acme.config.rest.CustomerRestClientRouteProperties;
+import org.apache.camel.Exchange;
+import org.apache.camel.Message;
+import org.apache.camel.Processor;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.jackson.JacksonDataFormat;
+import org.apache.camel.component.jackson.ListJacksonDataFormat;
+import org.globex.Account;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+@Component
+public class CustomerRestClientRoute extends RouteBuilder {
+
+ @Autowired
+ private CustomerRestClientRouteProperties customerRestClientRouteProperties;
+
+ @Override
+ public void configure () throws Exception {
+ onException(Exception.class)
+ .to("log:onException")
+ .handled(true)
+ .transform(constant("Exception thrown. Stop route"));
+
+ JacksonDataFormat dataFormat = new ListJacksonDataFormat(Account.class);
+
+ from(customerRestClientRouteProperties.getInput()).routeId("customer-rest")
+ .to("log:rest-picked-up")
+ .process(new AccountHeaderProcessor())
+ .inOut(customerRestClientRouteProperties.getOutput())
+ .unmarshal(dataFormat)
+ .to("log:sent-to-rest");
+ }
+
+ class AccountHeaderProcessor implements Processor {
+ public void process(Exchange exchange) {
+ Message message = exchange.getIn();
+ message.setHeader("Content-type", "application/json");
+ message.setHeader("Accept", "application/json");
+ message.setHeader("CamelHTTPMethod", "POST");
+ message.setHeader("CamelHttpPath", "/customerservice/enrich");
+ message.setHeader("CamelCxfRsUsingHttpAPI", "True");
+ }
+ }
+}
diff --git a/code/02_enrich-content-REST-and-WS-sb/routing/src/main/java/org/acme/routes/rest/CustomerRestServerRoute.java b/code/02_enrich-content-REST-and-WS-sb/routing/src/main/java/org/acme/routes/rest/CustomerRestServerRoute.java
new file mode 100644
index 0000000..86d2b4c
--- /dev/null
+++ b/code/02_enrich-content-REST-and-WS-sb/routing/src/main/java/org/acme/routes/rest/CustomerRestServerRoute.java
@@ -0,0 +1,18 @@
+package org.acme.routes.rest;
+
+import org.acme.config.rest.CustomerRestServerRouteProperties;
+import org.apache.camel.builder.RouteBuilder;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+@Component
+public class CustomerRestServerRoute extends RouteBuilder {
+
+ @Autowired
+ private CustomerRestServerRouteProperties customerRestServerRouteProperties;
+
+ @Override
+ public void configure () throws Exception {
+ from(customerRestServerRouteProperties.getInput()).to("log:found-rest-message");
+ }
+}
diff --git a/code/02_enrich-content-REST-and-WS-sb/routing/src/main/java/org/acme/routes/ws/CustomerWsClientRoute.java b/code/02_enrich-content-REST-and-WS-sb/routing/src/main/java/org/acme/routes/ws/CustomerWsClientRoute.java
new file mode 100644
index 0000000..2788ae5
--- /dev/null
+++ b/code/02_enrich-content-REST-and-WS-sb/routing/src/main/java/org/acme/routes/ws/CustomerWsClientRoute.java
@@ -0,0 +1,22 @@
+package org.acme.routes.ws;
+
+import org.acme.config.ws.CustomerWsClientRouteProperties;
+import org.apache.camel.builder.RouteBuilder;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+@Component
+public class CustomerWsClientRoute extends RouteBuilder {
+
+ @Autowired
+ private CustomerWsClientRouteProperties customerWsClientRouteProperties;
+
+ @Override
+ public void configure () throws Exception {
+ from(customerWsClientRouteProperties.getInput()).routeId("customer-ws-client")
+ .to("log:ws-picked-up")
+ .to(customerWsClientRouteProperties.getOutput())
+ .to("log:ws-response-received");
+ }
+
+}
diff --git a/code/02_enrich-content-REST-and-WS-sb/routing/src/main/java/org/acme/routes/ws/CustomerWsServerRoute.java b/code/02_enrich-content-REST-and-WS-sb/routing/src/main/java/org/acme/routes/ws/CustomerWsServerRoute.java
new file mode 100644
index 0000000..a7799d1
--- /dev/null
+++ b/code/02_enrich-content-REST-and-WS-sb/routing/src/main/java/org/acme/routes/ws/CustomerWsServerRoute.java
@@ -0,0 +1,21 @@
+package org.acme.routes.ws;
+
+import org.acme.config.ws.CustomerWsServerRouteProperties;
+import org.apache.camel.builder.RouteBuilder;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+
+@Component
+public class CustomerWsServerRoute extends RouteBuilder {
+
+ @Autowired
+ private CustomerWsServerRouteProperties customerWsServerRouteProperties;
+
+ @Override
+ public void configure () throws Exception {
+ from(customerWsServerRouteProperties.getInput()).routeId("customer-ws-server")
+ .beanRef("customerWSImplBean", "updateAccount")
+ .to("log:ws-server-responded");
+ }
+}
diff --git a/code/02_enrich-content-REST-and-WS-sb/routing/src/main/java/org/fuse/usecase/AccountAggregator.java b/code/02_enrich-content-REST-and-WS-sb/routing/src/main/java/org/fuse/usecase/AccountAggregator.java
index dfa5c65..95431d6 100644
--- a/code/02_enrich-content-REST-and-WS-sb/routing/src/main/java/org/fuse/usecase/AccountAggregator.java
+++ b/code/02_enrich-content-REST-and-WS-sb/routing/src/main/java/org/fuse/usecase/AccountAggregator.java
@@ -2,24 +2,47 @@
import org.apache.camel.Exchange;
import org.apache.camel.processor.aggregate.AggregationStrategy;
-import org.apache.cxf.message.MessageContentsList;
import org.globex.Account;
-import org.globex.Company;
import org.globex.CorporateAccount;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.ArrayList;
/**
* Aggregator implementation which extract the id and salescontact
* from CorporateAccount and update the Account
*/
public class AccountAggregator implements AggregationStrategy {
+ final Logger logger = LoggerFactory.getLogger(AccountAggregator.class);
@Override
public Exchange aggregate(Exchange oldExchange, Exchange newExchange) {
+ if(oldExchange == null) {
+ logger.info("oldExchange is empty, just returning newExchange.");
+ return newExchange;
+ }
- return oldExchange;
+ try {
+ logger.info("oldExchange body: " + oldExchange.getIn().getBody().getClass());
+ logger.info("newExchange body: " + newExchange.getIn().getBody().getClass());
+ Account account = (Account) oldExchange.getIn().getBody(ArrayList.class).get(0);
+ logger.info("Retrieved Account from oldExchange: " + account);
+ CorporateAccount corporateAccount = newExchange.getIn().getBody(CorporateAccount.class);
+ logger.info("Retrieved CorporateAccount from newExchange: " + corporateAccount);
+ logger.info("CorporateAccount ID: " + corporateAccount.getId());
+ account.setClientId(corporateAccount.getId());
+ logger.info("CorporateAccount Sales Contact: " + corporateAccount.getSalesContact());
+ account.setSalesRepresentative(corporateAccount.getSalesContact());
+
+ oldExchange.getIn().setBody(account, Account.class);
+
+ logger.info("Successfully merged enriched accounts.");
+ return oldExchange;
+ }
+ catch(Exception e) {
+ logger.error("Exception: ", e);
+ }
+ return newExchange;
}
}
\ No newline at end of file
diff --git a/code/02_enrich-content-REST-and-WS-sb/routing/src/main/java/org/fuse/usecase/ProcessorBean.java b/code/02_enrich-content-REST-and-WS-sb/routing/src/main/java/org/fuse/usecase/ProcessorBean.java
index f1eaeca..5f6678b 100644
--- a/code/02_enrich-content-REST-and-WS-sb/routing/src/main/java/org/fuse/usecase/ProcessorBean.java
+++ b/code/02_enrich-content-REST-and-WS-sb/routing/src/main/java/org/fuse/usecase/ProcessorBean.java
@@ -4,13 +4,10 @@
import org.apache.camel.Exchange;
import org.apache.camel.Message;
import org.apache.cxf.jaxrs.impl.ResponseImpl;
-import org.apache.cxf.message.MessageContentsList;
import org.globex.Account;
-import org.globex.CorporateAccount;
import java.io.IOException;
import java.io.InputStream;
-import java.io.SequenceInputStream;
import java.sql.Timestamp;
import java.util.Calendar;
import java.util.HashMap;
diff --git a/code/02_enrich-content-REST-and-WS-sb/routing/src/main/java/org/fuse/usecase/service/CustomerRest.java b/code/02_enrich-content-REST-and-WS-sb/routing/src/main/java/org/fuse/usecase/service/CustomerRest.java
index 3a569cf..d1b138a 100644
--- a/code/02_enrich-content-REST-and-WS-sb/routing/src/main/java/org/fuse/usecase/service/CustomerRest.java
+++ b/code/02_enrich-content-REST-and-WS-sb/routing/src/main/java/org/fuse/usecase/service/CustomerRest.java
@@ -4,11 +4,14 @@
import org.globex.Account;
import javax.ws.rs.*;
+import javax.ws.rs.core.MediaType;
@Path("/customerservice/")
public interface CustomerRest {
- @POST @Path("/enrich") @Consumes("application/json")
+ @POST @Path("/enrich")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
Account enrich(Account customer);
}
diff --git a/code/02_enrich-content-REST-and-WS-sb/routing/src/main/java/org/fuse/usecase/service/CustomerRestImpl.java b/code/02_enrich-content-REST-and-WS-sb/routing/src/main/java/org/fuse/usecase/service/CustomerRestImpl.java
index 9181021..488f37f 100644
--- a/code/02_enrich-content-REST-and-WS-sb/routing/src/main/java/org/fuse/usecase/service/CustomerRestImpl.java
+++ b/code/02_enrich-content-REST-and-WS-sb/routing/src/main/java/org/fuse/usecase/service/CustomerRestImpl.java
@@ -13,7 +13,8 @@ public class CustomerRestImpl implements CustomerRest {
private static final String WE_REGION = "WEST_AMERICA";
private static final String EAST_REGION = "EAST_AMERICA";
- @Override public Account enrich(Account account) {
+ @Override
+ public Account enrich(Account account) {
Company company = account.getCompany();
String region = company.getGeo();
switch (region) {
diff --git a/code/02_enrich-content-REST-and-WS-sb/routing/src/main/resources/META-INF/spring/camel-context.xml b/code/02_enrich-content-REST-and-WS-sb/routing/src/main/resources/META-INF/spring/camel-context.xml
index 6f95558..5efcd71 100644
--- a/code/02_enrich-content-REST-and-WS-sb/routing/src/main/resources/META-INF/spring/camel-context.xml
+++ b/code/02_enrich-content-REST-and-WS-sb/routing/src/main/resources/META-INF/spring/camel-context.xml
@@ -1,17 +1,12 @@
+ http://camel.apache.org/schema/cxf/camel-cxf-spring.xsd">
@@ -32,14 +27,14 @@
+ loggingFeatureEnabled="true">
+ loggingFeatureEnabled="true" serviceClass="org.fuse.usecase.service.CustomerRest">
@@ -49,15 +44,16 @@
+
-
+
+
+
-
-
-
+
diff --git a/code/02_enrich-content-REST-and-WS-sb/routing/src/main/resources/fabric8/route.properties b/code/02_enrich-content-REST-and-WS-sb/routing/src/main/resources/fabric8/route.properties
deleted file mode 100644
index bbfd0e6..0000000
--- a/code/02_enrich-content-REST-and-WS-sb/routing/src/main/resources/fabric8/route.properties
+++ /dev/null
@@ -1,3 +0,0 @@
-fileInput=src/data/inbox
-fileOutput=src/data/outbox
-fileError=src/data/error
\ No newline at end of file
diff --git a/code/02_enrich-content-REST-and-WS-sb/routing/src/test/java/org/fuse/usecase/CxfRestClient.java b/code/02_enrich-content-REST-and-WS-sb/routing/src/test/java/org/fuse/usecase/CxfRestClient.java
index 617ccac..20a821e 100644
--- a/code/02_enrich-content-REST-and-WS-sb/routing/src/test/java/org/fuse/usecase/CxfRestClient.java
+++ b/code/02_enrich-content-REST-and-WS-sb/routing/src/test/java/org/fuse/usecase/CxfRestClient.java
@@ -1,14 +1,15 @@
package org.fuse.usecase;
import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider;
-//import org.codehaus.jackson.jaxrs.JacksonJsonProvider;
import org.globex.Account;
import org.globex.Company;
import org.globex.Contact;
-import javax.ws.rs.client.*;
+import javax.ws.rs.client.Client;
+import javax.ws.rs.client.ClientBuilder;
+import javax.ws.rs.client.Entity;
+import javax.ws.rs.client.WebTarget;
import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
import static org.junit.Assert.assertEquals;