16
16
17
17
package org .springframework .boot .autoconfigure .jms .activemq ;
18
18
19
- import java .util .List ;
20
19
import java .util .stream .Collectors ;
21
20
22
21
import javax .jms .ConnectionFactory ;
49
48
class ActiveMQConnectionFactoryConfiguration {
50
49
51
50
@ Configuration (proxyBeanMethods = false )
52
- @ ConditionalOnClass (CachingConnectionFactory .class )
53
51
@ ConditionalOnProperty (prefix = "spring.activemq.pool" , name = "enabled" , havingValue = "false" ,
54
52
matchIfMissing = true )
55
53
static class SimpleConnectionFactoryConfiguration {
56
54
57
- private final ActiveMQProperties properties ;
58
-
59
- private final List <ActiveMQConnectionFactoryCustomizer > connectionFactoryCustomizers ;
60
-
61
- SimpleConnectionFactoryConfiguration (ActiveMQProperties properties ,
62
- ObjectProvider <ActiveMQConnectionFactoryCustomizer > connectionFactoryCustomizers ) {
63
- this .properties = properties ;
64
- this .connectionFactoryCustomizers = connectionFactoryCustomizers .orderedStream ()
65
- .collect (Collectors .toList ());
55
+ @ Bean
56
+ @ ConditionalOnProperty (prefix = "spring.jms.cache" , name = "enabled" , havingValue = "false" )
57
+ ActiveMQConnectionFactory jmsConnectionFactory (ActiveMQProperties properties ,
58
+ ObjectProvider <ActiveMQConnectionFactoryCustomizer > factoryCustomizers ) {
59
+ return new ActiveMQConnectionFactoryFactory (properties ,
60
+ factoryCustomizers .orderedStream ().collect (Collectors .toList ()))
61
+ .createConnectionFactory (ActiveMQConnectionFactory .class );
66
62
}
67
63
68
- @ Bean
64
+ @ Configuration (proxyBeanMethods = false )
65
+ @ ConditionalOnClass (CachingConnectionFactory .class )
69
66
@ ConditionalOnProperty (prefix = "spring.jms.cache" , name = "enabled" , havingValue = "true" ,
70
67
matchIfMissing = true )
71
- CachingConnectionFactory cachingJmsConnectionFactory (JmsProperties jmsProperties ) {
72
- JmsProperties .Cache cacheProperties = jmsProperties .getCache ();
73
- CachingConnectionFactory connectionFactory = new CachingConnectionFactory (createConnectionFactory ());
74
- connectionFactory .setCacheConsumers (cacheProperties .isConsumers ());
75
- connectionFactory .setCacheProducers (cacheProperties .isProducers ());
76
- connectionFactory .setSessionCacheSize (cacheProperties .getSessionCacheSize ());
77
- return connectionFactory ;
78
- }
79
-
80
- @ Bean
81
- @ ConditionalOnProperty (prefix = "spring.jms.cache" , name = "enabled" , havingValue = "false" )
82
- ActiveMQConnectionFactory jmsConnectionFactory () {
83
- return createConnectionFactory ();
84
- }
68
+ static class CachingConnectionFactoryConfiguration {
69
+
70
+ @ Bean
71
+ @ ConditionalOnProperty (prefix = "spring.jms.cache" , name = "enabled" , havingValue = "true" ,
72
+ matchIfMissing = true )
73
+ CachingConnectionFactory cachingJmsConnectionFactory (JmsProperties jmsProperties ,
74
+ ActiveMQProperties properties ,
75
+ ObjectProvider <ActiveMQConnectionFactoryCustomizer > factoryCustomizers ) {
76
+ JmsProperties .Cache cacheProperties = jmsProperties .getCache ();
77
+ CachingConnectionFactory connectionFactory = new CachingConnectionFactory (
78
+ new ActiveMQConnectionFactoryFactory (properties ,
79
+ factoryCustomizers .orderedStream ().collect (Collectors .toList ()))
80
+ .createConnectionFactory (ActiveMQConnectionFactory .class ));
81
+ connectionFactory .setCacheConsumers (cacheProperties .isConsumers ());
82
+ connectionFactory .setCacheProducers (cacheProperties .isProducers ());
83
+ connectionFactory .setSessionCacheSize (cacheProperties .getSessionCacheSize ());
84
+ return connectionFactory ;
85
+ }
85
86
86
- private ActiveMQConnectionFactory createConnectionFactory () {
87
- return new ActiveMQConnectionFactoryFactory (this .properties , this .connectionFactoryCustomizers )
88
- .createConnectionFactory (ActiveMQConnectionFactory .class );
89
87
}
90
88
91
89
}
@@ -95,8 +93,7 @@ private ActiveMQConnectionFactory createConnectionFactory() {
95
93
static class PooledConnectionFactoryConfiguration {
96
94
97
95
@ Bean (destroyMethod = "stop" )
98
- @ ConditionalOnProperty (prefix = "spring.activemq.pool" , name = "enabled" , havingValue = "true" ,
99
- matchIfMissing = false )
96
+ @ ConditionalOnProperty (prefix = "spring.activemq.pool" , name = "enabled" , havingValue = "true" )
100
97
JmsPoolConnectionFactory pooledJmsConnectionFactory (ActiveMQProperties properties ,
101
98
ObjectProvider <ActiveMQConnectionFactoryCustomizer > factoryCustomizers ) {
102
99
ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactoryFactory (properties ,
0 commit comments