Skip to content

Commit 1ac7b95

Browse files
committed
SPR-6460 Added "phase" attribute to the JMS namespace's "jca-listener-container" element.
1 parent dc24944 commit 1ac7b95

File tree

6 files changed

+22
-7
lines changed

6 files changed

+22
-7
lines changed

org.springframework.jms/src/main/java/org/springframework/jms/config/AbstractListenerContainerParser.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2008 the original author or authors.
2+
* Copyright 2002-2009 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -83,6 +83,8 @@ abstract class AbstractListenerContainerParser implements BeanDefinitionParser {
8383

8484
protected static final String CONCURRENCY_ATTRIBUTE = "concurrency";
8585

86+
protected static final String PHASE_ATTRIBUTE = "phase";
87+
8688
protected static final String PREFETCH_ATTRIBUTE = "prefetch";
8789

8890

org.springframework.jms/src/main/java/org/springframework/jms/config/JcaListenerContainerParser.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2007 the original author or authors.
2+
* Copyright 2002-2009 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -93,6 +93,11 @@ protected BeanDefinition parseContainer(Element listenerEle, Element containerEl
9393
configDef.getPropertyValues().add("maxConcurrency", concurrency[1]);
9494
}
9595

96+
String phase = containerEle.getAttribute(PHASE_ATTRIBUTE);
97+
if (StringUtils.hasText(phase)) {
98+
containerDef.getPropertyValues().add("phase", phase);
99+
}
100+
96101
String prefetch = containerEle.getAttribute(PREFETCH_ATTRIBUTE);
97102
if (StringUtils.hasText(prefetch)) {
98103
configDef.getPropertyValues().add("prefetchSize", new Integer(prefetch));

org.springframework.jms/src/main/java/org/springframework/jms/config/JmsListenerContainerParser.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,6 @@ class JmsListenerContainerParser extends AbstractListenerContainerParser {
4444

4545
private static final String ERROR_HANDLER_ATTRIBUTE = "error-handler";
4646

47-
private static final String PHASE_ATTRIBUTE = "phase";
48-
4947
private static final String CACHE_ATTRIBUTE = "cache";
5048

5149

org.springframework.jms/src/main/resources/org/springframework/jms/config/spring-jms-3.0.xsd

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,16 @@
391391
]]></xsd:documentation>
392392
</xsd:annotation>
393393
</xsd:attribute>
394+
<xsd:attribute name="phase" type="xsd:string">
395+
<xsd:annotation>
396+
<xsd:documentation><![CDATA[
397+
The lifecycle phase within which this container should start and stop. The lower
398+
the value the earlier this container will start and the later it will stop. The
399+
default is Integer.MAX_VALUE meaning the container will start as late as possible
400+
and stop as soon as possible.
401+
]]></xsd:documentation>
402+
</xsd:annotation>
403+
</xsd:attribute>
394404
</xsd:complexType>
395405
</xsd:element>
396406

org.springframework.jms/src/test/java/org/springframework/jms/config/JmsNamespaceHandlerTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,8 @@ public void testPhases() {
153153
int defaultPhase = getPhase(DefaultMessageListenerContainer.class.getName() + "#0");
154154
assertEquals(99, phase1);
155155
assertEquals(99, phase2);
156-
assertEquals(Integer.MAX_VALUE, phase3);
157-
assertEquals(Integer.MAX_VALUE, phase4);
156+
assertEquals(77, phase3);
157+
assertEquals(77, phase4);
158158
assertEquals(Integer.MAX_VALUE, defaultPhase);
159159
}
160160

org.springframework.jms/src/test/java/org/springframework/jms/config/jmsNamespaceHandlerTests.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
</jms:listener-container>
1919

2020
<jms:jca-listener-container resource-adapter="testResourceAdapter" activation-spec-factory="testActivationSpecFactory"
21-
message-converter="testMessageConverter">
21+
message-converter="testMessageConverter" phase="77">
2222
<jms:listener id="listener3" destination="testDestination" ref="testBean1" method="setName"/>
2323
<jms:listener id="listener4" destination="testDestination" ref="testBean2" method="setName" response-destination="responseDestination"/>
2424
</jms:jca-listener-container>

0 commit comments

Comments
 (0)