2424import org .springframework .boot .context .properties .PropertyMapper ;
2525import org .springframework .boot .jms .autoconfigure .JmsProperties .Listener .Session ;
2626import org .springframework .jms .config .AbstractJmsListenerContainerFactory ;
27+ import org .springframework .jms .config .JmsListenerContainerFactory ;
2728import org .springframework .jms .support .converter .MessageConverter ;
2829import org .springframework .jms .support .destination .DestinationResolver ;
2930import org .springframework .util .Assert ;
3031
3132/**
32- * Configures {@link AbstractJmsListenerContainerFactory} with sensible defaults.
33+ * Configure common {@link JmsListenerContainerFactory} settings with sensible defaults.
34+ * <p>
35+ * This includes:
36+ * <li>A {@link DestinationResolver} is such a component is present.</li>
37+ * <li>A {@link MessageConverter} is such a component is present.</li>
38+ * <li>An {@link ExceptionListener} is such a component is present.</li>
39+ * <li>An {@link ObservationRegistry} is such a component is present.</li>
40+ * <li>Configuration properties of the {@code spring.jms} namespace that are common to all
41+ * implementations.</li>
3342 *
3443 * @param <T> the connection factory type.
44+ * @author Stephane Nicoll
45+ * @author Eddú Meléndez
3546 * @author Vedran Pavic
36- * @since 4.0.0
47+ * @author Lasse Wulff
48+ * @since 4.1.0
3749 */
3850public abstract class AbstractJmsListenerContainerFactoryConfigurer <T extends AbstractJmsListenerContainerFactory <?>> {
3951
@@ -90,6 +102,15 @@ void setObservationRegistry(@Nullable ObservationRegistry observationRegistry) {
90102 this .observationRegistry = observationRegistry ;
91103 }
92104
105+ /**
106+ * Return the {@link JmsProperties}.
107+ * @return the jms properties
108+ */
109+ protected JmsProperties getJmsProperties () {
110+ Assert .state (this .jmsProperties != null , "'jmsProperties' must not be null" );
111+ return this .jmsProperties ;
112+ }
113+
93114 /**
94115 * Configure the specified jms listener container factory. The factory can be further
95116 * tuned and default settings can be overridden.
@@ -100,32 +121,21 @@ void setObservationRegistry(@Nullable ObservationRegistry observationRegistry) {
100121 public void configure (T factory , ConnectionFactory connectionFactory ) {
101122 Assert .notNull (factory , "'factory' must not be null" );
102123 Assert .notNull (connectionFactory , "'connectionFactory' must not be null" );
103- Assert . state ( this . jmsProperties != null , "'jmsProperties' must not be null" );
104- JmsProperties .Listener listenerProperties = this . jmsProperties .getListener ();
124+ JmsProperties properties = getJmsProperties ( );
125+ JmsProperties .Listener listenerProperties = properties .getListener ();
105126 Session sessionProperties = listenerProperties .getSession ();
106127 factory .setConnectionFactory (connectionFactory );
107128 PropertyMapper map = PropertyMapper .get ();
108- map .from (this . jmsProperties ::isPubSubDomain ).to (factory ::setPubSubDomain );
109- map .from (this . jmsProperties ::isSubscriptionDurable ).to (factory ::setSubscriptionDurable );
110- map .from (this . jmsProperties ::getClientId ).to (factory ::setClientId );
129+ map .from (properties ::isPubSubDomain ).to (factory ::setPubSubDomain );
130+ map .from (properties ::isSubscriptionDurable ).to (factory ::setSubscriptionDurable );
131+ map .from (properties ::getClientId ).to (factory ::setClientId );
111132 map .from (this .destinationResolver ).to (factory ::setDestinationResolver );
112133 map .from (this .messageConverter ).to (factory ::setMessageConverter );
113134 map .from (this .exceptionListener ).to (factory ::setExceptionListener );
114135 map .from (sessionProperties .getAcknowledgeMode ()::getMode ).to (factory ::setSessionAcknowledgeMode );
115136 map .from (this .observationRegistry ).to (factory ::setObservationRegistry );
116137 map .from (sessionProperties ::getTransacted ).to (factory ::setSessionTransacted );
117138 map .from (listenerProperties ::isAutoStartup ).to (factory ::setAutoStartup );
118- configure (factory , connectionFactory , this .jmsProperties );
119139 }
120140
121- /**
122- * Configures the given {@code factory} using the given {@code connectionFactory} and
123- * {@code jmsProperties}.
124- * @param factory the {@link AbstractJmsListenerContainerFactory} instance to
125- * configure
126- * @param connectionFactory the {@link ConnectionFactory} to use
127- * @param jmsProperties the {@link JmsProperties} to use
128- */
129- protected abstract void configure (T factory , ConnectionFactory connectionFactory , JmsProperties jmsProperties );
130-
131141}
0 commit comments