You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2016/11/24 09:45:25 UTC
[3/4] camel git commit: CAMEL-10447 Add contract based type awareness
and transformer which leverages the type metadata
http://git-wip-us.apache.org/repos/asf/camel/blob/7ba090f5/camel-core/src/main/resources/org/apache/camel/model/jaxb.index
----------------------------------------------------------------------
diff --git a/camel-core/src/main/resources/org/apache/camel/model/jaxb.index b/camel-core/src/main/resources/org/apache/camel/model/jaxb.index
index 9859736..aef22fa 100644
--- a/camel-core/src/main/resources/org/apache/camel/model/jaxb.index
+++ b/camel-core/src/main/resources/org/apache/camel/model/jaxb.index
@@ -35,6 +35,7 @@ HystrixConfigurationDefinition
IdempotentConsumerDefinition
InOnlyDefinition
InOutDefinition
+InputTypeDefinition
InterceptDefinition
InterceptFromDefinition
InterceptSendToEndpointDefinition
@@ -51,6 +52,7 @@ OnFallbackDefinition
OptimisticLockRetryPolicyDefinition
OptionalIdentifiedDefinition
OtherwiseDefinition
+OutputTypeDefinition
PackageScanDefinition
PipelineDefinition
PolicyDefinition
http://git-wip-us.apache.org/repos/asf/camel/blob/7ba090f5/camel-core/src/main/resources/org/apache/camel/model/transformer/jaxb.index
----------------------------------------------------------------------
diff --git a/camel-core/src/main/resources/org/apache/camel/model/transformer/jaxb.index b/camel-core/src/main/resources/org/apache/camel/model/transformer/jaxb.index
new file mode 100644
index 0000000..24e0f2b
--- /dev/null
+++ b/camel-core/src/main/resources/org/apache/camel/model/transformer/jaxb.index
@@ -0,0 +1,21 @@
+## ------------------------------------------------------------------------
+## Licensed to the Apache Software Foundation (ASF) under one or more
+## contributor license agreements. See the NOTICE file distributed with
+## this work for additional information regarding copyright ownership.
+## The ASF licenses this file to You under the Apache License, Version 2.0
+## (the "License"); you may not use this file except in compliance with
+## the License. You may obtain a copy of the License at
+##
+## http://www.apache.org/licenses/LICENSE-2.0
+##
+## Unless required by applicable law or agreed to in writing, software
+## distributed under the License is distributed on an "AS IS" BASIS,
+## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+## See the License for the specific language governing permissions and
+## limitations under the License.
+## ------------------------------------------------------------------------
+CustomTransformerDefinition
+DataFormatTransformerDefinition
+EndpointTransformerDefinition
+TransformerDefinition
+TransformersDefinition
http://git-wip-us.apache.org/repos/asf/camel/blob/7ba090f5/camel-core/src/test/java/org/apache/camel/impl/transformer/TransformerContractTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/impl/transformer/TransformerContractTest.java b/camel-core/src/test/java/org/apache/camel/impl/transformer/TransformerContractTest.java
new file mode 100644
index 0000000..263afd1
--- /dev/null
+++ b/camel-core/src/test/java/org/apache/camel/impl/transformer/TransformerContractTest.java
@@ -0,0 +1,173 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.impl.transformer;
+
+import java.io.BufferedReader;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.io.PrintWriter;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.Converter;
+import org.apache.camel.Exchange;
+import org.apache.camel.TypeConverters;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.model.DataFormatDefinition;
+import org.apache.camel.model.dataformat.JaxbDataFormat;
+import org.apache.camel.model.transformer.DataFormatTransformerDefinition;
+import org.apache.camel.spi.DataFormat;
+import org.apache.camel.spi.RouteContext;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+public class TransformerContractTest extends ContextTestSupport {
+
+ @Override
+ public boolean isUseRouteBuilder() {
+ return false;
+ }
+
+ @Test
+ public void testInputTypeOnly() throws Exception {
+ context.getTypeConverterRegistry().addTypeConverters(new MyTypeConverters());
+ context.addRoutes(new RouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+ from("direct:a")
+ .inputType(A.class)
+ .to("mock:a");
+ }
+ });
+ context.start();
+
+ MockEndpoint mock = context.getEndpoint("mock:a", MockEndpoint.class);
+ mock.setExpectedCount(1);
+ Object answer = template.requestBody("direct:a", "foo");
+ mock.assertIsSatisfied();
+ Exchange ex = mock.getExchanges().get(0);
+ assertEquals(A.class, ex.getIn().getBody().getClass());
+ assertEquals(A.class, answer.getClass());
+ }
+
+ @Test
+ public void testOutputTypeOnly() throws Exception {
+ context.getTypeConverterRegistry().addTypeConverters(new MyTypeConverters());
+ context.addRoutes(new RouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+ from("direct:a")
+ .outputType(A.class)
+ .to("mock:a");
+ }
+ });
+ context.start();
+
+ MockEndpoint mock = context.getEndpoint("mock:a", MockEndpoint.class);
+ mock.setExpectedCount(1);
+ Object answer = template.requestBody("direct:a", "foo");
+ mock.assertIsSatisfied();
+ Exchange ex = mock.getExchanges().get(0);
+ assertEquals("foo", ex.getIn().getBody());
+ assertEquals(A.class, answer.getClass());
+ }
+
+ @Test
+ public void testScheme() throws Exception {
+ DataFormatTransformerDefinition transformerDef = new DataFormatTransformerDefinition();
+ transformerDef.setScheme("xml");
+ transformerDef.setDataFormatType(new MyDataFormatDefinition());
+ context.getTransformers().add(transformerDef);
+ context.addRoutes(new RouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+ from("direct:a")
+ .inputType("xml")
+ .outputType("xml")
+ .to("mock:a")
+ .to("direct:b")
+ .to("mock:a2");
+ from("direct:b")
+ .inputType("java")
+ .outputType("java")
+ .to("mock:b")
+ .process(ex -> {
+ ex.getIn().setBody(new B());
+ });
+ }
+ });
+ context.start();
+
+ MockEndpoint mocka = context.getEndpoint("mock:a", MockEndpoint.class);
+ MockEndpoint mocka2 = context.getEndpoint("mock:a2", MockEndpoint.class);
+ MockEndpoint mockb = context.getEndpoint("mock:b", MockEndpoint.class);
+ mocka.setExpectedCount(1);
+ mocka2.setExpectedCount(1);
+ mockb.setExpectedCount(1);
+ Object answer = template.requestBody("direct:a", "<foo/>");
+ mocka.assertIsSatisfied();
+ mocka2.assertIsSatisfied();
+ mockb.assertIsSatisfied();
+ Exchange exa = mocka.getExchanges().get(0);
+ Exchange exa2 = mocka2.getExchanges().get(0);
+ Exchange exb = mockb.getExchanges().get(0);
+ assertEquals("<foo/>", exa.getIn().getBody());
+ assertEquals(A.class, exb.getIn().getBody().getClass());
+ assertEquals(B.class, exa2.getIn().getBody().getClass());
+ assertEquals("<fooResponse/>", new String((byte[])answer));
+ }
+
+ public static class MyTypeConverters implements TypeConverters {
+ @Converter
+ public A toA(String in) {
+ return new A();
+ }
+ }
+
+ public static class MyDataFormatDefinition extends DataFormatDefinition {
+ public static DataFormat getDataFormat(RouteContext routeContext, DataFormatDefinition type, String ref) {
+ return new MyDataFormatDefinition().createDataFormat();
+ }
+ public DataFormat getDataFormat(RouteContext routeContext) {
+ return createDataFormat();
+ }
+ private DataFormat createDataFormat() {
+ return new DataFormat() {
+ @Override
+ public void marshal(Exchange exchange, Object graph, OutputStream stream) throws Exception {
+ assertEquals(B.class, graph.getClass());
+ PrintWriter pw = new PrintWriter(new OutputStreamWriter(stream));
+ pw.print("<fooResponse/>");
+ pw.close();
+ }
+ @Override
+ public Object unmarshal(Exchange exchange, InputStream stream) throws Exception {
+ BufferedReader br = new BufferedReader(new InputStreamReader(stream));
+ assertEquals("<foo/>", br.readLine());
+ return new A();
+ }
+ };
+ }
+ }
+
+ public static class A { }
+ public static class B { }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/7ba090f5/camel-core/src/test/java/org/apache/camel/impl/transformer/TransformerRouteTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/impl/transformer/TransformerRouteTest.java b/camel-core/src/test/java/org/apache/camel/impl/transformer/TransformerRouteTest.java
new file mode 100644
index 0000000..29bd215
--- /dev/null
+++ b/camel-core/src/test/java/org/apache/camel/impl/transformer/TransformerRouteTest.java
@@ -0,0 +1,349 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.impl.transformer;
+
+import java.io.BufferedReader;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
+import java.util.Map;
+
+import org.apache.camel.AsyncCallback;
+import org.apache.camel.Consumer;
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.Converter;
+import org.apache.camel.Endpoint;
+import org.apache.camel.Exchange;
+import org.apache.camel.ExchangePattern;
+import org.apache.camel.Message;
+import org.apache.camel.Processor;
+import org.apache.camel.Producer;
+import org.apache.camel.TypeConverters;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.impl.DefaultAsyncProducer;
+import org.apache.camel.impl.DefaultComponent;
+import org.apache.camel.impl.DefaultEndpoint;
+import org.apache.camel.impl.DefaultExchange;
+import org.apache.camel.model.DataFormatDefinition;
+import org.apache.camel.model.transformer.CustomTransformerDefinition;
+import org.apache.camel.model.transformer.DataFormatTransformerDefinition;
+import org.apache.camel.model.transformer.EndpointTransformerDefinition;
+import org.apache.camel.spi.DataFormat;
+import org.apache.camel.spi.DataType;
+import org.apache.camel.spi.RouteContext;
+import org.apache.camel.spi.Transformer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * A TransformerTest demonstrates contract based declarative transformation via Java DSL.
+ */
+public class TransformerRouteTest extends ContextTestSupport {
+
+ protected static final Logger LOG = LoggerFactory.getLogger(TransformerRouteTest.class);
+
+ public void testJavaTransformer() throws Exception {
+ MockEndpoint abcresult = getMockEndpoint("mock:abcresult");
+ abcresult.expectedMessageCount(1);
+ abcresult.whenAnyExchangeReceived(new Processor() {
+ @Override
+ public void process(Exchange exchange) throws Exception {
+ LOG.info("Asserting String -> XOrderResponse convertion");
+ assertEquals(XOrderResponse.class, exchange.getIn().getBody().getClass());
+ }
+
+ });
+
+ MockEndpoint xyzresult = getMockEndpoint("mock:xyzresult");
+ xyzresult.expectedMessageCount(1);
+ xyzresult.whenAnyExchangeReceived(new Processor() {
+ @Override
+ public void process(Exchange exchange) throws Exception {
+ LOG.info("Asserting String -> XOrderResponse convertion is not yet performed");
+ assertEquals("response", exchange.getIn().getBody());
+ }
+ });
+
+ Exchange exchange = new DefaultExchange(context, ExchangePattern.InOut);
+ exchange.getIn().setBody(new AOrder());
+ Exchange answerEx = template.send("direct:abc", exchange);
+ if (answerEx.getException() != null) {
+ throw answerEx.getException();
+ }
+ assertEquals(AOrderResponse.class, answerEx.getOut().getBody().getClass());
+ assertMockEndpointsSatisfied();
+ }
+
+ public void testDataFormatTransformer() throws Exception {
+ MockEndpoint xyzresult = getMockEndpoint("mock:xyzresult");
+ xyzresult.expectedMessageCount(1);
+ xyzresult.whenAnyExchangeReceived(new Processor() {
+ @Override
+ public void process(Exchange exchange) throws Exception {
+ LOG.info("Asserting String -> XOrderResponse convertion is not yet performed");
+ assertEquals("response", exchange.getIn().getBody());
+ }
+ });
+
+ Exchange exchange = new DefaultExchange(context, ExchangePattern.InOut);
+ exchange.getIn().setBody("{name:XOrder}");
+ Exchange answerEx = template.send("direct:dataFormat", exchange);
+ if (answerEx.getException() != null) {
+ throw answerEx.getException();
+ }
+ assertEquals("{name:XOrderResponse}", answerEx.getOut().getBody(String.class));
+ assertMockEndpointsSatisfied();
+ }
+
+ public void testEndpointTransformer() throws Exception {
+ MockEndpoint xyzresult = getMockEndpoint("mock:xyzresult");
+ xyzresult.expectedMessageCount(1);
+ xyzresult.whenAnyExchangeReceived(new Processor() {
+ @Override
+ public void process(Exchange exchange) throws Exception {
+ LOG.info("Asserting String -> XOrderResponse convertion is not yet performed");
+ assertEquals("response", exchange.getIn().getBody());
+ }
+ });
+
+ Exchange exchange = new DefaultExchange(context, ExchangePattern.InOut);
+ exchange.getIn().setBody("<XOrder/>");
+ Exchange answerEx = template.send("direct:endpoint", exchange);
+ if (answerEx.getException() != null) {
+ throw answerEx.getException();
+ }
+ assertEquals("<XOrderResponse/>", answerEx.getOut().getBody(String.class));
+ assertMockEndpointsSatisfied();
+ }
+
+ public void testCustomTransformer() throws Exception {
+ MockEndpoint xyzresult = getMockEndpoint("mock:xyzresult");
+ xyzresult.expectedMessageCount(1);
+ xyzresult.whenAnyExchangeReceived(new Processor() {
+ @Override
+ public void process(Exchange exchange) throws Exception {
+ LOG.info("Asserting String -> XOrderResponse convertion is not yet performed");
+ assertEquals("response", exchange.getIn().getBody());
+ }
+ });
+
+ Exchange exchange = new DefaultExchange(context, ExchangePattern.InOut);
+ exchange.getIn().setBody("name=XOrder");
+ Exchange answerEx = template.send("direct:custom", exchange);
+ if (answerEx.getException() != null) {
+ throw answerEx.getException();
+ }
+ assertEquals("name=XOrderResponse", answerEx.getOut().getBody(String.class));
+ assertMockEndpointsSatisfied();
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+ context.getTypeConverterRegistry().addTypeConverters(new MyTypeConverters());
+ from("direct:abc")
+ .inputType(AOrder.class)
+ .outputType(AOrderResponse.class)
+ .process(new Processor() {
+ public void process(Exchange exchange) throws Exception {
+ LOG.info("Asserting input -> AOrder convertion");
+ assertEquals(AOrder.class, exchange.getIn().getBody().getClass());
+ }
+ })
+ .inOut("direct:xyz")
+ .to("mock:abcresult");
+
+ from("direct:xyz")
+ .inputType(XOrder.class)
+ .outputType(XOrderResponse.class)
+ .process(new Processor() {
+ public void process(Exchange exchange) throws Exception {
+ LOG.info("Asserting input -> XOrder convertion");
+ assertEquals(XOrder.class, exchange.getIn().getBody().getClass());
+ exchange.getIn().setBody("response");
+ }
+ }).to("mock:xyzresult");
+
+ DataFormatTransformerDefinition dfdef = new DataFormatTransformerDefinition();
+ dfdef.setDataFormatType(new MyJsonDataFormatDefinition());
+ dfdef.setScheme("json");
+ context.getTransformers().add(dfdef);
+ from("direct:dataFormat")
+ .inputType("json:JsonXOrder")
+ .outputType("json:JsonXOrderResponse")
+ .inOut("direct:xyz");
+
+ context.addComponent("myxml", new MyXmlComponent());
+ EndpointTransformerDefinition edef1 = new EndpointTransformerDefinition();
+ edef1.setUri("myxml:endpoint");
+ edef1.setFrom("xml:XmlXOrder");
+ edef1.setTo(XOrder.class);
+ EndpointTransformerDefinition edef2 = new EndpointTransformerDefinition();
+ edef2.setUri("myxml:endpoint");
+ edef2.setFrom(XOrderResponse.class);
+ edef2.setTo("xml:XmlXOrderResponse");
+ context.getTransformers().add(edef1);
+ context.getTransformers().add(edef2);
+ from("direct:endpoint")
+ .inputType("xml:XmlXOrder")
+ .outputType("xml:XmlXOrderResponse")
+ .inOut("direct:xyz");
+
+ CustomTransformerDefinition bdef1 = new CustomTransformerDefinition();
+ bdef1.setType(OtherToXOrderTransformer.class.getName());
+ bdef1.setFrom("other:OtherXOrder");
+ bdef1.setTo(XOrder.class);
+ CustomTransformerDefinition bdef2 = new CustomTransformerDefinition();
+ bdef2.setType(XOrderResponseToOtherTransformer.class.getName());
+ bdef2.setFrom(XOrderResponse.class);
+ bdef2.setTo("other:OtherXOrderResponse");
+ context.getTransformers().add(bdef1);
+ context.getTransformers().add(bdef2);
+ from("direct:custom")
+ .inputType("other:OtherXOrder")
+ .outputType("other:OtherXOrderResponse")
+ .inOut("direct:xyz");
+ }
+ };
+ }
+
+ public static class MyTypeConverters implements TypeConverters {
+ @Converter
+ public AOrder toAOrder(String order) {
+ LOG.info("TypeConverter: String -> AOrder");
+ return new AOrder();
+ }
+
+ @Converter
+ public XOrder toXOrder(AOrder aorder) {
+ LOG.info("TypeConverter: AOrder -> XOrder");
+ return new XOrder();
+ }
+
+ @Converter
+ public XOrderResponse toXOrderResponse(String res) {
+ LOG.info("TypeConverter: String -> XOrderResponse");
+ return new XOrderResponse();
+ }
+
+ @Converter
+ public AOrderResponse toAOrderResponse(XOrderResponse xres) {
+ LOG.info("TypeConverter: XOrderResponse -> AOrderResponse");
+ return new AOrderResponse();
+ }
+ }
+
+ public static class MyJsonDataFormatDefinition extends DataFormatDefinition {
+ public static DataFormat getDataFormat(RouteContext routeContext, DataFormatDefinition type, String ref) {
+ return new MyJsonDataFormatDefinition().createDataFormat();
+ }
+ public DataFormat getDataFormat(RouteContext routeContext) {
+ return createDataFormat();
+ }
+ private DataFormat createDataFormat() {
+ return new DataFormat() {
+ @Override
+ public void marshal(Exchange exchange, Object graph, OutputStream stream) throws Exception {
+ assertEquals(graph.toString(), XOrderResponse.class, graph.getClass());
+ LOG.info("DataFormat: XOrderResponse -> JSON");
+ stream.write("{name:XOrderResponse}".getBytes());
+ }
+ @Override
+ public Object unmarshal(Exchange exchange, InputStream stream) throws Exception {
+ BufferedReader reader = new BufferedReader(new InputStreamReader(stream));
+ String line = "";
+ String input = "";
+ while ((line = reader.readLine()) != null) {
+ input += line;
+ }
+ reader.close();
+ assertEquals("{name:XOrder}", input);
+ LOG.info("DataFormat: JSON -> XOrder");
+ return new XOrder();
+ }
+ };
+ }
+ }
+
+ public static class MyXmlComponent extends DefaultComponent {
+ @Override
+ protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception {
+ return new MyXmlEndpoint();
+ }
+
+ }
+
+ public static class MyXmlEndpoint extends DefaultEndpoint {
+ @Override
+ public Producer createProducer() throws Exception {
+ return new DefaultAsyncProducer(this) {
+ @Override
+ public boolean process(Exchange exchange, AsyncCallback callback) {
+ Object input = exchange.getIn().getBody();
+ if (input instanceof XOrderResponse) {
+ LOG.info("Endpoint: XOrderResponse -> XML");
+ exchange.getIn().setBody("<XOrderResponse/>");
+ } else {
+ assertEquals("<XOrder/>", input);
+ LOG.info("Endpoint: XML -> XOrder");
+ exchange.getIn().setBody(new XOrder());
+
+ }
+ callback.done(true);
+ return true;
+ }
+ };
+ }
+ @Override
+ public Consumer createConsumer(Processor processor) throws Exception {
+ return null;
+ }
+ @Override
+ public boolean isSingleton() {
+ return false;
+ }
+ @Override
+ protected String createEndpointUri() {
+ return "myxml:endpoint";
+ }
+ }
+
+ public static class OtherToXOrderTransformer extends Transformer {
+ @Override
+ public void transform(Message message, DataType from, DataType to) throws Exception {
+ assertEquals("name=XOrder", message.getBody());
+ LOG.info("Bean: Other -> XOrder");
+ message.setBody(new XOrder());
+ }
+ }
+
+ public static class XOrderResponseToOtherTransformer extends Transformer {
+ @Override
+ public void transform(Message message, DataType from, DataType to) throws Exception {
+ LOG.info("Bean: XOrderResponse -> Other");
+ message.setBody("name=XOrderResponse");
+ }
+ }
+
+ public static class AOrder { }
+ public static class AOrderResponse { }
+ public static class XOrder { }
+ public static class XOrderResponse { }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/7ba090f5/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/CamelContextFactoryBean.java
----------------------------------------------------------------------
diff --git a/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/CamelContextFactoryBean.java b/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/CamelContextFactoryBean.java
index 6802312..59e9f38 100644
--- a/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/CamelContextFactoryBean.java
+++ b/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/CamelContextFactoryBean.java
@@ -65,6 +65,7 @@ import org.apache.camel.model.remote.KubernetesConfigurationDefinition;
import org.apache.camel.model.remote.RibbonConfigurationDefinition;
import org.apache.camel.model.rest.RestConfigurationDefinition;
import org.apache.camel.model.rest.RestDefinition;
+import org.apache.camel.model.transformer.TransformersDefinition;
import org.apache.camel.spi.PackageScanFilter;
import org.apache.camel.spi.Registry;
import org.osgi.framework.BundleContext;
@@ -173,6 +174,8 @@ public class CamelContextFactoryBean extends AbstractCamelContextFactoryBean<Blu
private List<CamelEndpointFactoryBean> endpoints;
@XmlElement(name = "dataFormats")
private DataFormatsDefinition dataFormats;
+ @XmlElement(name = "transformers")
+ private TransformersDefinition transformers;
@XmlElement(name = "redeliveryPolicyProfile")
private List<CamelRedeliveryPolicyFactoryBean> redeliveryPolicies;
@XmlElement(name = "onException")
@@ -645,6 +648,14 @@ public class CamelContextFactoryBean extends AbstractCamelContextFactoryBean<Blu
this.dataFormats = dataFormats;
}
+ public void setTransformers(TransformersDefinition transformers) {
+ this.transformers = transformers;
+ }
+
+ public TransformersDefinition getTransformers() {
+ return transformers;
+ }
+
public List<OnExceptionDefinition> getOnExceptions() {
return onExceptions;
}
http://git-wip-us.apache.org/repos/asf/camel/blob/7ba090f5/components/camel-cdi/src/main/java/org/apache/camel/cdi/xml/CamelContextFactoryBean.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/main/java/org/apache/camel/cdi/xml/CamelContextFactoryBean.java b/components/camel-cdi/src/main/java/org/apache/camel/cdi/xml/CamelContextFactoryBean.java
index c75d30b..9299424 100644
--- a/components/camel-cdi/src/main/java/org/apache/camel/cdi/xml/CamelContextFactoryBean.java
+++ b/components/camel-cdi/src/main/java/org/apache/camel/cdi/xml/CamelContextFactoryBean.java
@@ -60,6 +60,7 @@ import org.apache.camel.model.ThreadPoolProfileDefinition;
import org.apache.camel.model.dataformat.DataFormatsDefinition;
import org.apache.camel.model.rest.RestConfigurationDefinition;
import org.apache.camel.model.rest.RestDefinition;
+import org.apache.camel.model.transformer.TransformersDefinition;
import org.apache.camel.spi.PackageScanFilter;
@XmlRootElement(name = "camelContext")
@@ -189,6 +190,9 @@ public class CamelContextFactoryBean extends AbstractCamelContextFactoryBean<Def
@XmlElement(name = "dataFormats")
private DataFormatsDefinition dataFormats;
+ @XmlElement(name = "transformers")
+ private TransformersDefinition transformers;
+
@XmlElement(name = "redeliveryPolicyProfile")
private List<RedeliveryPolicyFactoryBean> redeliveryPolicies;
@@ -639,6 +643,14 @@ public class CamelContextFactoryBean extends AbstractCamelContextFactoryBean<Def
this.dataFormats = dataFormats;
}
+ public TransformersDefinition getTransformers() {
+ return transformers;
+ }
+
+ public void setTransformers(TransformersDefinition transformers) {
+ this.transformers = transformers;
+ }
+
public List<OnExceptionDefinition> getOnExceptions() {
return onExceptions;
}
http://git-wip-us.apache.org/repos/asf/camel/blob/7ba090f5/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelContextFactoryBean.java
----------------------------------------------------------------------
diff --git a/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelContextFactoryBean.java b/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelContextFactoryBean.java
index fe5b826..a4bb342 100644
--- a/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelContextFactoryBean.java
+++ b/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelContextFactoryBean.java
@@ -70,6 +70,7 @@ import org.apache.camel.model.dataformat.DataFormatsDefinition;
import org.apache.camel.model.rest.RestConfigurationDefinition;
import org.apache.camel.model.rest.RestContainer;
import org.apache.camel.model.rest.RestDefinition;
+import org.apache.camel.model.transformer.TransformersDefinition;
import org.apache.camel.processor.interceptor.BacklogTracer;
import org.apache.camel.processor.interceptor.HandleFault;
import org.apache.camel.processor.interceptor.TraceFormatter;
@@ -760,6 +761,8 @@ public abstract class AbstractCamelContextFactoryBean<T extends ModelCamelContex
public abstract DataFormatsDefinition getDataFormats();
+ public abstract TransformersDefinition getTransformers();
+
public abstract List<OnExceptionDefinition> getOnExceptions();
public abstract List<OnCompletionDefinition> getOnCompletions();
@@ -833,6 +836,9 @@ public abstract class AbstractCamelContextFactoryBean<T extends ModelCamelContex
if (getDataFormats() != null) {
ctx.setDataFormats(getDataFormats().asMap());
}
+ if (getTransformers() != null) {
+ ctx.setTransformers(getTransformers().getTransforms());
+ }
if (getTypeConverterStatisticsEnabled() != null) {
ctx.setTypeConverterStatisticsEnabled(getTypeConverterStatisticsEnabled());
}
http://git-wip-us.apache.org/repos/asf/camel/blob/7ba090f5/components/camel-spring/src/main/java/org/apache/camel/spring/CamelContextFactoryBean.java
----------------------------------------------------------------------
diff --git a/components/camel-spring/src/main/java/org/apache/camel/spring/CamelContextFactoryBean.java b/components/camel-spring/src/main/java/org/apache/camel/spring/CamelContextFactoryBean.java
index 651f280..9e11f6c 100644
--- a/components/camel-spring/src/main/java/org/apache/camel/spring/CamelContextFactoryBean.java
+++ b/components/camel-spring/src/main/java/org/apache/camel/spring/CamelContextFactoryBean.java
@@ -64,6 +64,7 @@ import org.apache.camel.model.remote.KubernetesConfigurationDefinition;
import org.apache.camel.model.remote.RibbonConfigurationDefinition;
import org.apache.camel.model.rest.RestConfigurationDefinition;
import org.apache.camel.model.rest.RestDefinition;
+import org.apache.camel.model.transformer.TransformersDefinition;
import org.apache.camel.spi.Metadata;
import org.apache.camel.spi.PackageScanFilter;
import org.apache.camel.spi.Registry;
@@ -182,6 +183,8 @@ public class CamelContextFactoryBean extends AbstractCamelContextFactoryBean<Spr
private List<CamelEndpointFactoryBean> endpoints;
@XmlElement(name = "dataFormats")
private DataFormatsDefinition dataFormats;
+ @XmlElement(name = "transformers")
+ private TransformersDefinition transformers;
@XmlElement(name = "redeliveryPolicyProfile")
private List<CamelRedeliveryPolicyFactoryBean> redeliveryPolicies;
@XmlElement(name = "onException")
@@ -875,6 +878,17 @@ public class CamelContextFactoryBean extends AbstractCamelContextFactoryBean<Spr
}
/**
+ * Configuration of transformers.
+ */
+ public void setTransformers(TransformersDefinition transformers) {
+ this.transformers = transformers;
+ }
+
+ public TransformersDefinition getTransformers() {
+ return transformers;
+ }
+
+ /**
* Configuration of redelivery settings.
*/
public void setRedeliveryPolicies(List<CamelRedeliveryPolicyFactoryBean> redeliveryPolicies) {
http://git-wip-us.apache.org/repos/asf/camel/blob/7ba090f5/components/camel-spring/src/main/java/org/apache/camel/spring/handler/CamelNamespaceHandler.java
----------------------------------------------------------------------
diff --git a/components/camel-spring/src/main/java/org/apache/camel/spring/handler/CamelNamespaceHandler.java b/components/camel-spring/src/main/java/org/apache/camel/spring/handler/CamelNamespaceHandler.java
index 945c2e9..68ae70d 100644
--- a/components/camel-spring/src/main/java/org/apache/camel/spring/handler/CamelNamespaceHandler.java
+++ b/components/camel-spring/src/main/java/org/apache/camel/spring/handler/CamelNamespaceHandler.java
@@ -393,6 +393,7 @@ public class CamelNamespaceHandler extends NamespaceHandlerSupport {
builder.addPropertyValue("interceptFroms", factoryBean.getInterceptFroms());
builder.addPropertyValue("interceptSendToEndpoints", factoryBean.getInterceptSendToEndpoints());
builder.addPropertyValue("dataFormats", factoryBean.getDataFormats());
+ builder.addPropertyValue("transformers", factoryBean.getTransformers());
builder.addPropertyValue("onCompletions", factoryBean.getOnCompletions());
builder.addPropertyValue("onExceptions", factoryBean.getOnExceptions());
builder.addPropertyValue("builderRefs", factoryBean.getBuilderRefs());
http://git-wip-us.apache.org/repos/asf/camel/blob/7ba090f5/components/camel-spring/src/test/java/org/apache/camel/spring/impl/transformer/SpringTransformerRouteTest.java
----------------------------------------------------------------------
diff --git a/components/camel-spring/src/test/java/org/apache/camel/spring/impl/transformer/SpringTransformerRouteTest.java b/components/camel-spring/src/test/java/org/apache/camel/spring/impl/transformer/SpringTransformerRouteTest.java
new file mode 100644
index 0000000..b075c59
--- /dev/null
+++ b/components/camel-spring/src/test/java/org/apache/camel/spring/impl/transformer/SpringTransformerRouteTest.java
@@ -0,0 +1,48 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.spring.impl.transformer;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.impl.transformer.TransformerRouteTest;
+
+import static org.apache.camel.spring.processor.SpringTestHelper.createSpringCamelContext;
+
+/**
+ * A TransformerTest demonstrates contract based declarative transformation via Spring DSL.
+ */
+public class SpringTransformerRouteTest extends TransformerRouteTest {
+
+ protected CamelContext createCamelContext() throws Exception {
+ return createSpringCamelContext(this, "org/apache/camel/spring/impl/transformer/SpringTransformerRouteTest.xml");
+ }
+
+ public static class MyXmlProcessor implements Processor {
+ public void process(Exchange exchange) {
+ Object input = exchange.getIn().getBody();
+ if (input instanceof XOrderResponse) {
+ LOG.info("Endpoint: XOrderResponse -> XML");
+ exchange.getIn().setBody("<XOrderResponse/>");
+ } else {
+ assertEquals("<XOrder/>", input);
+ LOG.info("Endpoint: XML -> XOrder");
+ exchange.getIn().setBody(new XOrder());
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/7ba090f5/components/camel-spring/src/test/resources/org/apache/camel/spring/impl/transformer/SpringTransformerRouteTest.xml
----------------------------------------------------------------------
diff --git a/components/camel-spring/src/test/resources/org/apache/camel/spring/impl/transformer/SpringTransformerRouteTest.xml b/components/camel-spring/src/test/resources/org/apache/camel/spring/impl/transformer/SpringTransformerRouteTest.xml
new file mode 100644
index 0000000..d8b4f72
--- /dev/null
+++ b/components/camel-spring/src/test/resources/org/apache/camel/spring/impl/transformer/SpringTransformerRouteTest.xml
@@ -0,0 +1,97 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<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.xsd
+ http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
+ ">
+
+ <bean id="myTypeConverters" class="org.apache.camel.impl.transformer.TransformerRouteTest$MyTypeConverters"/>
+ <bean id="myJsonDataFormatDef" class="org.apache.camel.impl.transformer.TransformerRouteTest$MyJsonDataFormatDefinition"/>
+ <bean id="myXmlProcessor" class="org.apache.camel.spring.impl.transformer.SpringTransformerRouteTest$MyXmlProcessor"/>
+ <bean id="otherToXOrder" class="org.apache.camel.impl.transformer.TransformerRouteTest$OtherToXOrderTransformer"/>
+ <bean id="xOrderResponseToOther" class="org.apache.camel.impl.transformer.TransformerRouteTest$XOrderResponseToOtherTransformer"/>
+
+ <camelContext xmlns="http://camel.apache.org/schema/spring">
+
+ <endpoint id="myXmlEndpoint" uri="direct:endpointXmlTransformer"/>
+
+ <transformers>
+ <dataFormatTransformer scheme="json">
+ <custom ref="myJsonDataFormatDef"/>
+ </dataFormatTransformer>
+ <endpointTransformer ref="myXmlEndpoint" from="xml:XmlXOrder" to="java:org.apache.camel.impl.transformer.TransformerRouteTest$XOrder"/>
+ <endpointTransformer ref="myXmlEndpoint" from="java:org.apache.camel.impl.transformer.TransformerRouteTest$XOrderResponse" to="xml:XmlXOrderResponse"/>
+ <customTransformer ref="otherToXOrder" from="other:OtherXOrder" to="java:org.apache.camel.impl.transformer.TransformerRouteTest$XOrder"/>
+ <customTransformer ref="xOrderResponseToOther" from="java:org.apache.camel.impl.transformer.TransformerRouteTest$XOrderResponse" to="other:OtherXOrderResponse"/>
+ </transformers>
+
+ <route>
+ <from uri="direct:abc"/>
+ <inputType urn="java:org.apache.camel.impl.transformer.TransformerRouteTest$AOrder"/>
+ <outputType urn="java:org.apache.camel.impl.transformer.TransformerRouteTest$AOrderResponse"/>
+ <when>
+ <simple>${body} not is 'org.apache.camel.impl.transformer.TransformerRouteTest\\$AOrder'</simple>
+ <throwException exceptionType="java.lang.Exception" message="expected AOrder object but was '${body}'"/>
+ </when>
+ <inOut uri="direct:xyz"/>
+ <to uri="mock:abcresult"/>
+ </route>
+
+ <route>
+ <from uri="direct:xyz"/>
+ <inputType urn="java:org.apache.camel.impl.transformer.TransformerRouteTest$XOrder"/>
+ <outputType urn="java:org.apache.camel.impl.transformer.TransformerRouteTest$XOrderResponse"/>
+ <when>
+ <simple>${body} not is 'org.apache.camel.impl.transformer.TransformerRouteTest\\$XOrder'</simple>
+ <throwException exceptionType="java.lang.Exception" message="expected XOrder object but was '${body}'"/>
+ </when>
+ <setBody><constant>response</constant></setBody>
+ <to uri="mock:xyzresult"/>
+ </route>
+
+ <route>
+ <from uri="direct:dataFormat"/>
+ <inputType urn="json:JsonXOrder"/>
+ <outputType urn="json:JsonXOrderResponse"/>
+ <inOut uri="direct:xyz"/>
+ </route>
+
+ <route>
+ <from uri="direct:endpoint"/>
+ <inputType urn="xml:XmlXOrder"/>
+ <outputType urn="xml:XmlXOrderResponse"/>
+ <inOut uri="direct:xyz"/>
+ </route>
+
+ <route>
+ <from uri="direct:endpointXmlTransformer"/>
+ <process ref="myXmlProcessor"/>
+ </route>
+
+ <route>
+ <from uri="direct:custom"/>
+ <inputType urn="other:OtherXOrder"/>
+ <outputType urn="other:OtherXOrderResponse"/>
+ <inOut uri="direct:xyz"/>
+ </route>
+
+ </camelContext>
+
+</beans>
http://git-wip-us.apache.org/repos/asf/camel/blob/7ba090f5/examples/README.md
----------------------------------------------------------------------
diff --git a/examples/README.md b/examples/README.md
index 923e6b7..1e3d97d 100644
--- a/examples/README.md
+++ b/examples/README.md
@@ -119,6 +119,11 @@ All examples have been sort by type/category
* [camel-example-cxf-proxy](camel-example-cxf-proxy/README.md)
* [camel-example-cxf-tomcat](camel-example-cxf-tomcat/README.md)
+##### Input/Output type contract
+* [camel-example-transformer-blueprint](camel-example-transformer-blueprint/README.md)
+* [camel-example-transformer-cdi](camel-example-transformer-cdi/README.md)
+* [camel-example-transformer-demo](camel-example-transformer-demo/README.md)
+
### Documentation
They are described in detail here <http://camel.apache.org/examples.html>
http://git-wip-us.apache.org/repos/asf/camel/blob/7ba090f5/examples/camel-example-transformer-blueprint/README.md
----------------------------------------------------------------------
diff --git a/examples/camel-example-transformer-blueprint/README.md b/examples/camel-example-transformer-blueprint/README.md
new file mode 100644
index 0000000..9907c9c
--- /dev/null
+++ b/examples/camel-example-transformer-blueprint/README.md
@@ -0,0 +1,51 @@
+# Declarative Transformer example using Blueprint XML
+
+
+### Introduction
+
+This example shows how to work with declarative transformation by declaring data types.
+
+### Build
+
+You will need to compile this example first:
+
+ mvn compile
+
+### Run without container
+
+To run the example, type
+
+ mvn camel:run
+
+To stop the example hit <kbd>ctrl</kbd>+<kbd>c</kbd>.
+
+### Run on karaf container
+
+To run the example on the karaf container
+
+#### Step 1: Start karaf container
+
+ karaf / karaf.bat
+
+#### Step 2: Deploy
+
+ feature:repo-add feature:repo-add mvn:org.apache.camel/camel-example-transformer-blueprint/${version}/xml/features
+ feature:install camel-example-transformer-blueprint
+
+#### Step 3: Check the output
+
+You will see the output in ${karaf}/data/karaf.log
+
+You can see the routing rules by looking at the Blueprint XML configuration lives in
+`src/main/resources/OSGI-INF/blueprint`
+
+### Forum, Help, etc
+
+If you hit an problems please let us know on the Camel Forums
+ <http://camel.apache.org/discussion-forums.html>
+
+Please help us make Apache Camel better - we appreciate any feedback you may
+have. Enjoy!
+
+
+The Camel riders!
http://git-wip-us.apache.org/repos/asf/camel/blob/7ba090f5/examples/camel-example-transformer-blueprint/pom.xml
----------------------------------------------------------------------
diff --git a/examples/camel-example-transformer-blueprint/pom.xml b/examples/camel-example-transformer-blueprint/pom.xml
new file mode 100644
index 0000000..7a5df6d
--- /dev/null
+++ b/examples/camel-example-transformer-blueprint/pom.xml
@@ -0,0 +1,121 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>examples</artifactId>
+ <version>2.19.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>camel-example-transformer-blueprint</artifactId>
+ <packaging>bundle</packaging>
+ <name>Camel :: Example :: Transformer :: Blueprint</name>
+ <description>An example demonstrating declarative transformation along data type declaration using Blueprint DSL
+ </description>
+
+ <dependencies>
+ <!-- START SNIPPET: e1 -->
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-blueprint</artifactId>
+ </dependency>
+
+ <!-- logging -->
+ <dependency>
+ <groupId>org.apache.logging.log4j</groupId>
+ <artifactId>log4j-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.logging.log4j</groupId>
+ <artifactId>log4j-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.logging.log4j</groupId>
+ <artifactId>log4j-slf4j-impl</artifactId>
+ </dependency>
+
+ <!-- for testing -->
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-test-blueprint</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>xmlunit</groupId>
+ <artifactId>xmlunit</artifactId>
+ <scope>test</scope>
+ <version>1.6</version>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>build-helper-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>attach-artifacts</id>
+ <phase>package</phase>
+ <goals>
+ <goal>attach-artifact</goal>
+ </goals>
+ <configuration>
+ <artifacts>
+ <artifact>
+ <file>target/classes/features.xml</file>
+ <type>xml</type>
+ <classifier>features</classifier>
+ </artifact>
+ </artifacts>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <extensions>true</extensions>
+ <configuration>
+ <instructions>
+ <Bundle-SymbolicName>${project.groupId}.${project.artifactId}</Bundle-SymbolicName>
+ <Export-Package>${camel.osgi.export.pkg}</Export-Package>
+ <Import-Package>*</Import-Package>
+ </instructions>
+ </configuration>
+ </plugin>
+
+ <!-- Allows the routes to be run via 'mvn camel:run' -->
+ <plugin>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-maven-plugin</artifactId>
+ <version>${project.version}</version>
+ </plugin>
+
+ </plugins>
+ </build>
+
+</project>
http://git-wip-us.apache.org/repos/asf/camel/blob/7ba090f5/examples/camel-example-transformer-blueprint/src/main/resources/OSGI-INF/blueprint/camel-context.xml
----------------------------------------------------------------------
diff --git a/examples/camel-example-transformer-blueprint/src/main/resources/OSGI-INF/blueprint/camel-context.xml b/examples/camel-example-transformer-blueprint/src/main/resources/OSGI-INF/blueprint/camel-context.xml
new file mode 100644
index 0000000..67e3373
--- /dev/null
+++ b/examples/camel-example-transformer-blueprint/src/main/resources/OSGI-INF/blueprint/camel-context.xml
@@ -0,0 +1,53 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0 https://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd">
+
+ <camelContext id="TransformerBlueprint" xmlns="http://camel.apache.org/schema/blueprint">
+
+ <!-- START SNIPPET: e1 -->
+ <transformers>
+ <endpointTransformer uri="xslt:transform.xsl" from="xml:MyRequest" to="xml:MyResponse"/>
+ </transformers>
+ <!-- END SNIPPET: e1 -->
+
+ <!-- START SNIPPET: e2 -->
+ <route id="timer-route">
+ <from uri="timer:foo?period=5s"/>
+ <log message="start -->"/>
+ <setBody><constant><MyRequest>foobar</MyRequest></constant></setBody>
+ <log message="--> Sending:[${body}]"/>
+ <to uri="direct:a"/>
+ <log message="--> Received:[${body}]"/>
+ <log message="<-- end"/>
+ </route>
+ <!-- END SNIPPET: e2 -->
+
+ <!-- START SNIPPET: e3 -->
+ <route id="xslt-route">
+ <from uri="direct:a"/>
+ <inputType urn="xml:MyRequest"/>
+ <outputType urn="xml:MyResponse"/>
+ <log message="----> Received:[${body}]"/>
+ </route>
+ <!-- END SNIPPET: e3 -->
+
+ </camelContext>
+
+</blueprint>
http://git-wip-us.apache.org/repos/asf/camel/blob/7ba090f5/examples/camel-example-transformer-blueprint/src/main/resources/features.xml
----------------------------------------------------------------------
diff --git a/examples/camel-example-transformer-blueprint/src/main/resources/features.xml b/examples/camel-example-transformer-blueprint/src/main/resources/features.xml
new file mode 100644
index 0000000..92c60b3
--- /dev/null
+++ b/examples/camel-example-transformer-blueprint/src/main/resources/features.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<features xmlns="http://karaf.apache.org/xmlns/features/v1.0.0" name="camel-example-transformer-blueprint">
+ <repository>mvn:org.apache.camel.karaf/apache-camel/${project.version}/xml/features</repository>
+
+ <feature name='camel-example-transformer-blueprint' version='${project.version}'>
+ <feature version="${project.version}">camel</feature>
+ <feature version="${project.version}">camel-blueprint</feature>
+ <bundle>mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.xalan/${xalan-bundle-version}</bundle>
+ <bundle>mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.bcel/${bcel-bundle-version}</bundle>
+ <bundle>mvn:org.apache.camel/camel-example-transformer-blueprint/${project.version}</bundle>
+ </feature>
+
+</features>
http://git-wip-us.apache.org/repos/asf/camel/blob/7ba090f5/examples/camel-example-transformer-blueprint/src/main/resources/log4j2.properties
----------------------------------------------------------------------
diff --git a/examples/camel-example-transformer-blueprint/src/main/resources/log4j2.properties b/examples/camel-example-transformer-blueprint/src/main/resources/log4j2.properties
new file mode 100644
index 0000000..a1e0d92
--- /dev/null
+++ b/examples/camel-example-transformer-blueprint/src/main/resources/log4j2.properties
@@ -0,0 +1,28 @@
+## ---------------------------------------------------------------------------
+## Licensed to the Apache Software Foundation (ASF) under one or more
+## contributor license agreements. See the NOTICE file distributed with
+## this work for additional information regarding copyright ownership.
+## The ASF licenses this file to You under the Apache License, Version 2.0
+## (the "License"); you may not use this file except in compliance with
+## the License. You may obtain a copy of the License at
+##
+## http://www.apache.org/licenses/LICENSE-2.0
+##
+## Unless required by applicable law or agreed to in writing, software
+## distributed under the License is distributed on an "AS IS" BASIS,
+## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+## See the License for the specific language governing permissions and
+## limitations under the License.
+## ---------------------------------------------------------------------------
+
+appender.stdout.type = Console
+appender.stdout.name = stdout
+appender.stdout.layout.type = PatternLayout
+appender.stdout.layout.pattern = %d [%-15.15t] %-5p %-30.30c{1} - %m%n
+rootLogger.level = INFO
+rootLogger.appenderRef.stdout.ref = stdout
+
+#logger.transformer.name = org.apache.camel.impl.transformer
+#logger.transformer.level = DEBUG
+#logger.processor.name = org.apache.camel.processor
+#logger.processor.level = DEBUG
http://git-wip-us.apache.org/repos/asf/camel/blob/7ba090f5/examples/camel-example-transformer-blueprint/src/main/resources/transform.xsl
----------------------------------------------------------------------
diff --git a/examples/camel-example-transformer-blueprint/src/main/resources/transform.xsl b/examples/camel-example-transformer-blueprint/src/main/resources/transform.xsl
new file mode 100644
index 0000000..2f2e514
--- /dev/null
+++ b/examples/camel-example-transformer-blueprint/src/main/resources/transform.xsl
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="Shift_JIS"?>
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
+ <xsl:template match="@*|node()">
+ <xsl:copy>
+ <xsl:apply-templates select="@*|node()"/>
+ </xsl:copy>
+ </xsl:template>
+
+ <xsl:template match="MyRequest">
+ <MyResponse>
+ <xsl:apply-templates/>
+ </MyResponse>
+ </xsl:template>
+</xsl:stylesheet>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/camel/blob/7ba090f5/examples/camel-example-transformer-cdi/README.md
----------------------------------------------------------------------
diff --git a/examples/camel-example-transformer-cdi/README.md b/examples/camel-example-transformer-cdi/README.md
new file mode 100644
index 0000000..2f47539
--- /dev/null
+++ b/examples/camel-example-transformer-cdi/README.md
@@ -0,0 +1,37 @@
+# Declarative Transformer example using CDI
+
+
+### Introduction
+
+This example shows how to work with declarative transformation by declaring data types.
+
+### Build
+
+You will need to compile this example first:
+
+ mvn compile
+
+### Run
+
+To run the example type
+
+ mvn camel:run
+
+You can see the routing rules by looking at the java code in the
+`src/main/java` directory.
+
+To stop the example hit <kbd>ctrl</kbd>+<kbd>c</kbd>.
+
+When we launch the example using the Camel Maven plugin, a standalone CDI container
+is created and started.
+
+### Forum, Help, etc
+
+If you hit an problems please let us know on the Camel Forums
+ <http://camel.apache.org/discussion-forums.html>
+
+Please help us make Apache Camel better - we appreciate any feedback you may
+have. Enjoy!
+
+
+The Camel riders!
http://git-wip-us.apache.org/repos/asf/camel/blob/7ba090f5/examples/camel-example-transformer-cdi/pom.xml
----------------------------------------------------------------------
diff --git a/examples/camel-example-transformer-cdi/pom.xml b/examples/camel-example-transformer-cdi/pom.xml
new file mode 100644
index 0000000..10c178d
--- /dev/null
+++ b/examples/camel-example-transformer-cdi/pom.xml
@@ -0,0 +1,102 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>examples</artifactId>
+ <version>2.19.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>camel-example-transformer-cdi</artifactId>
+ <packaging>jar</packaging>
+ <name>Camel :: Example :: Transformer :: CDI</name>
+ <description>An example demonstrating declarative transformation along data type declaration using Java DSL and CDI
+ </description>
+
+ <dependencies>
+ <!-- START SNIPPET: e1 -->
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-cdi</artifactId>
+ </dependency>
+
+ <!-- logging -->
+ <dependency>
+ <groupId>org.apache.logging.log4j</groupId>
+ <artifactId>log4j-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.logging.log4j</groupId>
+ <artifactId>log4j-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.logging.log4j</groupId>
+ <artifactId>log4j-slf4j-impl</artifactId>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <plugins>
+ <!-- Allows the routes to be run via 'mvn camel:run' -->
+ <plugin>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-maven-plugin</artifactId>
+ <version>${project.version}</version>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.deltaspike.cdictrl</groupId>
+ <artifactId>deltaspike-cdictrl-weld</artifactId>
+ <version>${deltaspike-version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.weld.se</groupId>
+ <artifactId>weld-se</artifactId>
+ <version>${weld2-version}</version>
+ </dependency>
+ <!-- logging -->
+ <dependency>
+ <groupId>org.apache.logging.log4j</groupId>
+ <artifactId>log4j-api</artifactId>
+ <version>${log4j2-version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.logging.log4j</groupId>
+ <artifactId>log4j-core</artifactId>
+ <version>${log4j2-version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.logging.log4j</groupId>
+ <artifactId>log4j-slf4j-impl</artifactId>
+ <version>${log4j2-version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.logging.log4j</groupId>
+ <artifactId>log4j-1.2-api</artifactId>
+ <version>${log4j2-version}</version>
+ </dependency>
+ </dependencies>
+ </plugin>
+ </plugins>
+
+ </build>
+
+</project>
http://git-wip-us.apache.org/repos/asf/camel/blob/7ba090f5/examples/camel-example-transformer-cdi/src/main/java/org/apache/camel/example/transformer/cdi/MyRoutes.java
----------------------------------------------------------------------
diff --git a/examples/camel-example-transformer-cdi/src/main/java/org/apache/camel/example/transformer/cdi/MyRoutes.java b/examples/camel-example-transformer-cdi/src/main/java/org/apache/camel/example/transformer/cdi/MyRoutes.java
new file mode 100644
index 0000000..ee107a3
--- /dev/null
+++ b/examples/camel-example-transformer-cdi/src/main/java/org/apache/camel/example/transformer/cdi/MyRoutes.java
@@ -0,0 +1,56 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.example.transformer.cdi;
+
+import org.apache.camel.Endpoint;
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.model.dataformat.JaxbDataFormat;
+import org.apache.camel.model.transformer.DataFormatTransformerDefinition;
+import org.apache.camel.model.transformer.EndpointTransformerDefinition;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Configures all our Camel routes, components, endpoints and beans
+ */
+public class MyRoutes extends RouteBuilder {
+
+ @Override
+ public void configure() {
+ EndpointTransformerDefinition eptd = new EndpointTransformerDefinition();
+ eptd.setUri("xslt:transform.xsl");
+ eptd.setFrom("xml:MyRequest");
+ eptd.setTo("xml:MyResponse");
+ getContext().getTransformers().add(eptd);
+
+ from("timer:foo?period=5000").id("timer-route")
+ .log("start -->")
+ .setBody(constant("<MyRequest>foobar</MyRequest>"))
+ .log("--> Sending:[${body}]")
+ .to("direct:a")
+ .log("--> Received:[${body}]")
+ .log("<-- end");
+
+ from("direct:a").id("xslt-route")
+ .inputType("xml:MyRequest")
+ .outputType("xml:MyResponse")
+ .log("----> Received:[${body}]");
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/7ba090f5/examples/camel-example-transformer-cdi/src/main/resources/META-INF/LICENSE.txt
----------------------------------------------------------------------
diff --git a/examples/camel-example-transformer-cdi/src/main/resources/META-INF/LICENSE.txt b/examples/camel-example-transformer-cdi/src/main/resources/META-INF/LICENSE.txt
new file mode 100644
index 0000000..6b0b127
--- /dev/null
+++ b/examples/camel-example-transformer-cdi/src/main/resources/META-INF/LICENSE.txt
@@ -0,0 +1,203 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
http://git-wip-us.apache.org/repos/asf/camel/blob/7ba090f5/examples/camel-example-transformer-cdi/src/main/resources/META-INF/NOTICE.txt
----------------------------------------------------------------------
diff --git a/examples/camel-example-transformer-cdi/src/main/resources/META-INF/NOTICE.txt b/examples/camel-example-transformer-cdi/src/main/resources/META-INF/NOTICE.txt
new file mode 100644
index 0000000..2e215bf
--- /dev/null
+++ b/examples/camel-example-transformer-cdi/src/main/resources/META-INF/NOTICE.txt
@@ -0,0 +1,11 @@
+ =========================================================================
+ == NOTICE file corresponding to the section 4 d of ==
+ == the Apache License, Version 2.0, ==
+ == in this case for the Apache Camel distribution. ==
+ =========================================================================
+
+ This product includes software developed by
+ The Apache Software Foundation (http://www.apache.org/).
+
+ Please read the different LICENSE files present in the licenses directory of
+ this distribution.
http://git-wip-us.apache.org/repos/asf/camel/blob/7ba090f5/examples/camel-example-transformer-cdi/src/main/resources/META-INF/beans.xml
----------------------------------------------------------------------
diff --git a/examples/camel-example-transformer-cdi/src/main/resources/META-INF/beans.xml b/examples/camel-example-transformer-cdi/src/main/resources/META-INF/beans.xml
new file mode 100644
index 0000000..112d56d
--- /dev/null
+++ b/examples/camel-example-transformer-cdi/src/main/resources/META-INF/beans.xml
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<beans/>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/camel/blob/7ba090f5/examples/camel-example-transformer-cdi/src/main/resources/log4j2.properties
----------------------------------------------------------------------
diff --git a/examples/camel-example-transformer-cdi/src/main/resources/log4j2.properties b/examples/camel-example-transformer-cdi/src/main/resources/log4j2.properties
new file mode 100644
index 0000000..a1e0d92
--- /dev/null
+++ b/examples/camel-example-transformer-cdi/src/main/resources/log4j2.properties
@@ -0,0 +1,28 @@
+## ---------------------------------------------------------------------------
+## Licensed to the Apache Software Foundation (ASF) under one or more
+## contributor license agreements. See the NOTICE file distributed with
+## this work for additional information regarding copyright ownership.
+## The ASF licenses this file to You under the Apache License, Version 2.0
+## (the "License"); you may not use this file except in compliance with
+## the License. You may obtain a copy of the License at
+##
+## http://www.apache.org/licenses/LICENSE-2.0
+##
+## Unless required by applicable law or agreed to in writing, software
+## distributed under the License is distributed on an "AS IS" BASIS,
+## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+## See the License for the specific language governing permissions and
+## limitations under the License.
+## ---------------------------------------------------------------------------
+
+appender.stdout.type = Console
+appender.stdout.name = stdout
+appender.stdout.layout.type = PatternLayout
+appender.stdout.layout.pattern = %d [%-15.15t] %-5p %-30.30c{1} - %m%n
+rootLogger.level = INFO
+rootLogger.appenderRef.stdout.ref = stdout
+
+#logger.transformer.name = org.apache.camel.impl.transformer
+#logger.transformer.level = DEBUG
+#logger.processor.name = org.apache.camel.processor
+#logger.processor.level = DEBUG
http://git-wip-us.apache.org/repos/asf/camel/blob/7ba090f5/examples/camel-example-transformer-cdi/src/main/resources/transform.xsl
----------------------------------------------------------------------
diff --git a/examples/camel-example-transformer-cdi/src/main/resources/transform.xsl b/examples/camel-example-transformer-cdi/src/main/resources/transform.xsl
new file mode 100644
index 0000000..2f2e514
--- /dev/null
+++ b/examples/camel-example-transformer-cdi/src/main/resources/transform.xsl
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="Shift_JIS"?>
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
+ <xsl:template match="@*|node()">
+ <xsl:copy>
+ <xsl:apply-templates select="@*|node()"/>
+ </xsl:copy>
+ </xsl:template>
+
+ <xsl:template match="MyRequest">
+ <MyResponse>
+ <xsl:apply-templates/>
+ </MyResponse>
+ </xsl:template>
+</xsl:stylesheet>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/camel/blob/7ba090f5/examples/camel-example-transformer-demo/README.md
----------------------------------------------------------------------
diff --git a/examples/camel-example-transformer-demo/README.md b/examples/camel-example-transformer-demo/README.md
new file mode 100644
index 0000000..8f203f8
--- /dev/null
+++ b/examples/camel-example-transformer-demo/README.md
@@ -0,0 +1,33 @@
+# Declarative Transformer Demo using Spring XML
+
+
+### Introduction
+
+This example shows how to work with declarative transformation by declaring data types.
+
+### Build
+
+You will need to compile this example first:
+
+ mvn compile
+
+### Run
+
+To run the example type
+
+ mvn exec:java
+
+You can see the routing rules by looking at the Spring XML configuration lives in
+`src/main/resources/META-INF/spring`
+
+
+### Forum, Help, etc
+
+If you hit an problems please let us know on the Camel Forums
+ <http://camel.apache.org/discussion-forums.html>
+
+Please help us make Apache Camel better - we appreciate any feedback you may
+have. Enjoy!
+
+
+The Camel riders!