Default JmsListenerContainerFactory lookup

Prior to this commit, the default JmsListenerContainerFactory to use
must be explicitly set. Since having a single container factory is a
fairly common use case, we look up the default one automatically
using the bean name "jmsListenerContainerFactory".

It is still possible to provide an explicit default but since it refers
more to "the" container factory to use, the parameter has been
renamed to "containerFactory" which is shorter and more explicit.

The lookup strategy is lazy: if all endpoints are providing an
explicit container factory and no container factory with the
"jmsListenerContainerFactory" bean name exists, no exception
will be thrown.

Issue : SPR-11706
This commit is contained in:
Stephane Nicoll
2014-04-24 10:31:44 +03:00
parent 08f0395033
commit 4b0aba63df
15 changed files with 195 additions and 81 deletions

View File

@@ -7,11 +7,11 @@
http://www.springframework.org/schema/jms
http://www.springframework.org/schema/jms/spring-jms-4.1.xsd">
<jms:annotation-driven default-container-factory="defaultFactory"/>
<jms:annotation-driven container-factory="simpleFactory"/>
<bean class="org.springframework.jms.annotation.AbstractJmsAnnotationDrivenTests$DefaultBean"/>
<bean id="defaultFactory" class="org.springframework.jms.config.JmsListenerContainerTestFactory"/>
<bean id="simpleFactory" class="org.springframework.jms.config.JmsListenerContainerTestFactory"/>
</beans>

View File

@@ -13,14 +13,13 @@
<bean id="customRegistry" class="org.springframework.jms.config.JmsListenerEndpointRegistry"/>
<bean id="defaultFactory" class="org.springframework.jms.config.JmsListenerContainerTestFactory"/>
<bean id="jmsListenerContainerFactory" class="org.springframework.jms.config.JmsListenerContainerTestFactory"/>
<bean id="customFactory" class="org.springframework.jms.config.JmsListenerContainerTestFactory"/>
<bean id="simpleMessageListener" class="org.springframework.jms.listener.adapter.MessageListenerAdapter"/>
<bean class="org.springframework.jms.annotation.AnnotationDrivenNamespaceTests$CustomJmsListenerConfigurer">
<property name="messageListener" ref="simpleMessageListener"/>
<property name="containerFactory" ref="defaultFactory"/>
</bean>

View File

@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jms="http://www.springframework.org/schema/jms"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/jms
http://www.springframework.org/schema/jms/spring-jms-4.1.xsd">
<jms:annotation-driven/>
<bean class="org.springframework.jms.annotation.AbstractJmsAnnotationDrivenTests$DefaultBean"/>
<bean id="jmsListenerContainerFactory"
class="org.springframework.jms.config.JmsListenerContainerTestFactory"/>
</beans>

View File

@@ -11,7 +11,7 @@
<bean class="org.springframework.jms.annotation.AbstractJmsAnnotationDrivenTests$SampleBean"/>
<bean id="defaultFactory" class="org.springframework.jms.config.JmsListenerContainerTestFactory"/>
<bean id="jmsListenerContainerFactory" class="org.springframework.jms.config.JmsListenerContainerTestFactory"/>
<bean id="simpleFactory" class="org.springframework.jms.config.JmsListenerContainerTestFactory"/>