Repository: camel Updated Branches: refs/heads/master 2b00399af -> 75dd4db79
Fix for CAMEL-10226: Allow JmsComponent subclasses to disable auto-wiring connection factories/destination resolvers. Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/75dd4db7 Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/75dd4db7 Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/75dd4db7 Branch: refs/heads/master Commit: 75dd4db790172ce684c597d20ca51402b9f24c82 Parents: 2b00399 Author: Hiram Chirino <hi...@hiramchirino.com> Authored: Tue Aug 9 11:29:06 2016 -0400 Committer: Hiram Chirino <hi...@hiramchirino.com> Committed: Tue Aug 9 12:23:23 2016 -0400 ---------------------------------------------------------------------- .../camel/component/jms/JmsComponent.java | 44 ++++++++++++++++---- 1 file changed, 36 insertions(+), 8 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/75dd4db7/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsComponent.java ---------------------------------------------------------------------- diff --git a/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsComponent.java b/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsComponent.java index 4f5d3bf..30e9354 100644 --- a/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsComponent.java +++ b/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsComponent.java @@ -148,15 +148,21 @@ public class JmsComponent extends UriEndpointComponent implements ApplicationCon // If we are being configured with spring... if (applicationContext != null) { - Map<String, ConnectionFactory> beansOfTypeConnectionFactory = applicationContext.getBeansOfType(ConnectionFactory.class); - if (!beansOfTypeConnectionFactory.isEmpty()) { - ConnectionFactory cf = beansOfTypeConnectionFactory.values().iterator().next(); - configuration.setConnectionFactory(cf); + + if( getAllowAutoWiredConnectionFactory() ) { + Map<String, ConnectionFactory> beansOfTypeConnectionFactory = applicationContext.getBeansOfType(ConnectionFactory.class); + if (!beansOfTypeConnectionFactory.isEmpty()) { + ConnectionFactory cf = beansOfTypeConnectionFactory.values().iterator().next(); + configuration.setConnectionFactory(cf); + } } - Map<String, DestinationResolver> beansOfTypeDestinationResolver = applicationContext.getBeansOfType(DestinationResolver.class); - if (!beansOfTypeDestinationResolver.isEmpty()) { - DestinationResolver destinationResolver = beansOfTypeDestinationResolver.values().iterator().next(); - configuration.setDestinationResolver(destinationResolver); + + if( getAllowAutoWiredDestinationResolver() ) { + Map<String, DestinationResolver> beansOfTypeDestinationResolver = applicationContext.getBeansOfType(DestinationResolver.class); + if (!beansOfTypeDestinationResolver.isEmpty()) { + DestinationResolver destinationResolver = beansOfTypeDestinationResolver.values().iterator().next(); + configuration.setDestinationResolver(destinationResolver); + } } } } @@ -164,6 +170,28 @@ public class JmsComponent extends UriEndpointComponent implements ApplicationCon } /** + * Subclasses can override to prevent the jms configuration from being + * setup to use an auto-wired the connection factory that's found in the spring + * application context. + * + * @return true + */ + public boolean getAllowAutoWiredConnectionFactory() { + return true; + } + + /** + * Subclasses can override to prevent the jms configuration from being + * setup to use an auto-wired the destination resolved that's found in the spring + * application context. + * + * @return true + */ + public boolean getAllowAutoWiredDestinationResolver() { + return true; + } + + /** * To use a shared JMS configuration */ public void setConfiguration(JmsConfiguration configuration) {