Rework ListenerContainerFactory configurers

Rework commit b726974 to avoid exposing setters that would permit anyone
to change Spring Boot's defaults. Also, since these are configurers of a
specific instance, they should be named accordingly.

Closes gh-5138
This commit is contained in:
Stephane Nicoll
2016-02-23 14:22:54 +01:00
parent f94e8bd287
commit c4205d04b3
6 changed files with 64 additions and 65 deletions

View File

@@ -3490,9 +3490,9 @@ TIP: Check {spring-javadoc}/jms/annotation/EnableJms.{dc-ext}[the Javadoc of `@E
more details.
If you need to create more `JmsListenerContainerFactory` instances or if you want to override
the default, Spring Boot provides a `JmsListenerContainerFactoryConfigurer` that you can use
to initialize a `DefaultJmsListenerContainerFactory` with the same settings as the one that
is auto-configured.
the default, Spring Boot provides a `DefaultJmsListenerContainerFactoryConfigurer` that you
can use to initialize a `DefaultJmsListenerContainerFactory` with the same settings as the one
that is auto-configured.
For instance, the following exposes another factory that uses a specific `MessageConverter`:
@@ -3503,9 +3503,10 @@ For instance, the following exposes another factory that uses a specific `Messag
@Bean
public DefaultJmsListenerContainerFactory myFactory(
JmsListenerContainerFactoryConfigurer configurer) {
DefaultJmsListenerContainerFactory factory = configurer
.createJmsListenerContainerFactory(connectionFactory());
DefaultJmsListenerContainerFactoryConfigurer configurer) {
DefaultJmsListenerContainerFactory factory =
new DefaultJmsListenerContainerFactory();
configurer.configure(factory, connectionFactory());
factory.setMessageConverter(myMessageConverter());
return factory;
}
@@ -3624,8 +3625,8 @@ TIP: Check {spring-amqp-javadoc}/rabbit/annotation/EnableRabbit.{dc-ext}[the Jav
for more details.
If you need to create more `RabbitListenerContainerFactory` instances or if you want to override
the default, Spring Boot provides a `RabbitListenerContainerFactoryConfigurer` that you can use
to initialize a `SimpleRabbitListenerContainerFactory` with the same settings as the one that
the default, Spring Boot provides a `SimpleRabbitListenerContainerFactoryConfigurer` that you can
use to initialize a `SimpleRabbitListenerContainerFactory` with the same settings as the one that
is auto-configured.
For instance, the following exposes another factory that uses a specific `MessageConverter`:
@@ -3637,9 +3638,10 @@ For instance, the following exposes another factory that uses a specific `Messag
@Bean
public SimpleRabbitListenerContainerFactory myFactory(
RabbitListenerContainerFactoryConfigurer configurer) {
SimpleRabbitListenerContainerFactory factory = configurer
.createRabbitListenerContainerFactory(connectionFactory());
SimpleRabbitListenerContainerFactoryConfigurer configurer) {
SimpleRabbitListenerContainerFactory factory =
new SimpleRabbitListenerContainerFactory();
configurer.configure(factory, connectionFactory);
factory.setMessageConverter(myMessageConverter());
return factory;
}