|
43 | 43 | class ArtemisConnectionFactoryConfiguration { |
44 | 44 |
|
45 | 45 | @Configuration(proxyBeanMethods = false) |
46 | | - @ConditionalOnClass(CachingConnectionFactory.class) |
47 | 46 | @ConditionalOnProperty(prefix = "spring.artemis.pool", name = "enabled", havingValue = "false", |
48 | 47 | matchIfMissing = true) |
49 | 48 | static class SimpleConnectionFactoryConfiguration { |
50 | 49 |
|
51 | | - private final ArtemisProperties properties; |
52 | | - |
53 | | - private final ListableBeanFactory beanFactory; |
| 50 | + @Bean(name = "jmsConnectionFactory") |
| 51 | + @ConditionalOnProperty(prefix = "spring.jms.cache", name = "enabled", havingValue = "false") |
| 52 | + ActiveMQConnectionFactory jmsConnectionFactory(ArtemisProperties properties, ListableBeanFactory beanFactory) { |
| 53 | + return createConnectionFactory(properties, beanFactory); |
| 54 | + } |
54 | 55 |
|
55 | | - SimpleConnectionFactoryConfiguration(ArtemisProperties properties, ListableBeanFactory beanFactory) { |
56 | | - this.properties = properties; |
57 | | - this.beanFactory = beanFactory; |
| 56 | + private static ActiveMQConnectionFactory createConnectionFactory(ArtemisProperties properties, |
| 57 | + ListableBeanFactory beanFactory) { |
| 58 | + return new ArtemisConnectionFactoryFactory(beanFactory, properties) |
| 59 | + .createConnectionFactory(ActiveMQConnectionFactory.class); |
58 | 60 | } |
59 | 61 |
|
60 | | - @Bean(name = "jmsConnectionFactory") |
| 62 | + @Configuration(proxyBeanMethods = false) |
| 63 | + @ConditionalOnClass(CachingConnectionFactory.class) |
61 | 64 | @ConditionalOnProperty(prefix = "spring.jms.cache", name = "enabled", havingValue = "true", |
62 | 65 | matchIfMissing = true) |
63 | | - CachingConnectionFactory cachingJmsConnectionFactory(JmsProperties jmsProperties) { |
64 | | - JmsProperties.Cache cacheProperties = jmsProperties.getCache(); |
65 | | - CachingConnectionFactory connectionFactory = new CachingConnectionFactory(createConnectionFactory()); |
66 | | - connectionFactory.setCacheConsumers(cacheProperties.isConsumers()); |
67 | | - connectionFactory.setCacheProducers(cacheProperties.isProducers()); |
68 | | - connectionFactory.setSessionCacheSize(cacheProperties.getSessionCacheSize()); |
69 | | - return connectionFactory; |
70 | | - } |
71 | | - |
72 | | - @Bean(name = "jmsConnectionFactory") |
73 | | - @ConditionalOnProperty(prefix = "spring.jms.cache", name = "enabled", havingValue = "false") |
74 | | - ActiveMQConnectionFactory jmsConnectionFactory() { |
75 | | - return createConnectionFactory(); |
76 | | - } |
| 66 | + static class CachingConnectionFactoryConfiguration { |
| 67 | + |
| 68 | + @Bean(name = "jmsConnectionFactory") |
| 69 | + CachingConnectionFactory cachingJmsConnectionFactory(JmsProperties jmsProperties, |
| 70 | + ArtemisProperties properties, ListableBeanFactory beanFactory) { |
| 71 | + JmsProperties.Cache cacheProperties = jmsProperties.getCache(); |
| 72 | + CachingConnectionFactory connectionFactory = new CachingConnectionFactory( |
| 73 | + createConnectionFactory(properties, beanFactory)); |
| 74 | + connectionFactory.setCacheConsumers(cacheProperties.isConsumers()); |
| 75 | + connectionFactory.setCacheProducers(cacheProperties.isProducers()); |
| 76 | + connectionFactory.setSessionCacheSize(cacheProperties.getSessionCacheSize()); |
| 77 | + return connectionFactory; |
| 78 | + } |
77 | 79 |
|
78 | | - private ActiveMQConnectionFactory createConnectionFactory() { |
79 | | - return new ArtemisConnectionFactoryFactory(this.beanFactory, this.properties) |
80 | | - .createConnectionFactory(ActiveMQConnectionFactory.class); |
81 | 80 | } |
82 | 81 |
|
83 | 82 | } |
|
0 commit comments