Updated Branches: refs/heads/camel-2.12.x 0147b7a5a -> aad59d74f
CAMEL-7203: Introdued allowUseOriginalMessage option which can be turned off to improve performance when you dont need access to the original message. Likely more often, so added INFO logging on startup to notice users about this. Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/aad59d74 Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/aad59d74 Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/aad59d74 Branch: refs/heads/camel-2.12.x Commit: aad59d74fbdfbf1d1cf14645632ed96b4ff82bfb Parents: 0147b7a Author: Claus Ibsen <davscl...@apache.org> Authored: Thu Feb 13 14:16:07 2014 +0100 Committer: Claus Ibsen <davscl...@apache.org> Committed: Thu Feb 13 14:16:33 2014 +0100 ---------------------------------------------------------------------- .../org/apache/camel/RuntimeConfiguration.java | 20 ++++++++ .../mbean/ManagedCamelContextMBean.java | 12 +++++ .../apache/camel/impl/DefaultCamelContext.java | 15 ++++++ .../apache/camel/impl/DefaultRouteContext.java | 8 +++ .../apache/camel/impl/DefaultUnitOfWork.java | 22 ++++---- .../management/mbean/ManagedCamelContext.java | 16 ++++++ .../java/org/apache/camel/spi/UnitOfWork.java | 6 +-- ...ContextAllowUseOriginalMessageFalseTest.java | 54 ++++++++++++++++++++ ...lContextAllowUseOriginalMessageTrueTest.java | 54 ++++++++++++++++++++ .../camel/impl/OriginalMessageProcessor.java | 36 +++++++++++++ .../blueprint/CamelContextFactoryBean.java | 10 ++++ .../xml/AbstractCamelContextFactoryBean.java | 5 ++ .../camel/spring/CamelContextFactoryBean.java | 10 ++++ ...ContextAllowUseOriginalMessageFalseTest.java | 33 ++++++++++++ ...lContextAllowUseOriginalMessageTrueTest.java | 33 ++++++++++++ ...lContextAllowUseOriginalMessageFalseTest.xml | 39 ++++++++++++++ ...elContextAllowUseOriginalMessageTrueTest.xml | 39 ++++++++++++++ .../camel/karaf/commands/ContextInfo.java | 13 ++--- 18 files changed, 406 insertions(+), 19 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/aad59d74/camel-core/src/main/java/org/apache/camel/RuntimeConfiguration.java ---------------------------------------------------------------------- diff --git a/camel-core/src/main/java/org/apache/camel/RuntimeConfiguration.java b/camel-core/src/main/java/org/apache/camel/RuntimeConfiguration.java index 3a1c92d..0bcaff1 100644 --- a/camel-core/src/main/java/org/apache/camel/RuntimeConfiguration.java +++ b/camel-core/src/main/java/org/apache/camel/RuntimeConfiguration.java @@ -151,4 +151,24 @@ public interface RuntimeConfiguration { */ ShutdownRunningTask getShutdownRunningTask(); + /** + * Sets whether to allow access to the original message from Camel's error handler, + * or from {@link org.apache.camel.spi.UnitOfWork#getOriginalInMessage()}. + * <p/> + * Turning this off can optimize performance, as defensive copy of the original message is not needed. + * + * @param allowUseOriginalMessage the option to use. + */ + void setAllowUseOriginalMessage(Boolean allowUseOriginalMessage); + + /** + * Sets whether to allow access to the original message from Camel's error handler, + * or from {@link org.apache.camel.spi.UnitOfWork#getOriginalInMessage()}. + * <p/> + * Turning this off can optimize performance, as defensive copy of the original message is not needed. + * + * @return the option + */ + Boolean isAllowUseOriginalMessage(); + } http://git-wip-us.apache.org/repos/asf/camel/blob/aad59d74/camel-core/src/main/java/org/apache/camel/api/management/mbean/ManagedCamelContextMBean.java ---------------------------------------------------------------------- diff --git a/camel-core/src/main/java/org/apache/camel/api/management/mbean/ManagedCamelContextMBean.java b/camel-core/src/main/java/org/apache/camel/api/management/mbean/ManagedCamelContextMBean.java index 5ec2a4c..15bd452 100644 --- a/camel-core/src/main/java/org/apache/camel/api/management/mbean/ManagedCamelContextMBean.java +++ b/camel-core/src/main/java/org/apache/camel/api/management/mbean/ManagedCamelContextMBean.java @@ -119,6 +119,18 @@ public interface ManagedCamelContextMBean extends ManagedPerformanceCounterMBean @ManagedAttribute(description = "Average load over the last fifteen minutes") String getLoad15(); + @ManagedAttribute(description = "Whether breadcrumbs is in use") + boolean isUseBreadcrumb(); + + @ManagedAttribute(description = "Whether allowing access to the original message during routing") + boolean isAllowUseOriginalMessage(); + + @ManagedAttribute(description = "Whether message history is enabled") + boolean isMessageHistory(); + + @ManagedAttribute(description = "Whether MDC logging is supported") + boolean isUseMDCLogging(); + @ManagedOperation(description = "Start Camel") void start() throws Exception; http://git-wip-us.apache.org/repos/asf/camel/blob/aad59d74/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java ---------------------------------------------------------------------- diff --git a/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java b/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java index 03f149d..eba472a 100644 --- a/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java +++ b/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java @@ -185,6 +185,7 @@ public class DefaultCamelContext extends ServiceSupport implements ModelCamelCon private Boolean typeConverterStatisticsEnabled = Boolean.FALSE; private Boolean useMDCLogging = Boolean.FALSE; private Boolean useBreadcrumb = Boolean.TRUE; + private Boolean allowUseOriginalMessage = Boolean.TRUE; private Long delay; private ErrorHandlerFactory errorHandlerBuilder; private final Object errorHandlerExecutorServiceLock = new Object(); @@ -1701,6 +1702,12 @@ public class DefaultCamelContext extends ServiceSupport implements ModelCamelCon } } } + + if (isAllowUseOriginalMessage()) { + log.info("AllowUseOriginalMessage is enabled. If access to the original message is not needed," + + " then its recommended to turn this option off as it may improve performance."); + } + if (streamCachingInUse) { // stream caching is in use so enable the strategy getStreamCachingStrategy().setEnabled(true); @@ -2642,6 +2649,14 @@ public class DefaultCamelContext extends ServiceSupport implements ModelCamelCon this.shutdownRunningTask = shutdownRunningTask; } + public void setAllowUseOriginalMessage(Boolean allowUseOriginalMessage) { + this.allowUseOriginalMessage = allowUseOriginalMessage; + } + + public Boolean isAllowUseOriginalMessage() { + return allowUseOriginalMessage != null && allowUseOriginalMessage; + } + public ExecutorServiceManager getExecutorServiceManager() { return this.executorServiceManager; } http://git-wip-us.apache.org/repos/asf/camel/blob/aad59d74/camel-core/src/main/java/org/apache/camel/impl/DefaultRouteContext.java ---------------------------------------------------------------------- diff --git a/camel-core/src/main/java/org/apache/camel/impl/DefaultRouteContext.java b/camel-core/src/main/java/org/apache/camel/impl/DefaultRouteContext.java index 2680e84..aeb8b91 100644 --- a/camel-core/src/main/java/org/apache/camel/impl/DefaultRouteContext.java +++ b/camel-core/src/main/java/org/apache/camel/impl/DefaultRouteContext.java @@ -320,6 +320,14 @@ public class DefaultRouteContext implements RouteContext { this.shutdownRoute = shutdownRoute; } + public void setAllowUseOriginalMessage(Boolean allowUseOriginalMessage) { + throw new IllegalArgumentException("This option can only be configured on CamelContext"); + } + + public Boolean isAllowUseOriginalMessage() { + return getCamelContext().isAllowUseOriginalMessage(); + } + public ShutdownRoute getShutdownRoute() { if (shutdownRoute != null) { return shutdownRoute; http://git-wip-us.apache.org/repos/asf/camel/blob/aad59d74/camel-core/src/main/java/org/apache/camel/impl/DefaultUnitOfWork.java ---------------------------------------------------------------------- diff --git a/camel-core/src/main/java/org/apache/camel/impl/DefaultUnitOfWork.java b/camel-core/src/main/java/org/apache/camel/impl/DefaultUnitOfWork.java index db8dc27..e8b98e0 100644 --- a/camel-core/src/main/java/org/apache/camel/impl/DefaultUnitOfWork.java +++ b/camel-core/src/main/java/org/apache/camel/impl/DefaultUnitOfWork.java @@ -79,16 +79,18 @@ public class DefaultUnitOfWork implements UnitOfWork, Service { tracedRouteNodes = new DefaultTracedRouteNodes(); context = exchange.getContext(); - // TODO: Camel 3.0: the copy on facade strategy will help us here in the future - // TODO: optimize to only copy original message if enabled to do so in the route - // special for JmsMessage as it can cause it to loose headers later. - // This will be resolved when we get the message facade with copy on write implemented - if (exchange.getIn().getClass().getName().equals("org.apache.camel.component.jms.JmsMessage")) { - this.originalInMessage = new DefaultMessage(); - this.originalInMessage.setBody(exchange.getIn().getBody()); - this.originalInMessage.getHeaders().putAll(exchange.getIn().getHeaders()); - } else { - this.originalInMessage = exchange.getIn().copy(); + if (context.isAllowUseOriginalMessage()) { + // TODO: Camel 3.0: the copy on facade strategy will help us here in the future + // TODO: optimize to only copy original message if enabled to do so in the route + // special for JmsMessage as it can cause it to loose headers later. + // This will be resolved when we get the message facade with copy on write implemented + if (exchange.getIn().getClass().getName().equals("org.apache.camel.component.jms.JmsMessage")) { + this.originalInMessage = new DefaultMessage(); + this.originalInMessage.setBody(exchange.getIn().getBody()); + this.originalInMessage.getHeaders().putAll(exchange.getIn().getHeaders()); + } else { + this.originalInMessage = exchange.getIn().copy(); + } } // TODO: Optimize to only copy if useOriginalMessage has been enabled http://git-wip-us.apache.org/repos/asf/camel/blob/aad59d74/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedCamelContext.java ---------------------------------------------------------------------- diff --git a/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedCamelContext.java b/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedCamelContext.java index a4d54d2..8d5b4ce 100644 --- a/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedCamelContext.java +++ b/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedCamelContext.java @@ -182,6 +182,22 @@ public class ManagedCamelContext extends ManagedPerformanceCounter implements Ti return String.format("%.2f", load.getLoad15()); } + public boolean isUseBreadcrumb() { + return context.isUseBreadcrumb(); + } + + public boolean isAllowUseOriginalMessage() { + return context.isAllowUseOriginalMessage(); + } + + public boolean isMessageHistory() { + return context.isMessageHistory(); + } + + public boolean isUseMDCLogging() { + return context.isUseMDCLogging(); + } + public void onTimer() { load.update(getInflightExchanges()); } http://git-wip-us.apache.org/repos/asf/camel/blob/aad59d74/camel-core/src/main/java/org/apache/camel/spi/UnitOfWork.java ---------------------------------------------------------------------- diff --git a/camel-core/src/main/java/org/apache/camel/spi/UnitOfWork.java b/camel-core/src/main/java/org/apache/camel/spi/UnitOfWork.java index 2f8d419..5100666 100644 --- a/camel-core/src/main/java/org/apache/camel/spi/UnitOfWork.java +++ b/camel-core/src/main/java/org/apache/camel/spi/UnitOfWork.java @@ -80,10 +80,10 @@ public interface UnitOfWork extends Service { /** * Gets the original IN {@link Message} this Unit of Work was started with. * <p/> - * <b>Important: </b> This is subject for change in a later Camel release, where we plan to only - * support getting the original IN message if you have enabled this option explicit. + * The original message is only returned if the option {@link org.apache.camel.RuntimeConfiguration#isAllowUseOriginalMessage()} + * is enabled. If its disabled, then <tt>null</tt> is returned. * - * @return the original IN {@link Message}, may return <tt>null</tt> in a later Camel release (see important note). + * @return the original IN {@link Message}, or <tt>null</tt> if using original message is disabled. */ Message getOriginalInMessage(); http://git-wip-us.apache.org/repos/asf/camel/blob/aad59d74/camel-core/src/test/java/org/apache/camel/impl/DefaultCamelContextAllowUseOriginalMessageFalseTest.java ---------------------------------------------------------------------- diff --git a/camel-core/src/test/java/org/apache/camel/impl/DefaultCamelContextAllowUseOriginalMessageFalseTest.java b/camel-core/src/test/java/org/apache/camel/impl/DefaultCamelContextAllowUseOriginalMessageFalseTest.java new file mode 100644 index 0000000..cf2bf98 --- /dev/null +++ b/camel-core/src/test/java/org/apache/camel/impl/DefaultCamelContextAllowUseOriginalMessageFalseTest.java @@ -0,0 +1,54 @@ +/** + * 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; + +import org.apache.camel.CamelContext; +import org.apache.camel.ContextTestSupport; +import org.apache.camel.builder.RouteBuilder; + +public class DefaultCamelContextAllowUseOriginalMessageFalseTest extends ContextTestSupport { + + @Override + protected CamelContext createCamelContext() throws Exception { + CamelContext context = super.createCamelContext(); + context.setAllowUseOriginalMessage(false); + return context; + } + + public void testUseOriginalMessageFalse() throws Exception { + getMockEndpoint("mock:result").expectedBodiesReceived("Bye World"); + getMockEndpoint("mock:result").expectedHeaderReceived("HasOriginal", "false"); + + template.sendBody("direct:start", "World"); + + assertMockEndpointsSatisfied(); + } + + @Override + protected RouteBuilder createRouteBuilder() throws Exception { + return new RouteBuilder() { + @Override + public void configure() throws Exception { + from("direct:start") + .transform().simple("Bye ${body}") + .process(new OriginalMessageProcessor()) + .to("mock:result"); + } + }; + } + +} http://git-wip-us.apache.org/repos/asf/camel/blob/aad59d74/camel-core/src/test/java/org/apache/camel/impl/DefaultCamelContextAllowUseOriginalMessageTrueTest.java ---------------------------------------------------------------------- diff --git a/camel-core/src/test/java/org/apache/camel/impl/DefaultCamelContextAllowUseOriginalMessageTrueTest.java b/camel-core/src/test/java/org/apache/camel/impl/DefaultCamelContextAllowUseOriginalMessageTrueTest.java new file mode 100644 index 0000000..f1adf4a --- /dev/null +++ b/camel-core/src/test/java/org/apache/camel/impl/DefaultCamelContextAllowUseOriginalMessageTrueTest.java @@ -0,0 +1,54 @@ +/** + * 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; + +import org.apache.camel.CamelContext; +import org.apache.camel.ContextTestSupport; +import org.apache.camel.builder.RouteBuilder; + +public class DefaultCamelContextAllowUseOriginalMessageTrueTest extends ContextTestSupport { + + @Override + protected CamelContext createCamelContext() throws Exception { + CamelContext context = super.createCamelContext(); + context.setAllowUseOriginalMessage(true); + return context; + } + + public void testUseOriginalMessageTrue() throws Exception { + getMockEndpoint("mock:result").expectedBodiesReceived("Bye World"); + getMockEndpoint("mock:result").expectedHeaderReceived("HasOriginal", "true"); + getMockEndpoint("mock:result").expectedHeaderReceived("OriginalBody", "World"); + + template.sendBody("direct:start", "World"); + + assertMockEndpointsSatisfied(); + } + + @Override + protected RouteBuilder createRouteBuilder() throws Exception { + return new RouteBuilder() { + @Override + public void configure() throws Exception { + from("direct:start") + .transform().simple("Bye ${body}") + .process(new OriginalMessageProcessor()) + .to("mock:result"); + } + }; + } +} http://git-wip-us.apache.org/repos/asf/camel/blob/aad59d74/camel-core/src/test/java/org/apache/camel/impl/OriginalMessageProcessor.java ---------------------------------------------------------------------- diff --git a/camel-core/src/test/java/org/apache/camel/impl/OriginalMessageProcessor.java b/camel-core/src/test/java/org/apache/camel/impl/OriginalMessageProcessor.java new file mode 100644 index 0000000..ef0bd6f --- /dev/null +++ b/camel-core/src/test/java/org/apache/camel/impl/OriginalMessageProcessor.java @@ -0,0 +1,36 @@ +/** + * 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; + +import org.apache.camel.Exchange; +import org.apache.camel.Message; +import org.apache.camel.Processor; + +public class OriginalMessageProcessor implements Processor { + + @Override + public void process(Exchange exchange) throws Exception { + Message original = exchange.getUnitOfWork().getOriginalInMessage(); + if (original == null) { + exchange.getIn().setHeader("HasOriginal", "false"); + } else { + exchange.getIn().setHeader("HasOriginal", "true"); + exchange.getIn().setHeader("OriginalBody", original.getBody()); + } + } + +} http://git-wip-us.apache.org/repos/asf/camel/blob/aad59d74/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 1e71c62..72dc978 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 @@ -96,6 +96,8 @@ public class CamelContextFactoryBean extends AbstractCamelContextFactoryBean<Blu @XmlAttribute(required = false) private String useBreadcrumb; @XmlAttribute(required = false) + private String allowUseOriginalMessage; + @XmlAttribute(required = false) private String managementNamePattern; @XmlAttribute(required = false) private String threadNamePattern; @@ -332,6 +334,14 @@ public class CamelContextFactoryBean extends AbstractCamelContextFactoryBean<Blu this.useBreadcrumb = useBreadcrumb; } + public String getAllowUseOriginalMessage() { + return allowUseOriginalMessage; + } + + public void setAllowUseOriginalMessage(String allowUseOriginalMessage) { + this.allowUseOriginalMessage = allowUseOriginalMessage; + } + public String getManagementNamePattern() { return managementNamePattern; } http://git-wip-us.apache.org/repos/asf/camel/blob/aad59d74/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 33071f3..84f6b5a 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 @@ -568,6 +568,8 @@ public abstract class AbstractCamelContextFactoryBean<T extends ModelCamelContex public abstract String getUseBreadcrumb(); + public abstract String getAllowUseOriginalMessage(); + public abstract String getManagementNamePattern(); public abstract String getThreadNamePattern(); @@ -641,6 +643,9 @@ public abstract class AbstractCamelContextFactoryBean<T extends ModelCamelContex if (getUseBreadcrumb() != null) { ctx.setUseBreadcrumb(CamelContextHelper.parseBoolean(getContext(), getUseBreadcrumb())); } + if (getAllowUseOriginalMessage() != null) { + ctx.setAllowUseOriginalMessage(CamelContextHelper.parseBoolean(getContext(), getAllowUseOriginalMessage())); + } if (getManagementNamePattern() != null) { ctx.getManagementNameStrategy().setNamePattern(getManagementNamePattern()); } http://git-wip-us.apache.org/repos/asf/camel/blob/aad59d74/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 1ba3163..79aeed0 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 @@ -105,6 +105,8 @@ public class CamelContextFactoryBean extends AbstractCamelContextFactoryBean<Spr @XmlAttribute(required = false) private String useBreadcrumb; @XmlAttribute(required = false) + private String allowUseOriginalMessage; + @XmlAttribute(required = false) private String managementNamePattern; @XmlAttribute(required = false) private String threadNamePattern; @@ -548,6 +550,14 @@ public class CamelContextFactoryBean extends AbstractCamelContextFactoryBean<Spr this.useBreadcrumb = useBreadcrumb; } + public String getAllowUseOriginalMessage() { + return allowUseOriginalMessage; + } + + public void setAllowUseOriginalMessage(String allowUseOriginalMessage) { + this.allowUseOriginalMessage = allowUseOriginalMessage; + } + public String getManagementNamePattern() { return managementNamePattern; } http://git-wip-us.apache.org/repos/asf/camel/blob/aad59d74/components/camel-spring/src/test/java/org/apache/camel/spring/impl/SpringDefaultCamelContextAllowUseOriginalMessageFalseTest.java ---------------------------------------------------------------------- diff --git a/components/camel-spring/src/test/java/org/apache/camel/spring/impl/SpringDefaultCamelContextAllowUseOriginalMessageFalseTest.java b/components/camel-spring/src/test/java/org/apache/camel/spring/impl/SpringDefaultCamelContextAllowUseOriginalMessageFalseTest.java new file mode 100644 index 0000000..6ffe0fe --- /dev/null +++ b/components/camel-spring/src/test/java/org/apache/camel/spring/impl/SpringDefaultCamelContextAllowUseOriginalMessageFalseTest.java @@ -0,0 +1,33 @@ +/** + * 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; + +import org.apache.camel.CamelContext; +import org.apache.camel.impl.DefaultCamelContextAllowUseOriginalMessageFalseTest; + +import static org.apache.camel.spring.processor.SpringTestHelper.createSpringCamelContext; + +/** + * + */ +public class SpringDefaultCamelContextAllowUseOriginalMessageFalseTest extends DefaultCamelContextAllowUseOriginalMessageFalseTest { + + protected CamelContext createCamelContext() throws Exception { + return createSpringCamelContext(this, "org/apache/camel/spring/impl/SpringDefaultCamelContextAllowUseOriginalMessageFalseTest.xml"); + } + +} http://git-wip-us.apache.org/repos/asf/camel/blob/aad59d74/components/camel-spring/src/test/java/org/apache/camel/spring/impl/SpringDefaultCamelContextAllowUseOriginalMessageTrueTest.java ---------------------------------------------------------------------- diff --git a/components/camel-spring/src/test/java/org/apache/camel/spring/impl/SpringDefaultCamelContextAllowUseOriginalMessageTrueTest.java b/components/camel-spring/src/test/java/org/apache/camel/spring/impl/SpringDefaultCamelContextAllowUseOriginalMessageTrueTest.java new file mode 100644 index 0000000..f8f847a --- /dev/null +++ b/components/camel-spring/src/test/java/org/apache/camel/spring/impl/SpringDefaultCamelContextAllowUseOriginalMessageTrueTest.java @@ -0,0 +1,33 @@ +/** + * 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; + +import org.apache.camel.CamelContext; +import org.apache.camel.impl.DefaultCamelContextAllowUseOriginalMessageTrueTest; + +import static org.apache.camel.spring.processor.SpringTestHelper.createSpringCamelContext; + +/** + * + */ +public class SpringDefaultCamelContextAllowUseOriginalMessageTrueTest extends DefaultCamelContextAllowUseOriginalMessageTrueTest { + + protected CamelContext createCamelContext() throws Exception { + return createSpringCamelContext(this, "org/apache/camel/spring/impl/SpringDefaultCamelContextAllowUseOriginalMessageTrueTest.xml"); + } + +} http://git-wip-us.apache.org/repos/asf/camel/blob/aad59d74/components/camel-spring/src/test/resources/org/apache/camel/spring/impl/SpringDefaultCamelContextAllowUseOriginalMessageFalseTest.xml ---------------------------------------------------------------------- diff --git a/components/camel-spring/src/test/resources/org/apache/camel/spring/impl/SpringDefaultCamelContextAllowUseOriginalMessageFalseTest.xml b/components/camel-spring/src/test/resources/org/apache/camel/spring/impl/SpringDefaultCamelContextAllowUseOriginalMessageFalseTest.xml new file mode 100644 index 0000000..ab42e4b --- /dev/null +++ b/components/camel-spring/src/test/resources/org/apache/camel/spring/impl/SpringDefaultCamelContextAllowUseOriginalMessageFalseTest.xml @@ -0,0 +1,39 @@ +<?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="proc" class="org.apache.camel.impl.OriginalMessageProcessor"/> + + <camelContext allowUseOriginalMessage="false" xmlns="http://camel.apache.org/schema/spring"> + <route> + <from uri="direct:start"/> + <transform> + <simple>Bye ${body}</simple> + </transform> + <process ref="proc"/> + <to uri="mock:result"/> + </route> + + </camelContext> + +</beans> http://git-wip-us.apache.org/repos/asf/camel/blob/aad59d74/components/camel-spring/src/test/resources/org/apache/camel/spring/impl/SpringDefaultCamelContextAllowUseOriginalMessageTrueTest.xml ---------------------------------------------------------------------- diff --git a/components/camel-spring/src/test/resources/org/apache/camel/spring/impl/SpringDefaultCamelContextAllowUseOriginalMessageTrueTest.xml b/components/camel-spring/src/test/resources/org/apache/camel/spring/impl/SpringDefaultCamelContextAllowUseOriginalMessageTrueTest.xml new file mode 100644 index 0000000..168befb --- /dev/null +++ b/components/camel-spring/src/test/resources/org/apache/camel/spring/impl/SpringDefaultCamelContextAllowUseOriginalMessageTrueTest.xml @@ -0,0 +1,39 @@ +<?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="proc" class="org.apache.camel.impl.OriginalMessageProcessor"/> + + <camelContext allowUseOriginalMessage="true" xmlns="http://camel.apache.org/schema/spring"> + <route> + <from uri="direct:start"/> + <transform> + <simple>Bye ${body}</simple> + </transform> + <process ref="proc"/> + <to uri="mock:result"/> + </route> + + </camelContext> + +</beans> http://git-wip-us.apache.org/repos/asf/camel/blob/aad59d74/platforms/karaf/commands/src/main/java/org/apache/camel/karaf/commands/ContextInfo.java ---------------------------------------------------------------------- diff --git a/platforms/karaf/commands/src/main/java/org/apache/camel/karaf/commands/ContextInfo.java b/platforms/karaf/commands/src/main/java/org/apache/camel/karaf/commands/ContextInfo.java index 0cee886..ff8eefa 100644 --- a/platforms/karaf/commands/src/main/java/org/apache/camel/karaf/commands/ContextInfo.java +++ b/platforms/karaf/commands/src/main/java/org/apache/camel/karaf/commands/ContextInfo.java @@ -78,6 +78,7 @@ public class ContextInfo extends OsgiCommandSupport { System.out.println(StringEscapeUtils.unescapeJava("\tSuspended: " + camelContext.isSuspended())); System.out.println(StringEscapeUtils.unescapeJava("\tShutdown timeout: " + camelContext.getShutdownStrategy().getTimeUnit().toSeconds(camelContext.getShutdownStrategy().getTimeout()) + " sec.")); + System.out.println(StringEscapeUtils.unescapeJava("\tAllow UseOriginalMessage: " + camelContext.isAllowUseOriginalMessage())); System.out.println(StringEscapeUtils.unescapeJava("\tMessage History: " + camelContext.isMessageHistory())); System.out.println(StringEscapeUtils.unescapeJava("\tTracing: " + camelContext.isTracing())); System.out.println(""); @@ -104,14 +105,14 @@ public class ContextInfo extends OsgiCommandSupport { System.out.println(StringEscapeUtils.unescapeJava("\t" + names)); } - System.out.println(""); - System.out.println(StringEscapeUtils.unescapeJava("\u001B[1mLanguages\u001B[0m")); - for (String language : camelContext.getLanguageNames()) { - System.out.println(StringEscapeUtils.unescapeJava("\t" + language)); - } - if (mode != null && mode.equals("--verbose")) { System.out.println(""); + System.out.println(StringEscapeUtils.unescapeJava("\u001B[1mLanguages\u001B[0m")); + for (String language : camelContext.getLanguageNames()) { + System.out.println(StringEscapeUtils.unescapeJava("\t" + language)); + } + + System.out.println(""); System.out.println(StringEscapeUtils.unescapeJava("\u001B[1mEndpoints\u001B[0m")); for (Endpoint endpoint : camelContext.getEndpoints()) { System.out.println(StringEscapeUtils.unescapeJava("\t" + endpoint.getEndpointUri()));