Harmonize JMS connection factory bean names

This commit restores consistent naming for the auto-configured
connection factory.

Closes gh-19565
This commit is contained in:
Stephane Nicoll
2020-02-11 16:21:15 +01:00
parent d1f4a1821c
commit 8f06d819e4
6 changed files with 75 additions and 49 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2012-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -55,7 +55,7 @@ public class JndiConnectionFactoryAutoConfiguration {
private static final String[] JNDI_LOCATIONS = { "java:/JmsXA", "java:/XAConnectionFactory" };
@Bean
public ConnectionFactory connectionFactory(JmsProperties properties) throws NamingException {
public ConnectionFactory jmsConnectionFactory(JmsProperties properties) throws NamingException {
JndiLocatorDelegate jndiLocatorDelegate = JndiLocatorDelegate.createDefaultResourceRefLocator();
if (StringUtils.hasLength(properties.getJndiName())) {
return jndiLocatorDelegate.lookup(properties.getJndiName(), ConnectionFactory.class);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2012-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -73,8 +73,7 @@ class ActiveMQConnectionFactoryConfiguration {
static class CachingConnectionFactoryConfiguration {
@Bean
CachingConnectionFactory cachingJmsConnectionFactory(JmsProperties jmsProperties,
ActiveMQProperties properties,
CachingConnectionFactory jmsConnectionFactory(JmsProperties jmsProperties, ActiveMQProperties properties,
ObjectProvider<ActiveMQConnectionFactoryCustomizer> factoryCustomizers) {
JmsProperties.Cache cacheProperties = jmsProperties.getCache();
CachingConnectionFactory connectionFactory = new CachingConnectionFactory(
@@ -95,7 +94,7 @@ class ActiveMQConnectionFactoryConfiguration {
@Bean(destroyMethod = "stop")
@ConditionalOnProperty(prefix = "spring.activemq.pool", name = "enabled", havingValue = "true")
JmsPoolConnectionFactory pooledJmsConnectionFactory(ActiveMQProperties properties,
JmsPoolConnectionFactory jmsConnectionFactory(ActiveMQProperties properties,
ObjectProvider<ActiveMQConnectionFactoryCustomizer> factoryCustomizers) {
ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactoryFactory(properties,
factoryCustomizers.orderedStream().collect(Collectors.toList()))

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2012-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -58,7 +58,7 @@ class ArtemisConnectionFactoryConfiguration {
this.beanFactory = beanFactory;
}
@Bean
@Bean(name = "jmsConnectionFactory")
@ConditionalOnProperty(prefix = "spring.jms.cache", name = "enabled", havingValue = "true",
matchIfMissing = true)
CachingConnectionFactory cachingJmsConnectionFactory(JmsProperties jmsProperties) {
@@ -70,7 +70,7 @@ class ArtemisConnectionFactoryConfiguration {
return connectionFactory;
}
@Bean
@Bean(name = "jmsConnectionFactory")
@ConditionalOnProperty(prefix = "spring.jms.cache", name = "enabled", havingValue = "false")
ActiveMQConnectionFactory jmsConnectionFactory() {
return createConnectionFactory();
@@ -85,13 +85,11 @@ class ArtemisConnectionFactoryConfiguration {
@Configuration(proxyBeanMethods = false)
@ConditionalOnClass({ JmsPoolConnectionFactory.class, PooledObject.class })
@ConditionalOnProperty(prefix = "spring.artemis.pool", name = "enabled", havingValue = "true")
static class PooledConnectionFactoryConfiguration {
@Bean(destroyMethod = "stop")
@ConditionalOnProperty(prefix = "spring.artemis.pool", name = "enabled", havingValue = "true",
matchIfMissing = false)
JmsPoolConnectionFactory pooledJmsConnectionFactory(ListableBeanFactory beanFactory,
ArtemisProperties properties) {
JmsPoolConnectionFactory jmsConnectionFactory(ListableBeanFactory beanFactory, ArtemisProperties properties) {
ActiveMQConnectionFactory connectionFactory = new ArtemisConnectionFactoryFactory(beanFactory, properties)
.createConnectionFactory(ActiveMQConnectionFactory.class);
return new JmsPoolConnectionFactoryFactory(properties.getPool())