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