Permalink
Browse files

[maven-release-plugin] copy for tag camel-2.10.0

git-svn-id: https://svn.apache.org/repos/asf/camel/tags/camel-2.10.0@1354763 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information...
2 parents 6774644 + ddbb36b commit 4b7de2347b85ee27df04dfe9e3c27342b0e495ff @hzbarcea hzbarcea committed Jun 27, 2012
Showing with 1,260 additions and 189 deletions.
  1. +34 −0 camel-core/src/main/java/org/apache/camel/builder/ThreadPoolBuilder.java
  2. +0 −1 camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java
  3. +29 −12 camel-core/src/main/java/org/apache/camel/impl/ScheduledPollConsumer.java
  4. +5 −1 camel-core/src/main/java/org/apache/camel/impl/ScheduledPollEndpoint.java
  5. +45 −18 camel-core/src/main/java/org/apache/camel/language/bean/BeanExpression.java
  6. +1 −1 camel-core/src/main/java/org/apache/camel/model/WireTapDefinition.java
  7. +17 −10 camel-core/src/main/java/org/apache/camel/model/language/MethodCallExpression.java
  8. +3 −3 camel-core/src/main/java/org/apache/camel/processor/validation/ValidatingProcessor.java
  9. +115 −9 camel-core/src/main/java/org/apache/camel/util/jsse/BaseSSLContextParameters.java
  10. +12 −1 camel-core/src/main/java/org/apache/camel/util/jsse/FilterParameters.java
  11. +24 −18 camel-core/src/main/java/org/apache/camel/util/jsse/JsseParameters.java
  12. +7 −3 camel-core/src/main/java/org/apache/camel/util/jsse/KeyManagersParameters.java
  13. +18 −3 camel-core/src/main/java/org/apache/camel/util/jsse/KeyStoreParameters.java
  14. +3 −3 camel-core/src/main/java/org/apache/camel/util/jsse/SSLContextClientParameters.java
  15. +27 −16 camel-core/src/main/java/org/apache/camel/util/jsse/SSLContextParameters.java
  16. +5 −3 camel-core/src/main/java/org/apache/camel/util/jsse/SSLContextServerParameters.java
  17. +3 −0 camel-core/src/main/java/org/apache/camel/util/jsse/SecureRandomParameters.java
  18. +6 −1 camel-core/src/main/java/org/apache/camel/util/jsse/TrustManagersParameters.java
  19. +36 −0 camel-core/src/test/java/org/apache/camel/builder/ThreadPoolBuilderTest.java
  20. +128 −0 camel-core/src/test/java/org/apache/camel/component/bean/BeanExpressionConcurrentTest.java
  21. +59 −0 ...core/src/test/java/org/apache/camel/component/file/FileConsumerSharedThreadPollStopRouteTest.java
  22. +91 −0 camel-core/src/test/java/org/apache/camel/component/file/FileConsumerSharedThreadPollTest.java
  23. +101 −0 camel-core/src/test/java/org/apache/camel/processor/DeadLetterChannelRestartFromBeginningTest.java
  24. +69 −0 camel-core/src/test/java/org/apache/camel/processor/WireTapBeanTest.java
  25. +1 −0 camel-core/src/test/resources/log4j.properties
  26. +16 −1 ...ts/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelThreadPoolFactoryBean.java
  27. +0 −3 components/camel-cxf/src/main/java/org/apache/camel/component/cxf/converter/CxfConverter.java
  28. +1 −0 components/camel-guice/src/main/java/org/apache/camel/guice/Main.java
  29. +5 −0 components/camel-jcr/src/main/java/org/apache/camel/component/jcr/JcrMessage.java
  30. +4 −5 components/camel-jibx/pom.xml
  31. +5 −0 components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsMessage.java
  32. +91 −0 ...onents/camel-jms/src/test/java/org/apache/camel/component/jms/JmsSplitterParallelChainedTest.java
  33. +79 −0 components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsSplitterParallelTest.java
  34. +103 −0 .../java/org/apache/camel/component/jms/issues/DynamicRoutersWithJMSMessageLostHeadersIssueTest.java
  35. +1 −0 components/camel-leveldb/pom.xml
  36. +0 −1 components/camel-restlet/src/main/java/org/apache/camel/component/restlet/RestletComponent.java
  37. +0 −1 components/camel-rmi/src/test/java/org/apache/camel/component/rmi/RmiRouteEndpointTest.java
  38. +5 −0 ...gration/src/main/java/org/apache/camel/component/spring/integration/SpringIntegrationMessage.java
  39. +6 −0 components/camel-spring-ws/pom.xml
  40. +3 −0 ...ing-ws/src/test/java/org/apache/camel/component/spring/ws/SSLContextParametersLocalRouteTest.java
  41. +0 −32 components/camel-spring/src/test/java/org/apache/camel/component/test/SpringTestEndpointTest.java
  42. +39 −0 ...s/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringScheduledThreadPoolTest.java
  43. +6 −8 .../{component/test/SpringTestEndpointTest.xml → spring/processor/SpringScheduledThreadPoolTest.xml}
  44. +5 −0 components/camel-stream/src/main/java/org/apache/camel/component/stream/StreamProducer.java
  45. +16 −0 components/camel-stream/src/test/java/org/apache/camel/component/stream/StreamSystemOutTest.java
  46. +5 −4 parent/pom.xml
  47. +1 −0 platforms/karaf/features/pom.xml
  48. +2 −2 platforms/karaf/features/src/main/resources/features.xml
  49. +0 −2 tests/camel-itest-karaf/src/test/java/org/apache/camel/itest/karaf/CamelSpringWebServiceTest.java
  50. +1 −1 tooling/camel-manual/pom.xml
  51. +27 −26 tooling/pom.xml
View
34 camel-core/src/main/java/org/apache/camel/builder/ThreadPoolBuilder.java
@@ -17,6 +17,7 @@
package org.apache.camel.builder;
import java.util.concurrent.ExecutorService;
+import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import org.apache.camel.CamelContext;
@@ -103,4 +104,37 @@ public ExecutorService build(Object source, String name) throws Exception {
return context.getExecutorServiceManager().newThreadPool(source, name, profile);
}
+ /**
+ * Builds the new scheduled thread pool
+ *
+ * @return the created scheduled thread pool
+ * @throws Exception is thrown if error building the scheduled thread pool
+ */
+ public ScheduledExecutorService buildScheduled() throws Exception {
+ return buildScheduled(null, null);
+ }
+
+ /**
+ * Builds the new scheduled thread pool
+ *
+ * @param name name which is appended to the thread name
+ * @return the created scheduled thread pool
+ * @throws Exception is thrown if error building the scheduled thread pool
+ */
+ public ScheduledExecutorService buildScheduled(String name) throws Exception {
+ return buildScheduled(null, name);
+ }
+
+ /**
+ * Builds the new scheduled thread pool
+ *
+ * @param source the source object, usually it should be <tt>this</tt> passed in as parameter
+ * @param name name which is appended to the thread name
+ * @return the created scheduled thread pool
+ * @throws Exception is thrown if error building the scheduled thread pool
+ */
+ public ScheduledExecutorService buildScheduled(Object source, String name) throws Exception {
+ return context.getExecutorServiceManager().newScheduledThreadPool(source, name, profile);
+ }
+
}
View
1 camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java
@@ -113,7 +113,6 @@
import org.apache.camel.spi.RouteStartupOrder;
import org.apache.camel.spi.ServicePool;
import org.apache.camel.spi.ShutdownStrategy;
-import org.apache.camel.spi.ThreadPoolProfile;
import org.apache.camel.spi.TypeConverterRegistry;
import org.apache.camel.spi.UuidGenerator;
import org.apache.camel.support.ServiceSupport;
View
41 camel-core/src/main/java/org/apache/camel/impl/ScheduledPollConsumer.java
@@ -41,7 +41,7 @@
public abstract class ScheduledPollConsumer extends DefaultConsumer implements Runnable, SuspendableService, PollingConsumerPollingStrategy {
private static final transient Logger LOG = LoggerFactory.getLogger(ScheduledPollConsumer.class);
- private ScheduledExecutorService executor;
+ private ScheduledExecutorService scheduledExecutorService;
private boolean shutdownExecutor;
private ScheduledFuture<?> future;
@@ -60,12 +60,12 @@ public ScheduledPollConsumer(Endpoint endpoint, Processor processor) {
super(endpoint, processor);
}
- public ScheduledPollConsumer(Endpoint endpoint, Processor processor, ScheduledExecutorService executor) {
+ public ScheduledPollConsumer(Endpoint endpoint, Processor processor, ScheduledExecutorService scheduledExecutorService) {
super(endpoint, processor);
// we have been given an existing thread pool, so we should not manage its lifecycle
// so we should keep shutdownExecutor as false
- this.executor = executor;
- ObjectHelper.notNull(executor, "executor");
+ this.scheduledExecutorService = scheduledExecutorService;
+ ObjectHelper.notNull(scheduledExecutorService, "scheduledExecutorService");
}
/**
@@ -283,6 +283,23 @@ public boolean isSendEmptyMessageWhenIdle() {
return sendEmptyMessageWhenIdle;
}
+ public ScheduledExecutorService getScheduledExecutorService() {
+ return scheduledExecutorService;
+ }
+
+ /**
+ * Sets a custom shared {@link ScheduledExecutorService} to use as thread pool
+ * <p/>
+ * <b>Notice: </b> When using a custom thread pool, then the lifecycle of this thread
+ * pool is not controlled by this consumer (eg this consumer will not start/stop the thread pool
+ * when the consumer is started/stopped etc.)
+ *
+ * @param scheduledExecutorService the custom thread pool to use
+ */
+ public void setScheduledExecutorService(ScheduledExecutorService scheduledExecutorService) {
+ this.scheduledExecutorService = scheduledExecutorService;
+ }
+
// Implementation methods
// -------------------------------------------------------------------------
@@ -299,15 +316,15 @@ protected void doStart() throws Exception {
super.doStart();
// if no existing executor provided, then create a new thread pool ourselves
- if (executor == null) {
+ if (scheduledExecutorService == null) {
// we only need one thread in the pool to schedule this task
- this.executor = getEndpoint().getCamelContext().getExecutorServiceManager()
+ this.scheduledExecutorService = getEndpoint().getCamelContext().getExecutorServiceManager()
.newScheduledThreadPool(this, getEndpoint().getEndpointUri(), 1);
// and we should shutdown the thread pool when no longer needed
this.shutdownExecutor = true;
}
- ObjectHelper.notNull(executor, "executor", this);
+ ObjectHelper.notNull(scheduledExecutorService, "scheduledExecutorService", this);
ObjectHelper.notNull(pollStrategy, "pollStrategy", this);
if (isStartScheduler()) {
@@ -321,13 +338,13 @@ protected void startScheduler() {
LOG.debug("Scheduling poll (fixed delay) with initialDelay: {}, delay: {} ({}) for: {}",
new Object[]{getInitialDelay(), getDelay(), getTimeUnit().name().toLowerCase(Locale.ENGLISH), getEndpoint()});
}
- future = executor.scheduleWithFixedDelay(this, getInitialDelay(), getDelay(), getTimeUnit());
+ future = scheduledExecutorService.scheduleWithFixedDelay(this, getInitialDelay(), getDelay(), getTimeUnit());
} else {
if (LOG.isDebugEnabled()) {
LOG.debug("Scheduling poll (fixed rate) with initialDelay: {}, delay: {} ({}) for: {}",
new Object[]{getInitialDelay(), getDelay(), getTimeUnit().name().toLowerCase(Locale.ENGLISH), getEndpoint()});
}
- future = executor.scheduleAtFixedRate(this, getInitialDelay(), getDelay(), getTimeUnit());
+ future = scheduledExecutorService.scheduleAtFixedRate(this, getInitialDelay(), getDelay(), getTimeUnit());
}
}
@@ -342,9 +359,9 @@ protected void doStop() throws Exception {
@Override
protected void doShutdown() throws Exception {
- if (shutdownExecutor && executor != null) {
- getEndpoint().getCamelContext().getExecutorServiceManager().shutdownNow(executor);
- executor = null;
+ if (shutdownExecutor && scheduledExecutorService != null) {
+ getEndpoint().getCamelContext().getExecutorServiceManager().shutdownNow(scheduledExecutorService);
+ scheduledExecutorService = null;
future = null;
}
super.doShutdown();
View
6 camel-core/src/main/java/org/apache/camel/impl/ScheduledPollEndpoint.java
@@ -62,13 +62,14 @@ private void configureScheduledPollConsumerProperties(Map<String, Object> option
Object pollStrategy = options.remove("pollStrategy");
Object runLoggingLevel = options.remove("runLoggingLevel");
Object sendEmptyMessageWhenIdle = options.remove("sendEmptyMessageWhenIdle");
+ Object scheduledExecutorService = options.remove("scheduledExecutorService");
boolean setConsumerProperties = false;
// the following is split into two if statements to satisfy the checkstyle max complexity constraint
if (initialDelay != null || delay != null || timeUnit != null || useFixedDelay != null || pollStrategy != null) {
setConsumerProperties = true;
}
- if (runLoggingLevel != null || startScheduler != null || sendEmptyMessageWhenIdle != null) {
+ if (runLoggingLevel != null || startScheduler != null || sendEmptyMessageWhenIdle != null || scheduledExecutorService != null) {
setConsumerProperties = true;
}
@@ -101,6 +102,9 @@ private void configureScheduledPollConsumerProperties(Map<String, Object> option
if (sendEmptyMessageWhenIdle != null) {
consumerProperties.put("sendEmptyMessageWhenIdle", sendEmptyMessageWhenIdle);
}
+ if (scheduledExecutorService != null) {
+ consumerProperties.put("scheduledExecutorService", scheduledExecutorService);
+ }
}
}
View
63 camel-core/src/main/java/org/apache/camel/language/bean/BeanExpression.java
@@ -19,6 +19,7 @@
import java.util.List;
import java.util.Map;
+import org.apache.camel.CamelContext;
import org.apache.camel.Exchange;
import org.apache.camel.ExchangePattern;
import org.apache.camel.Expression;
@@ -37,28 +38,41 @@
/**
* Evaluates an expression using a bean method invocation
- *
- * @version
*/
public class BeanExpression implements Expression, Predicate {
- private Object bean;
- private String beanName;
- private Class<?> type;
- private String method;
+ private final Object bean;
+ private final String beanName;
+ private final Class<?> type;
+ private final String method;
+ private volatile BeanHolder beanHolder;
public BeanExpression(Object bean, String method) {
this.bean = bean;
this.method = method;
+ this.beanName = null;
+ this.type = null;
}
public BeanExpression(String beanName, String method) {
this.beanName = beanName;
this.method = method;
+ this.bean = null;
+ this.type = null;
}
public BeanExpression(Class<?> type, String method) {
this.type = type;
this.method = method;
+ this.bean = null;
+ this.beanName = null;
+ }
+
+ public BeanExpression(BeanHolder beanHolder, String method) {
+ this.beanHolder = beanHolder;
+ this.method = method;
+ this.bean = null;
+ this.beanName = null;
+ this.type = null;
}
@Override
@@ -79,16 +93,10 @@ public String toString() {
}
public Object evaluate(Exchange exchange) {
- // either use registry lookup or a constant bean
- BeanHolder holder;
- if (bean != null) {
- holder = new ConstantBeanHolder(bean, exchange.getContext());
- } else if (beanName != null) {
- holder = new RegistryBean(exchange.getContext(), beanName);
- } else if (type != null) {
- holder = new ConstantTypeBeanHolder(type, exchange.getContext());
- } else {
- throw new IllegalArgumentException("Either bean, beanName or type should be set on " + this);
+
+ // if the bean holder doesn't exist then create it using the context from the exchange
+ if (beanHolder == null) {
+ beanHolder = createBeanHolder(exchange.getContext());
}
// invoking the bean can either be the easy way or using OGNL
@@ -101,7 +109,7 @@ public Object evaluate(Exchange exchange) {
if (OgnlHelper.isValidOgnlExpression(method)) {
// okay the method is an ognl expression
- OgnlInvokeProcessor ognl = new OgnlInvokeProcessor(holder, method);
+ OgnlInvokeProcessor ognl = new OgnlInvokeProcessor(beanHolder, method);
try {
ognl.process(exchange);
return ognl.getResult();
@@ -110,7 +118,7 @@ public Object evaluate(Exchange exchange) {
}
} else {
// regular non ognl invocation
- InvokeProcessor invoke = new InvokeProcessor(holder, method);
+ InvokeProcessor invoke = new InvokeProcessor(beanHolder, method);
try {
invoke.process(exchange);
return invoke.getResult();
@@ -131,6 +139,25 @@ public boolean matches(Exchange exchange) {
}
/**
+ * Optimize to create the bean holder once, so we can reuse it for further
+ * evaluation, which is faster.
+ */
+ private synchronized BeanHolder createBeanHolder(CamelContext context) {
+ // either use registry lookup or a constant bean
+ BeanHolder holder;
+ if (bean != null) {
+ holder = new ConstantBeanHolder(bean, context);
+ } else if (beanName != null) {
+ holder = new RegistryBean(context, beanName);
+ } else if (type != null) {
+ holder = new ConstantTypeBeanHolder(type, context);
+ } else {
+ throw new IllegalArgumentException("Either bean, beanName or type should be set on " + this);
+ }
+ return holder;
+ }
+
+ /**
* Invokes a given bean holder. The method name is optional.
*/
private final class InvokeProcessor implements Processor {
View
2 camel-core/src/main/java/org/apache/camel/model/WireTapDefinition.java
@@ -43,7 +43,7 @@
*/
@XmlRootElement(name = "wireTap")
@XmlAccessorType(XmlAccessType.FIELD)
-public class WireTapDefinition<Type extends ProcessorDefinition<Type>> extends NoOutputDefinition<Type> implements ExecutorServiceAwareDefinition<WireTapDefinition<Type>> {
+public class WireTapDefinition<Type extends ProcessorDefinition<Type>> extends NoOutputDefinition<WireTapDefinition<Type>> implements ExecutorServiceAwareDefinition<WireTapDefinition<Type>> {
@XmlAttribute
protected String uri;
@XmlAttribute
View
27 camel-core/src/main/java/org/apache/camel/model/language/MethodCallExpression.java
@@ -28,6 +28,8 @@
import org.apache.camel.Predicate;
import org.apache.camel.component.bean.BeanHolder;
import org.apache.camel.component.bean.BeanInfo;
+import org.apache.camel.component.bean.ConstantBeanHolder;
+import org.apache.camel.component.bean.ConstantTypeBeanHolder;
import org.apache.camel.component.bean.MethodNotFoundException;
import org.apache.camel.component.bean.RegistryBean;
import org.apache.camel.language.bean.BeanExpression;
@@ -38,7 +40,7 @@
* For expressions and predicates using the
* <a href="http://camel.apache.org/bean-language.html">bean language</a>
*
- * @version
+ * @version
*/
@XmlRootElement(name = "method")
@XmlAccessorType(XmlAccessType.FIELD)
@@ -68,11 +70,11 @@ public MethodCallExpression(String beanName, String method) {
super(beanName);
this.method = method;
}
-
+
public MethodCallExpression(Object instance) {
this(instance, null);
}
-
+
public MethodCallExpression(Object instance, String method) {
super(ObjectHelper.className(instance));
// must use setter as they have special logic
@@ -83,7 +85,7 @@ public MethodCallExpression(Object instance, String method) {
public MethodCallExpression(Class<?> type) {
this(type, null);
}
-
+
public MethodCallExpression(Class<?> type, String method) {
super(type.getName());
this.beanType = type;
@@ -162,25 +164,30 @@ public Expression createExpression(CamelContext camelContext) {
}
}
+ BeanHolder holder;
if (beanType != null) {
// create a bean if there is a default public no-arg constructor
if (ObjectHelper.hasDefaultPublicNoArgConstructor(beanType)) {
instance = camelContext.getInjector().newInstance(beanType);
- answer = new BeanExpression(instance, getMethod());
+ holder = new ConstantBeanHolder(instance, camelContext);
} else {
- answer = new BeanExpression(beanType, getMethod());
+ holder = new ConstantTypeBeanHolder(beanType, camelContext);
}
} else if (instance != null) {
- answer = new BeanExpression(instance, getMethod());
+ holder = new ConstantBeanHolder(instance, camelContext);
} else {
String ref = beanName();
// if its a ref then check that the ref exists
- BeanHolder holder = new RegistryBean(camelContext, ref);
+ BeanHolder regHolder = new RegistryBean(camelContext, ref);
// get the bean which will check that it exists
- instance = holder.getBean();
- answer = new BeanExpression(instance, getMethod());
+ instance = regHolder.getBean();
+ holder = new ConstantBeanHolder(instance, camelContext);
}
+ // create answer using the holder
+ answer = new BeanExpression(holder, getMethod());
+
+ // and do sanity check that if a method name was given, that it exists
validateHasMethod(camelContext, instance, beanType, getMethod());
return answer;
}
View
6 camel-core/src/main/java/org/apache/camel/processor/validation/ValidatingProcessor.java
@@ -112,7 +112,7 @@ public void loadSchema() throws Exception {
// Properties
// -----------------------------------------------------------------------
- public synchronized Schema getSchema() throws IOException, SAXException {
+ public Schema getSchema() throws IOException, SAXException {
if (schema == null) {
schema = createSchema();
}
@@ -131,7 +131,7 @@ public void setSchemaLanguage(String schemaLanguage) {
this.schemaLanguage = schemaLanguage;
}
- public synchronized Source getSchemaSource() throws IOException {
+ public Source getSchemaSource() throws IOException {
if (schemaSource == null) {
schemaSource = createSchemaSource();
}
@@ -158,7 +158,7 @@ public void setSchemaFile(File schemaFile) {
this.schemaFile = schemaFile;
}
- public synchronized SchemaFactory getSchemaFactory() {
+ public SchemaFactory getSchemaFactory() {
if (schemaFactory == null) {
schemaFactory = createSchemaFactory();
}
View
124 camel-core/src/main/java/org/apache/camel/util/jsse/BaseSSLContextParameters.java
@@ -68,6 +68,20 @@
private static final Logger LOG = LoggerFactory.getLogger(BaseSSLContextParameters.class);
+ private static final String LS = System.getProperty("line.separator");
+
+ private static final String SSL_ENGINE_CIPHER_SUITE_LOG_MSG = createCipherSuiteLogMessage("SSLEngine");
+
+ private static final String SSL_SOCKET_CIPHER_SUITE_LOG_MSG = createCipherSuiteLogMessage("SSLSocket");
+
+ private static final String SSL_SERVER_SOCKET_CIPHER_SUITE_LOG_MSG = createCipherSuiteLogMessage("SSLServerSocket");
+
+ private static final String SSL_ENGINE_PROTOCOL_LOG_MSG = createProtocolLogMessage("SSLEngine");
+
+ private static final String SSL_SOCKET_PROTOCOL_LOG_MSG = createProtocolLogMessage("SSLSocket");
+
+ private static final String SSL_SERVER_SOCKET_PROTOCOL_LOG_MSG = createProtocolLogMessage("SSLServerSocket");
+
/**
* The optional explicitly configured cipher suites for this configuration.
*/
@@ -242,15 +256,16 @@ protected boolean getAllowPassthrough() {
* @throws GeneralSecurityException if there is an error configuring the context
*/
protected void configureSSLContext(SSLContext context) throws GeneralSecurityException {
- LOG.trace("Configuring client and server side SSLContext parameters...");
+ LOG.trace("Configuring client and server side SSLContext parameters on SSLContext [{}]...", context);
if (this.getSessionTimeout() != null) {
- LOG.debug("Configuring client and server side SSLContext session timeout: {}", this.getSessionTimeout());
+ LOG.debug("Configuring client and server side SSLContext session timeout on SSLContext [{}] to [{}]",
+ context, this.getSessionTimeout());
this.configureSessionContext(context.getClientSessionContext(), this.getSessionTimeout());
this.configureSessionContext(context.getServerSessionContext(), this.getSessionTimeout());
}
- LOG.trace("Configured client and server side SSLContext parameters.");
+ LOG.trace("Configured client and server side SSLContext parameters on SSLContext [{}].", context);
}
protected FilterParameters getDefaultCipherSuitesFilter() {
@@ -325,7 +340,17 @@ public SSLEngine configure(SSLEngine engine) {
enabledCipherSuitePatterns, defaultEnabledCipherSuitePatterns,
!allowPassthrough);
- LOG.trace("Enabled ChiperSuites: {}", filteredCipherSuites);
+ if (LOG.isDebugEnabled()) {
+ LOG.debug(SSL_ENGINE_CIPHER_SUITE_LOG_MSG,
+ new Object[] {engine,
+ enabledCipherSuites,
+ enabledCipherSuitePatterns,
+ engine.getSSLParameters().getCipherSuites(),
+ engine.getEnabledCipherSuites(),
+ defaultEnabledCipherSuitePatterns,
+ filteredCipherSuites});
+ }
+
engine.setEnabledCipherSuites(filteredCipherSuites.toArray(new String[filteredCipherSuites.size()]));
Collection<String> filteredSecureSocketProtocols = BaseSSLContextParameters.this
@@ -334,9 +359,19 @@ public SSLEngine configure(SSLEngine engine) {
enabledSecureSocketProtocolsPatterns, defaultEnabledSecureSocketProtocolsPatterns,
!allowPassthrough);
+ if (LOG.isDebugEnabled()) {
+ LOG.debug(SSL_ENGINE_PROTOCOL_LOG_MSG,
+ new Object[] {engine,
+ enabledSecureSocketProtocols,
+ enabledSecureSocketProtocolsPatterns,
+ engine.getSSLParameters().getProtocols(),
+ engine.getEnabledProtocols(),
+ defaultEnabledSecureSocketProtocolsPatterns,
+ filteredSecureSocketProtocols});
+ }
+
engine.setEnabledProtocols(filteredSecureSocketProtocols.toArray(new String[filteredSecureSocketProtocols.size()]));
- LOG.trace("Enabled Protocols: {}", filteredSecureSocketProtocols);
-
+
return engine;
}
};
@@ -482,6 +517,16 @@ public SSLSocket configure(SSLSocket socket) {
Arrays.asList(socket.getEnabledCipherSuites()),
enabledCipherSuitePatterns, defaultEnabledCipherSuitePatterns,
!allowPassthrough);
+ if (LOG.isDebugEnabled()) {
+ LOG.debug(SSL_SOCKET_CIPHER_SUITE_LOG_MSG,
+ new Object[] {socket,
+ enabledCipherSuites,
+ enabledCipherSuitePatterns,
+ socket.getSSLParameters().getCipherSuites(),
+ socket.getEnabledCipherSuites(),
+ defaultEnabledCipherSuitePatterns,
+ filteredCipherSuites});
+ }
socket.setEnabledCipherSuites(filteredCipherSuites.toArray(new String[filteredCipherSuites.size()]));
@@ -491,6 +536,17 @@ public SSLSocket configure(SSLSocket socket) {
enabledSecureSocketProtocolsPatterns, defaultEnabledSecureSocketProtocolsPatterns,
!allowPassthrough);
+ if (LOG.isDebugEnabled()) {
+ LOG.debug(SSL_SOCKET_PROTOCOL_LOG_MSG,
+ new Object[] {socket,
+ enabledSecureSocketProtocols,
+ enabledSecureSocketProtocolsPatterns,
+ socket.getSSLParameters().getProtocols(),
+ socket.getEnabledProtocols(),
+ defaultEnabledSecureSocketProtocolsPatterns,
+ filteredSecureSocketProtocols});
+ }
+
socket.setEnabledProtocols(filteredSecureSocketProtocols.toArray(new String[filteredSecureSocketProtocols.size()]));
return socket;
}
@@ -561,13 +617,35 @@ public SSLServerSocket configure(SSLServerSocket socket) {
enabledCipherSuitePatterns, defaultEnabledCipherSuitePatterns,
!allowPassthrough);
+ if (LOG.isDebugEnabled()) {
+ LOG.debug(SSL_SERVER_SOCKET_CIPHER_SUITE_LOG_MSG,
+ new Object[] {socket,
+ enabledCipherSuites,
+ enabledCipherSuitePatterns,
+ socket.getSupportedCipherSuites(),
+ socket.getEnabledCipherSuites(),
+ defaultEnabledCipherSuitePatterns,
+ filteredCipherSuites});
+ }
+
socket.setEnabledCipherSuites(filteredCipherSuites.toArray(new String[filteredCipherSuites.size()]));
Collection<String> filteredSecureSocketProtocols = BaseSSLContextParameters.this
.filter(enabledSecureSocketProtocols, Arrays.asList(socket.getSupportedProtocols()),
Arrays.asList(socket.getEnabledProtocols()),
enabledSecureSocketProtocolsPatterns, defaultEnabledSecureSocketProtocolsPatterns,
!allowPassthrough);
+
+ if (LOG.isDebugEnabled()) {
+ LOG.debug(SSL_SERVER_SOCKET_PROTOCOL_LOG_MSG,
+ new Object[] {socket,
+ enabledSecureSocketProtocols,
+ enabledSecureSocketProtocolsPatterns,
+ socket.getSupportedProtocols(),
+ socket.getEnabledProtocols(),
+ defaultEnabledSecureSocketProtocolsPatterns,
+ filteredSecureSocketProtocols});
+ }
socket.setEnabledProtocols(filteredSecureSocketProtocols.toArray(new String[filteredSecureSocketProtocols.size()]));
return socket;
@@ -732,13 +810,14 @@ protected boolean matchesOneOf(String value, List<Pattern> patterns) {
public SSLContextDecorator(SSLContextSpiDecorator decorator) {
super(decorator, decorator.getDelegate().getProvider(), decorator.getDelegate().getProtocol());
+ LOG.debug("SSLContextDecorator [{}] decorating SSLContext [{}].", this, decorator.getDelegate());
}
@Override
public String toString() {
- return String.format("SSLContext[provider=%s, protocol=%s, needClientAuth=%s, "
+ return String.format("SSLContext[hash=%h, provider=%s, protocol=%s, needClientAuth=%s, "
+ "wantClientAuth=%s\n\tdefaultProtocols=%s\n\tdefaultChiperSuites=%s\n\tsupportedProtocols=%s\n\tsupportedChiperSuites=%s\n]",
- getProvider(), getProtocol(), getDefaultSSLParameters().getNeedClientAuth(), getDefaultSSLParameters().getWantClientAuth(),
+ hashCode(), getProvider(), getProtocol(), getDefaultSSLParameters().getNeedClientAuth(), getDefaultSSLParameters().getWantClientAuth(),
collectionAsCommaDelimitedString(getDefaultSSLParameters().getProtocols()),
collectionAsCommaDelimitedString(getDefaultSSLParameters().getCipherSuites()),
collectionAsCommaDelimitedString(getSupportedSSLParameters().getProtocols()),
@@ -776,13 +855,15 @@ public SSLContextSpiDecorator(SSLContext context,
@Override
protected SSLEngine engineCreateSSLEngine() {
SSLEngine engine = this.context.createSSLEngine();
+ LOG.debug("SSLEngine [{}] created from SSLContext [{}].", engine, context);
this.configureSSLEngine(engine);
return engine;
}
@Override
protected SSLEngine engineCreateSSLEngine(String peerHost, int peerPort) {
SSLEngine engine = this.context.createSSLEngine(peerHost, peerPort);
+ LOG.debug("SSLEngine [{}] created from SSLContext [{}].", engine, context);
return this.configureSSLEngine(engine);
}
@@ -799,12 +880,14 @@ protected SSLSessionContext engineGetServerSessionContext() {
@Override
protected SSLServerSocketFactory engineGetServerSocketFactory() {
SSLServerSocketFactory factory = this.context.getServerSocketFactory();
+ LOG.debug("SSLServerSocketFactoryEngine [{}] created from SSLContext [{}].", factory, context);
return this.configureSSLServerSocketFactory(factory);
}
@Override
protected SSLSocketFactory engineGetSocketFactory() {
- SSLSocketFactory factory = this.context.getSocketFactory();
+ SSLSocketFactory factory = this.context.getSocketFactory();
+ LOG.debug("SSLSocketFactory [{}] created from SSLContext [{}].", factory, context);
return this.configureSSLSocketFactory(factory);
}
@@ -932,6 +1015,8 @@ public SSLServerSocketFactory getDelegate() {
private ServerSocket configureSocket(ServerSocket s) {
SSLServerSocket workingSocket = (SSLServerSocket) s;
+
+ LOG.debug("Created ServerSocket [{}] from SslServerSocketFactory [{}].", s, sslServerSocketFactory);
for (Configurer<SSLServerSocket> configurer : this.sslServerSocketConfigurers) {
workingSocket = configurer.configure(workingSocket);
@@ -1006,6 +1091,8 @@ public SSLSocketFactory getDelegate() {
private Socket configureSocket(Socket s) {
SSLSocket workingSocket = (SSLSocket) s;
+
+ LOG.debug("Created Socket [{}] from SocketFactory [{}].", s, sslSocketFactory);
for (Configurer<SSLSocket> configurer : this.sslSocketConfigurers) {
workingSocket = configurer.configure(workingSocket);
@@ -1015,4 +1102,23 @@ private Socket configureSocket(Socket s) {
}
}
+ private static String createCipherSuiteLogMessage(String entityName) {
+ return "Configuring " + entityName + " [{}] with " + LS
+ + "\t explicitly set cipher suites [{}]," + LS
+ + "\t cipher suite patterns [{}]," + LS
+ + "\t available cipher suites [{}]," + LS
+ + "\t currently enabled cipher suites [{}]," + LS
+ + "\t and default cipher suite patterns [{}]." + LS
+ + "\t Resulting enabled cipher suites are [{}].";
+ }
+
+ private static String createProtocolLogMessage(String entityName) {
+ return "Configuring " + entityName + " [{}] with " + LS
+ + "\t explicitly set protocols [{}]," + LS
+ + "\t protocol patterns [{}]," + LS
+ + "\t available protocols [{}]," + LS
+ + "\t currently enabled protocols [{}]," + LS
+ + "\t and default protocol patterns [{}]." + LS
+ + "\t Resulting enabled protocols are [{}].";
+ }
}
View
13 camel-core/src/main/java/org/apache/camel/util/jsse/FilterParameters.java
@@ -126,7 +126,18 @@ public Patterns(List<Pattern> includes, List<Pattern> excludes) {
public List<Pattern> getExcludes() {
return excludes;
- }
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder builder = new StringBuilder();
+ builder.append("Patterns [includes=");
+ builder.append(includes);
+ builder.append(", excludes=");
+ builder.append(excludes);
+ builder.append("]");
+ return builder.toString();
+ }
}
@Override
View
42 camel-core/src/main/java/org/apache/camel/util/jsse/JsseParameters.java
@@ -121,54 +121,60 @@ protected InputStream resolveResource(String resource) throws IOException {
InputStream is = null;
try {
- LOG.trace("Trying to open resource as a file.");
+ LOG.trace("Trying to open resource [{}] as a file.", resource);
is = new FileInputStream(resource);
- LOG.debug("Loaded resource as file {}", resource);
+ LOG.debug("Opened resource [{}] as a file.", resource);
} catch (FileNotFoundException e) {
- LOG.trace("Could not open resource as a file.", e);
+ LOG.trace("Could not open resource [" + resource + "] as a file.", e);
}
if (is == null && Thread.currentThread().getContextClassLoader() != null) {
- LOG.trace("Trying to open resource as a class path resource with the TCCL {}.",
- Thread.currentThread().getContextClassLoader());
+ LOG.trace("Trying to open resource [{}] as a class path resource with the TCCL [{}].",
+ resource, Thread.currentThread().getContextClassLoader());
is = Thread.currentThread().getContextClassLoader().getResourceAsStream(resource);
+
if (is == null) {
- LOG.trace("Could not open resource as a class path resource using the TCCL {}.",
- Thread.currentThread().getContextClassLoader());
+ LOG.trace("Could not open resource [{}] as a class path resource using the TCCL [{}].",
+ resource, Thread.currentThread().getContextClassLoader());
} else {
- LOG.debug("Loaded resource from TCCL ClassLoader {}", resource);
+ LOG.debug("Opened resource [{}] as a class path resource with the TCCL [{}].",
+ resource, Thread.currentThread().getContextClassLoader());
}
}
if (is == null) {
- LOG.trace("Trying to open resource as a class path resource using the classloader {}.",
+ LOG.trace("Trying to open resource [{}] as a class path resource using the classloader [{}].",
this.getClass().getClassLoader());
is = this.getClass().getResourceAsStream(resource);
+
if (is == null) {
- LOG.trace("Could not open resource as a class path resource using the classloader {}.",
- this.getClass().getClassLoader());
+ LOG.trace("Could not open resource [{}] as a class path resource using the classloader [{}].",
+ resource, this.getClass().getClassLoader());
} else {
- LOG.debug("Loaded resource from JsseParameter ClassLoader {}", resource);
+ LOG.debug("Opened resource [{}] as a class path resource with the classloader [{}].",
+ resource, this.getClass().getClassLoader());
}
}
if (is == null) {
try {
- LOG.trace("Trying to open resource as a URL.");
+ LOG.trace("Trying to open resource [{}] as a URL.", resource);
is = new URL(resource).openStream();
- LOG.debug("Loaded resource as URL {}", resource);
+ LOG.debug("Opened resource [{}] as a URL.", resource);
} catch (IOException e) {
- LOG.trace("Could not open resource as a URL", e);
+ LOG.trace("Could not open resource [" + resource + "] as a URL.", e);
}
}
if (is == null && this.context != null) {
- LOG.trace("Trying to open resource using the CamelContext ClassResolver {}", context.getClassResolver());
+ LOG.trace("Trying to open resource using the CamelContext ClassResolver [{}].", context.getClassResolver());
is = context.getClassResolver().loadResourceAsStream(resource);
if (is == null) {
- LOG.trace("Could not to open resource using the CamelContext ClassResolver {}.", context.getClassResolver());
+ LOG.trace("Could not to open resource [{}] using the CamelContext ClassResolver [{}].",
+ resource, context.getClassResolver());
} else {
- LOG.debug("Loaded resource using the CamelContext ClassResolver {}", resource);
+ LOG.debug("Opened resource [{}] using the CamelContext ClassResolver [{}].",
+ resource, this.getClass().getClassLoader());
}
}
View
10 camel-core/src/main/java/org/apache/camel/util/jsse/KeyManagersParameters.java
@@ -81,10 +81,10 @@
*/
public KeyManager[] createKeyManagers() throws GeneralSecurityException, IOException {
- LOG.debug("Creating KeyManager[] from KeyManagersParameters: {}", this);
+ LOG.trace("Creating KeyManager[] from KeyManagersParameters [{}].", this);
KeyManager[] keyManagers;
-
+
String kmfAlgorithm = this.parsePropertyValue(this.getAlgorithm());
if (kmfAlgorithm == null) {
kmfAlgorithm = KeyManagerFactory.getDefaultAlgorithm();
@@ -96,7 +96,9 @@
} else {
kmf = KeyManagerFactory.getInstance(kmfAlgorithm, this.parsePropertyValue(this.getProvider()));
}
-
+
+ LOG.debug("KeyManagerFactory [{}], initialized from [{}], is using provider [{}] and algorithm [{}].",
+ new Object[] {kmf, this, kmf.getProvider(), kmf.getAlgorithm()});
char[] kmfPassword = null;
if (this.getKeyPassword() != null) {
@@ -108,6 +110,8 @@
kmf.init(ks, kmfPassword);
keyManagers = kmf.getKeyManagers();
+ LOG.debug("KeyManager[] [{}], initialized from KeyManagerFactory [{}].", keyManagers, kmf);
+
return keyManagers;
}
View
21 camel-core/src/main/java/org/apache/camel/util/jsse/KeyStoreParameters.java
@@ -21,6 +21,9 @@
import java.security.GeneralSecurityException;
import java.security.KeyStore;
import java.security.Security;
+import java.util.Enumeration;
+import java.util.LinkedList;
+import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -146,7 +149,7 @@ public void setResource(String value) {
* resource to an input stream
*/
public KeyStore createKeyStore() throws GeneralSecurityException, IOException {
- LOG.debug("Creating KeyStore instance from KeyStoreParameters: {}", this);
+ LOG.trace("Creating KeyStore instance from KeyStoreParameters [{}].", this);
String ksType = this.parsePropertyValue(this.type);
if (ksType == null) {
@@ -164,14 +167,26 @@ public KeyStore createKeyStore() throws GeneralSecurityException, IOException {
} else {
ks = KeyStore.getInstance(ksType, this.parsePropertyValue(this.provider));
}
-
+
if (this.resource == null) {
ks.load(null, ksPassword);
} else {
InputStream is = this.resolveResource(this.parsePropertyValue(this.resource));
ks.load(is, ksPassword);
}
-
+
+ if (LOG.isDebugEnabled()) {
+ List<String> aliases = new LinkedList<String>();
+
+ Enumeration<String> aliasEnum = ks.aliases();
+ while (aliasEnum.hasMoreElements()) {
+ aliases.add(aliasEnum.nextElement());
+ }
+
+ LOG.debug("KeyStore [{}], initialized from [{}], is using provider [{}], has type [{}], and contains aliases {}.",
+ new Object[] {ks, this, ks.getProvider(), ks.getType(), aliases});
+ }
+
return ks;
}
View
6 camel-core/src/main/java/org/apache/camel/util/jsse/SSLContextClientParameters.java
@@ -41,12 +41,12 @@ protected boolean getAllowPassthrough() {
@Override
protected void configureSSLContext(SSLContext context) throws GeneralSecurityException {
- LOG.trace("Configuring client-side SSLContext parameters...");
+ LOG.trace("Configuring client-side SSLContext parameters on SSLContext [{}]...", context);
if (this.getSessionTimeout() != null) {
- LOG.debug("Configuring client-side SSLContext session timeout: " + this.getSessionTimeout());
+ LOG.info("Configuring client-side SSLContext session timeout on SSLContext [{}] to [{}].", context, this.getSessionTimeout());
this.configureSessionContext(context.getClientSessionContext(), this.getSessionTimeout());
}
- LOG.trace("Configured client-side SSLContext parameters.");
+ LOG.trace("Configured client-side SSLContext parameters on SSLContext [{}].", context);
}
/**
View
43 camel-core/src/main/java/org/apache/camel/util/jsse/SSLContextParameters.java
@@ -229,7 +229,9 @@ public void setSecureSocketProtocol(String secureSocketProtocol) {
*/
public SSLContext createSSLContext() throws GeneralSecurityException, IOException {
- LOG.trace("Creating SSLContext from SSLContextParameters: {}", this);
+ LOG.trace("Creating SSLContext from SSLContextParameters [{}].", this);
+
+ LOG.info("Available providers: {}.", Security.getProviders());
KeyManager[] keyManagers = this.keyManagers == null ? null : this.keyManagers.createKeyManagers();
TrustManager[] trustManagers = this.trustManagers == null ? null : this.trustManagers.createTrustManagers();
@@ -243,6 +245,9 @@ public SSLContext createSSLContext() throws GeneralSecurityException, IOExceptio
this.parsePropertyValue(this.getProvider()));
}
+ LOG.debug("SSLContext [{}], initialized from [{}], is using provider [{}], protocol [{}], key managers {}, trust managers {}, and secure random [{}].",
+ new Object[] {context, this, context.getProvider(), context.getProtocol(), keyManagers, trustManagers, secureRandom});
+
context.init(keyManagers, trustManagers, secureRandom);
this.configureSSLContext(context);
@@ -254,74 +259,80 @@ public SSLContext createSSLContext() throws GeneralSecurityException, IOExceptio
this.getSSLEngineConfigurers(context),
this.getSSLSocketFactoryConfigurers(context),
this.getSSLServerSocketFactoryConfigurers(context)));
- LOG.debug("Created {}", context);
+
return context;
}
@Override
protected void configureSSLContext(SSLContext context) throws GeneralSecurityException {
- LOG.trace("Configuring client and server side SSLContext parameters...");
+ LOG.trace("Configuring client and server side SSLContext parameters on SSLContext [{}]...", context);
super.configureSSLContext(context);
if (this.getClientParameters() != null) {
- LOG.trace("Overriding client-side SSLContext parameters with configured client parameters.");
+ LOG.trace("Overriding client-side SSLContext parameters on SSLContext [{}] with configured client parameters.",
+ context);
this.getClientParameters().configureSSLContext(context);
}
if (this.getServerParameters() != null) {
- LOG.trace("Overriding server-side SSLContext parameters with configured server parameters.");
+ LOG.trace("Overriding server-side SSLContext parameters on SSLContext [{}] with configured server parameters.",
+ context);
this.getServerParameters().configureSSLContext(context);
}
- LOG.trace("Configured client and server side SSLContext parameters.");
+ LOG.trace("Configured client and server side SSLContext parameters on SSLContext [{}].", context);
}
@Override
protected List<Configurer<SSLEngine>> getSSLEngineConfigurers(SSLContext context) {
- LOG.trace("Collecting client and server side SSLEngine configurers...");
+ LOG.trace("Collecting client and server side SSLEngine configurers on SSLContext [{}]...", context);
List<Configurer<SSLEngine>> configurers = super.getSSLEngineConfigurers(context);
if (this.getClientParameters() != null) {
- LOG.trace("Augmenting SSLEngine configurers with configurers from client parameters.");
+ LOG.trace("Augmenting SSLEngine configurers with configurers from client parameters on SSLContext [{}].",
+ context);
configurers.addAll(this.getClientParameters().getSSLEngineConfigurers(context));
}
if (this.getServerParameters() != null) {
- LOG.trace("Augmenting SSLEngine configurers with configurers from server parameters.");
+ LOG.trace("Augmenting SSLEngine configurers with configurers from server parameters on SSLContext [{}].",
+ context);
configurers.addAll(this.getServerParameters().getSSLEngineConfigurers(context));
}
- LOG.trace("Collected client and server side SSLEngine configurers.");
+ LOG.trace("Collected client and server side SSLEngine configurers on SSLContext [{}].", context);
return configurers;
}
@Override
protected List<Configurer<SSLSocketFactory>> getSSLSocketFactoryConfigurers(SSLContext context) {
- LOG.trace("Collecting SSLSocketFactory configurers...");
+ LOG.trace("Collecting SSLSocketFactory configurers on SSLContext [{}]...", context);
List<Configurer<SSLSocketFactory>> configurers = super.getSSLSocketFactoryConfigurers(context);
if (this.getClientParameters() != null) {
- LOG.trace("Augmenting SSLSocketFactory configurers with configurers from client parameters.");
+ LOG.trace("Augmenting SSLSocketFactory configurers with configurers from client parameters on SSLContext [{}].",
+ context);
configurers.addAll(this.getClientParameters().getSSLSocketFactoryConfigurers(context));
}
- LOG.trace("Collected SSLSocketFactory configurers.");
+ LOG.trace("Collected SSLSocketFactory configurers on SSLContext [{}].", context);
return configurers;
}
@Override
protected List<Configurer<SSLServerSocketFactory>> getSSLServerSocketFactoryConfigurers(SSLContext context) {
- LOG.trace("Collecting SSLServerSocketFactory configurers...");
+ LOG.trace("Collecting SSLServerSocketFactory configurers for SSLContext [{}]...", context);
List<Configurer<SSLServerSocketFactory>> configurers = super.getSSLServerSocketFactoryConfigurers(context);
if (this.getServerParameters() != null) {
- LOG.trace("Augmenting SSLServerSocketFactory configurers with configurers from server parameters.");
+ LOG.trace("Augmenting SSLServerSocketFactory configurers with configurers from server parameters for SSLContext [{}].",
+ context);
configurers.addAll(this.getServerParameters().getSSLServerSocketFactoryConfigurers(context));
}
- LOG.trace("Collected client and server side SSLServerSocketFactory configurers.");
+ LOG.trace("Collected client and server side SSLServerSocketFactory configurers for SSLContext [{}].", context);
return configurers;
}
View
8 camel-core/src/main/java/org/apache/camel/util/jsse/SSLContextServerParameters.java
@@ -63,12 +63,12 @@ protected boolean getAllowPassthrough() {
@Override
protected void configureSSLContext(SSLContext context) throws GeneralSecurityException {
- LOG.trace("Configuring server-side SSLContext parameters...");
+ LOG.trace("Configuring server-side SSLContext parameters on SSLContext [{}]...", context);
if (this.getSessionTimeout() != null) {
- LOG.debug("Configuring server-side SSLContext session timeout: " + this.getSessionTimeout());
+ LOG.debug("Configuring server-side SSLContext session timeout on SSLContext [{}] to [{}].", context, this.getSessionTimeout());
this.configureSessionContext(context.getServerSessionContext(), this.getSessionTimeout());
}
- LOG.trace("Configured server-side SSLContext parameters.");
+ LOG.trace("Configured server-side SSLContext parameters on SSLContext [{}].", context);
}
/**
@@ -97,6 +97,7 @@ protected void configureSSLContext(SSLContext context) throws GeneralSecurityExc
Configurer<SSLEngine> sslEngineConfigurer = new Configurer<SSLEngine>() {
@Override
public SSLEngine configure(SSLEngine engine) {
+ LOG.info("Configuring client-auth on SSLEngine [{}] to [{}].", engine, clientAuthValue);
switch (clientAuthValue) {
case NONE:
engine.setWantClientAuth(false);
@@ -135,6 +136,7 @@ public SSLEngine configure(SSLEngine engine) {
Configurer<SSLServerSocket> sslServerSocketConfigurer = new Configurer<SSLServerSocket>() {
@Override
public SSLServerSocket configure(SSLServerSocket socket) {
+ LOG.info("Configuring client-auth on SSLServerSocket [{}] to [{}].", socket, clientAuthValue);
switch (clientAuthValue) {
case NONE:
socket.setWantClientAuth(false);
View
3 camel-core/src/main/java/org/apache/camel/util/jsse/SecureRandomParameters.java
@@ -65,6 +65,9 @@ public SecureRandom createSecureRandom() throws GeneralSecurityException {
} else {
secureRandom = SecureRandom.getInstance(this.parsePropertyValue(this.getAlgorithm()));
}
+
+ LOG.debug("SecureRandom [{}] is using provider [{}] and algorithm [{}].",
+ new Object[] {secureRandom, secureRandom.getProvider(), secureRandom.getAlgorithm()});
return secureRandom;
}
View
7 camel-core/src/main/java/org/apache/camel/util/jsse/TrustManagersParameters.java
@@ -71,7 +71,7 @@
*/
public TrustManager[] createTrustManagers() throws GeneralSecurityException, IOException {
- LOG.trace("Creating TrustManager[] from TrustManagersParameters: {}", this);
+ LOG.trace("Creating TrustManager[] from TrustManagersParameters [{}]", this);
TrustManager[] trustManagers = null;
@@ -88,9 +88,14 @@
tmf = TrustManagerFactory.getInstance(tmfAlgorithm, this.parsePropertyValue(this.getProvider()));
}
+ LOG.debug("TrustManagerFactory [{}] is using provider [{}] and algorithm [{}].",
+ new Object[] {tmf, tmf.getProvider(), tmf.getAlgorithm()});
+
KeyStore ks = this.getKeyStore() == null ? null : this.getKeyStore().createKeyStore();
tmf.init(ks);
trustManagers = tmf.getTrustManagers();
+
+ LOG.debug("TrustManager[] [{}], initialized from TrustManagerFactory [{}].", trustManagers, tmf);
}
return trustManagers;
View
36 camel-core/src/test/java/org/apache/camel/builder/ThreadPoolBuilderTest.java
@@ -18,6 +18,7 @@
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import org.apache.camel.ContextTestSupport;
@@ -125,4 +126,39 @@ public void testThreadPoolBuilderTwoPoolsDefault() throws Exception {
assertEquals(true, executor2.isShutdown());
}
+ public void testThreadPoolBuilderScheduled() throws Exception {
+ ThreadPoolBuilder builder = new ThreadPoolBuilder(context);
+ ScheduledExecutorService executor = builder.poolSize(5).maxQueueSize(2000)
+ .buildScheduled();
+ assertNotNull(executor);
+
+ assertEquals(false, executor.isShutdown());
+ context.stop();
+ assertEquals(true, executor.isShutdown());
+ }
+
+ public void testThreadPoolBuilderScheduledName() throws Exception {
+ ThreadPoolBuilder builder = new ThreadPoolBuilder(context);
+ ScheduledExecutorService executor = builder.poolSize(5).maxQueueSize(2000)
+ .buildScheduled("myScheduledPool");
+ assertNotNull(executor);
+
+ assertEquals(false, executor.isShutdown());
+ context.stop();
+ assertEquals(true, executor.isShutdown());
+ }
+
+
+ public void testThreadPoolBuilderScheduledSourceName() throws Exception {
+ ThreadPoolBuilder builder = new ThreadPoolBuilder(context);
+ ScheduledExecutorService executor = builder.poolSize(5).maxQueueSize(2000)
+ .buildScheduled(this, "myScheduledPool");
+ assertNotNull(executor);
+
+ assertEquals(false, executor.isShutdown());
+ context.stop();
+ assertEquals(true, executor.isShutdown());
+ }
+
+
}
View
128 camel-core/src/test/java/org/apache/camel/component/bean/BeanExpressionConcurrentTest.java
@@ -0,0 +1,128 @@
+/**
+ * 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.component.bean;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.impl.JndiRegistry;
+
+/**
+ * @version
+ */
+public class BeanExpressionConcurrentTest extends ContextTestSupport {
+
+ public void testBeanConcurrent() throws Exception {
+ MockEndpoint mock = getMockEndpoint("mock:result");
+ mock.expectedMessageCount(1000);
+ mock.expectsNoDuplicates(body());
+
+ // start from 1000 to be 4 digit always (easier to string compare)
+ for (int i = 1000; i < 2000; i++) {
+ template.sendBody("seda:foo", "" + i);
+ }
+
+ context.startRoute("foo");
+
+ assertMockEndpointsSatisfied();
+
+ // should be 1000 messages
+ List<String> list = new ArrayList<String>();
+ for (int i = 0; i < 1000; i++) {
+ String body = mock.getReceivedExchanges().get(i).getIn().getBody(String.class);
+ list.add(body);
+ }
+ Collections.sort(list);
+
+ // and they should be unique and no lost messages
+ assertEquals(1000, list.size());
+ for (int i = 1; i < 1000; i++) {
+ int num = 1000 + i;
+ String s = "" + num + " " + num;
+ assertEquals(s, list.get(i));
+ }
+ }
+
+
+ @Override
+ protected JndiRegistry createRegistry() throws Exception {
+ JndiRegistry jndi = super.createRegistry();
+ jndi.bind("myBean", new MyBean());
+ return jndi;
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+ from("seda:foo?concurrentConsumers=10").routeId("foo").noAutoStartup()
+ .transform(method("myBean"))
+ .to("mock:result");
+ }
+ };
+ }
+
+ @SuppressWarnings("unused")
+ private static class MyBean {
+
+ private String foo;
+ private String bar;
+ private int baz;
+
+ public String getFoo() {
+ return foo;
+ }
+
+ public void setFoo(String foo) {
+ this.foo = foo;
+ }
+
+ public String getBar() {
+ return bar;
+ }
+
+ public void setBar(String bar) {
+ this.bar = bar;
+ }
+
+ public int getBaz() {
+ return baz;
+ }
+
+ public void setBaz(int baz) {
+ this.baz = baz;
+ }
+
+ public void doSomething() {
+ // noop
+ }
+
+ public String echo(String s) {
+ return s + " " + s;
+ }
+
+ @Override
+ public String toString() {
+ return "MyBean";
+ }
+ }
+}
View
59 .../test/java/org/apache/camel/component/file/FileConsumerSharedThreadPollStopRouteTest.java
@@ -0,0 +1,59 @@
+/**
+ * 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.component.file;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.component.mock.MockEndpoint;
+
+/**
+ *
+ */
+public class FileConsumerSharedThreadPollStopRouteTest extends FileConsumerSharedThreadPollTest {
+
+ public void testSharedThreadPool() throws Exception {
+ MockEndpoint mock = getMockEndpoint("mock:result");
+ mock.expectedMessageCount(2);
+ // thread thread name should be the same
+ mock.message(0).header("threadName").isEqualTo(mock.message(1).header("threadName"));
+
+ template.sendBodyAndHeader("file:target/a", "Hello World", Exchange.FILE_NAME, "hello.txt");
+ template.sendBodyAndHeader("file:target/b", "Bye World", Exchange.FILE_NAME, "bye.txt");
+
+ assertMockEndpointsSatisfied();
+
+ // now stop a
+ context.stopRoute("a");
+
+ resetMocks();
+ mock.expectedBodiesReceived("Bye World 2");
+ // a should not be polled
+ mock.expectedFileExists("target/a/hello2.txt");
+
+ template.sendBodyAndHeader("file:target/a", "Hello World 2", Exchange.FILE_NAME, "hello2.txt");
+ template.sendBodyAndHeader("file:target/b", "Bye World 2", Exchange.FILE_NAME, "bye2.txt");
+
+ assertMockEndpointsSatisfied();
+
+ // now start a, which should pickup the file
+ resetMocks();
+ mock.expectedBodiesReceived("Hello World 2");
+ context.startRoute("a");
+
+ assertMockEndpointsSatisfied();
+ }
+
+}
View
91 ...-core/src/test/java/org/apache/camel/component/file/FileConsumerSharedThreadPollTest.java
@@ -0,0 +1,91 @@
+/**
+ * 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.component.file;
+
+import java.util.concurrent.ScheduledExecutorService;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.builder.ThreadPoolBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.impl.DefaultCamelContext;
+import org.apache.camel.impl.SimpleRegistry;
+
+/**
+ *
+ */
+public class FileConsumerSharedThreadPollTest extends ContextTestSupport {
+
+ private ScheduledExecutorService pool;
+ private SimpleRegistry registry = new SimpleRegistry();
+
+ @Override
+ protected void setUp() throws Exception {
+ deleteDirectory("target/a");
+ deleteDirectory("target/b");
+ super.setUp();
+ }
+
+ @Override
+ protected CamelContext createCamelContext() throws Exception {
+ return new DefaultCamelContext(registry);
+ }
+
+ public void testSharedThreadPool() throws Exception {
+ MockEndpoint mock = getMockEndpoint("mock:result");
+ mock.expectedMessageCount(2);
+ // thread thread name should be the same
+ mock.message(0).header("threadName").isEqualTo(mock.message(1).header("threadName"));
+
+ template.sendBodyAndHeader("file:target/a", "Hello World", Exchange.FILE_NAME, "hello.txt");
+ template.sendBodyAndHeader("file:target/b", "Bye World", Exchange.FILE_NAME, "bye.txt");
+
+ assertMockEndpointsSatisfied();
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+ // create shared pool and enlist in registry
+ pool = new ThreadPoolBuilder(context).poolSize(1).buildScheduled(this, "MySharedPool");
+ registry.put("myPool", pool);
+
+ from("file:target/a?scheduledExecutorService=#myPool").routeId("a")
+ .to("direct:shared");
+
+ from("file:target/b?scheduledExecutorService=#myPool").routeId("b")
+ .to("direct:shared");
+
+ from("direct:shared").routeId("shared")
+ .convertBodyTo(String.class)
+ .log("Get ${file:name} using ${threadName}")
+ .process(new Processor() {
+ @Override
+ public void process(Exchange exchange) throws Exception {
+ exchange.getIn().setHeader("threadName", Thread.currentThread().getName());
+ }
+ })
+ .to("mock:result");
+ }
+ };
+ }
+}
View
101 ...e/src/test/java/org/apache/camel/processor/DeadLetterChannelRestartFromBeginningTest.java
@@ -0,0 +1,101 @@
+/**
+ * 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.processor;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.RecipientList;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.impl.JndiRegistry;
+
+/**
+ *
+ */
+public class DeadLetterChannelRestartFromBeginningTest extends ContextTestSupport {
+
+ @Override
+ protected JndiRegistry createRegistry() throws Exception {
+ JndiRegistry jndi = super.createRegistry();
+ jndi.bind("retryBean", new RetryBean());
+ return jndi;
+ }
+
+ public void testRestartFromBeginning() throws Exception {
+ // 1 original + 4 redeliveries
+ getMockEndpoint("mock:start").expectedBodiesReceived("Camel", "Camel", "Camel", "Camel", "Camel");
+ getMockEndpoint("mock:result").expectedBodiesReceived("Hello Camel");
+
+ // use fire and forget
+ template.sendBody("seda:start", "Camel");
+
+ setAssertPeriod(200);
+ assertMockEndpointsSatisfied();
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+ // use the DLQ and let the retryBean handle this
+ errorHandler(deadLetterChannel("bean:retryBean").useOriginalMessage());
+
+ // use seda:retry as a way of retrying from the input route
+ // the seda:start could be any other kind of fire and forget endpoint
+ from("seda:start", "seda:retry")
+ .to("log:start", "mock:start")
+ .transform(body().prepend("Hello "))
+ .process(new Processor() {
+ private int counter;
+ @Override
+ public void process(Exchange exchange) throws Exception {
+ // fail the first 3 times
+ if (counter++ <= 3) {
+ throw new IllegalArgumentException("Damn");
+ }
+ }
+ })
+ .to("mock:result");
+ }
+ };
+ }
+
+ /**
+ * Bean used as dead letter queue, that decides what to do with the message
+ */
+ public static class RetryBean {
+
+ // use recipient list to decide what to do with the message
+ @RecipientList
+ public String handleError(Exchange exchange) {
+ // store a property on the exchange with the number of total attempts
+ int attempts = exchange.getProperty("attempts", 0, int.class);
+ attempts++;
+ exchange.setProperty("attempts", attempts);
+
+ // we want to retry at most 4 times
+ if (attempts <= 4) {
+ return "seda:retry";
+ } else {
+ // okay we give up its a poison message
+ return "log:giveup";
+ }
+ }
+ }
+
+}
View
69 camel-core/src/test/java/org/apache/camel/processor/WireTapBeanTest.java
@@ -0,0 +1,69 @@
+/**
+ * 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.processor;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+
+/**
+ * Wire tap unit test
+ *
+ * @version
+ */
+public class WireTapBeanTest extends ContextTestSupport {
+ protected MockEndpoint tap;
+ protected MockEndpoint result;
+
+ public void testSend() throws Exception {
+ result.expectedBodiesReceived("Bye World");
+ tap.expectedBodiesReceived("World");
+
+ template.sendBody("direct:start", "World");
+
+ assertMockEndpointsSatisfied();
+ }
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ tap = getMockEndpoint("mock:tap");
+ result = getMockEndpoint("mock:result");
+ }
+
+ protected RouteBuilder createRouteBuilder() {
+ return new RouteBuilder() {
+ public void configure() {
+ from("direct:start")
+ .to("log:foo")
+ .wireTap("seda:tap")
+ .bean(MyBean.class)
+ .to("mock:result");
+
+ from("seda:tap")
+ .to("mock:tap");
+ }
+ };
+ }
+
+ public static class MyBean {
+
+ public String transform(String body) {
+ return "Bye " + body;
+ }
+ }
+}
View
1 camel-core/src/test/resources/log4j.properties
@@ -50,6 +50,7 @@ log4j.logger.org.apache.camel.impl.DefaultPackageScanClassResolver=WARN
#log4j.logger.org.apache.camel.util.FileUtil=TRACE
#log4j.logger.org.apache.camel.util.AsyncProcessorHelper=TRACE
#log4j.logger.org.apache.camel.util.ServiceHelper=TRACE
+#log4j.logger.org.apache.camel.util.jsse=TRACE
# CONSOLE appender not used by default
log4j.appender.out=org.apache.log4j.ConsoleAppender
View
17 ...-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelThreadPoolFactoryBean.java
@@ -52,6 +52,8 @@
private ThreadPoolRejectedPolicy rejectedPolicy = ThreadPoolRejectedPolicy.CallerRuns;
@XmlAttribute(required = true)
private String threadName;
+ @XmlAttribute
+ private Boolean scheduled;
public ExecutorService getObject() throws Exception {
int size = CamelContextHelper.parseInteger(getCamelContext(), poolSize);
@@ -81,7 +83,13 @@ public ExecutorService getObject() throws Exception {
.maxQueueSize(queueSize)
.rejectedPolicy(rejectedPolicy)
.build();
- ExecutorService answer = getCamelContext().getExecutorServiceManager().newThreadPool(getId(), getThreadName(), profile);
+
+ ExecutorService answer;
+ if (scheduled != null && scheduled) {
+ answer = getCamelContext().getExecutorServiceManager().newScheduledThreadPool(getId(), getThreadName(), profile);
+ } else {
+ answer = getCamelContext().getExecutorServiceManager().newThreadPool(getId(), getThreadName(), profile);
+ }
return answer;
}
@@ -145,4 +153,11 @@ public void setThreadName(String threadName) {
this.threadName = threadName;
}
+ public Boolean getScheduled() {
+ return scheduled;
+ }
+
+ public void setScheduled(Boolean scheduled) {
+ this.scheduled = scheduled;
+ }
}
View
3 ...onents/camel-cxf/src/main/java/org/apache/camel/component/cxf/converter/CxfConverter.java
@@ -35,8 +35,6 @@
import org.apache.camel.spi.TypeConverterRegistry;
import org.apache.camel.util.IOHelper;
import org.apache.cxf.message.MessageContentsList;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
/**
* The <a href="http://camel.apache.org/type-converter.html">Type Converters</a>
@@ -46,7 +44,6 @@
*/
@Converter
public final class CxfConverter {
- private static final Logger LOG = LoggerFactory.getLogger(CxfConverter.class);
private CxfConverter() {
// Helper class
View
1 components/camel-guice/src/main/java/org/apache/camel/guice/Main.java
@@ -73,6 +73,7 @@ public String getJndiProperties() {
public static void main(String... args) throws Exception {
Main main = new Main();
instance = main;
+ main.enableHangupSupport();
main.run(args);
}
View
5 components/camel-jcr/src/main/java/org/apache/camel/component/jcr/JcrMessage.java
@@ -50,6 +50,11 @@ public String toString() {
@Override
public void copyFrom(org.apache.camel.Message that) {
+ if (that == this) {
+ // the same instance so do not need to copy
+ return;
+ }
+
// must initialize headers before we set the JmsMessage to avoid Camel
// populating it before we do the copy
getHeaders().clear();
View
9 components/camel-jibx/pom.xml
@@ -81,14 +81,13 @@
<artifactId>maven-jibx-plugin</artifactId>
<version>${jibx-version}</version>
<configuration>
- <bindingDirectory>src/test/resources</bindingDirectory>
- <includeSchemaBindings>
- <includeSchemaBinding>**/*-jibx.xml</includeSchemaBinding>
- </includeSchemaBindings>
+ <directory>${basedir}/src/test/resources/org/apache/camel/dataformat/jibx/</directory>
+ <includes>
+ <include>purchaseOrder-jibx.xml</include>
+ </includes>
</configuration>
<executions>
<execution>
- <phase>process-test-classes</phase>
<goals>
<goal>test-bind</goal>
</goals>
View
5 components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsMessage.java
@@ -61,6 +61,11 @@ public String toString() {
@Override
public void copyFrom(org.apache.camel.Message that) {
+ if (that == this) {
+ // the same instance so do not need to copy
+ return;
+ }
+
// must initialize headers before we set the JmsMessage to avoid Camel
// populating it before we do the copy
getHeaders().clear();
View
91 ...amel-jms/src/test/java/org/apache/camel/component/jms/JmsSplitterParallelChainedTest.java
@@ -0,0 +1,91 @@
+/**
+ * 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.component.jms;
+
+import javax.jms.ConnectionFactory;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.ExchangePattern;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Test;
+
+import static org.apache.camel.component.jms.JmsComponent.jmsComponentAutoAcknowledge;
+
+/**
+ * Test that chained request/reply over JMS works in parallel mode with the splitter EIP.
+ *
+ * @version
+ */
+public class JmsSplitterParallelChainedTest extends CamelTestSupport {
+
+ protected String getUri() {
+ return "activemq:queue:foo";
+ }
+
+ protected String getUri2() {
+ return "activemq:queue:bar";
+ }
+
+ @Test
+ public void testSplitParallel() throws Exception {
+ getMockEndpoint("mock:result").expectedBodiesReceived("A,B,C,D,E");
+ getMockEndpoint("mock:reply").expectedBodiesReceivedInAnyOrder("Hi A", "Hi B", "Hi C", "Hi D", "Hi E");
+ getMockEndpoint("mock:reply2").expectedBodiesReceivedInAnyOrder("Bye Hi A", "Bye Hi B", "Bye Hi C", "Bye Hi D", "Bye Hi E");
+ getMockEndpoint("mock:split").expectedBodiesReceivedInAnyOrder("Bye Hi A", "Bye Hi B", "Bye Hi C", "Bye Hi D", "Bye Hi E");
+
+ template.sendBody("direct:start", "A,B,C,D,E");
+
+ assertMockEndpointsSatisfied();
+ }
+
+ protected CamelContext createCamelContext() throws Exception {
+ CamelContext camelContext = super.createCamelContext();
+
+ ConnectionFactory connectionFactory = CamelJmsTestHelper.createConnectionFactory();
+ camelContext.addComponent("activemq", jmsComponentAutoAcknowledge(connectionFactory));
+
+ return camelContext;
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+ from("direct:start")
+ .split(body().tokenize(",")).parallelProcessing()
+ .to("log:before")
+ .to(ExchangePattern.InOut, getUri())
+ .to("log:after")
+ .to("mock:split")
+ .end()
+ .to("mock:result");
+
+ from(getUri())
+ .transform(body().prepend("Hi "))
+ .to("mock:reply")
+ .to(ExchangePattern.InOut, getUri2());
+
+ from(getUri2())
+ .transform(body().prepend("Bye "))
+ .to("mock:reply2");
+ }
+ };
+ }
+
+}
View
79 ...nents/camel-jms/src/test/java/org/apache/camel/component/jms/JmsSplitterParallelTest.java
@@ -0,0 +1,79 @@
+/**
+ * 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.component.jms;
+
+import javax.jms.ConnectionFactory;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.ExchangePattern;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Test;
+
+import static org.apache.camel.component.jms.JmsComponent.jmsComponentAutoAcknowledge;
+
+/**
+ * @version
+ */
+public class JmsSplitterParallelTest extends CamelTestSupport {
+
+ protected String getUri() {
+ return "activemq:queue:foo?useMessageIDAsCorrelationID=true";
+ }
+
+ @Test
+ public void testSplitParallel() throws Exception {
+ getMockEndpoint("mock:result").expectedBodiesReceived("A,B,C,D,E");
+ getMockEndpoint("mock:reply").expectedBodiesReceivedInAnyOrder("Bye A", "Bye B", "Bye C", "Bye D", "Bye E");
+ getMockEndpoint("mock:split").expectedBodiesReceivedInAnyOrder("Bye A", "Bye B", "Bye C", "Bye D", "Bye E");
+
+ template.sendBody("direct:start", "A,B,C,D,E");
+
+ assertMockEndpointsSatisfied();
+ }
+
+ protected CamelContext createCamelContext() throws Exception {
+ CamelContext camelContext = super.createCamelContext();
+
+ ConnectionFactory connectionFactory = CamelJmsTestHelper.createConnectionFactory();
+ camelContext.addComponent("activemq", jmsComponentAutoAcknowledge(connectionFactory));
+
+ return camelContext;
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+ from("direct:start")
+ .split(body().tokenize(",")).parallelProcessing()
+ .to("log:before")
+ .to(ExchangePattern.InOut, getUri())
+ .to("log:after")
+ .to("mock:split")
+ .end()
+ .to("mock:result");
+
+ from(getUri())
+ .transform(body().prepend("Bye "))
+ .to("mock:reply");
+ }
+ };
+ }