INT-847 Upgrading to Spring 3.0 snapshot (CI-475 from 2009/11/25).
This commit is contained in:
@@ -10,14 +10,14 @@
|
||||
<classpathentry kind="var" path="IVY_CACHE/org.apache.geronimo.specs/com.springsource.javax.management.j2ee/1.0.1/com.springsource.javax.management.j2ee-1.0.1.jar" sourcepath="/IVY_CACHE/org.apache.geronimo.specs/com.springsource.javax.management.j2ee/1.0.1/com.springsource.javax.management.j2ee-sources-1.0.1.jar" />
|
||||
<classpathentry kind="var" path="IVY_CACHE/org.apache.commons/com.springsource.org.apache.commons.logging/1.1.1/com.springsource.org.apache.commons.logging-1.1.1.jar" sourcepath="/IVY_CACHE/org.apache.commons/com.springsource.org.apache.commons.logging/1.1.1/com.springsource.org.apache.commons.logging-sources-1.1.1.jar" />
|
||||
<classpathentry kind="var" path="IVY_CACHE/org.junit/com.springsource.org.junit/4.7.0/com.springsource.org.junit-4.7.0.jar" sourcepath="/IVY_CACHE/org.junit/com.springsource.org.junit/4.7.0/com.springsource.org.junit-sources-4.7.0.jar" />
|
||||
<classpathentry kind="var" path="IVY_CACHE/org.springframework/org.springframework.asm/3.0.0.RC1/org.springframework.asm-3.0.0.RC1.jar" sourcepath="/IVY_CACHE/org.springframework/org.springframework.asm/3.0.0.RC1/org.springframework.asm-sources-3.0.0.RC1.jar" />
|
||||
<classpathentry kind="var" path="IVY_CACHE/org.springframework/org.springframework.beans/3.0.0.RC1/org.springframework.beans-3.0.0.RC1.jar" sourcepath="/IVY_CACHE/org.springframework/org.springframework.beans/3.0.0.RC1/org.springframework.beans-sources-3.0.0.RC1.jar" />
|
||||
<classpathentry kind="var" path="IVY_CACHE/org.springframework/org.springframework.context/3.0.0.RC1/org.springframework.context-3.0.0.RC1.jar" sourcepath="/IVY_CACHE/org.springframework/org.springframework.context/3.0.0.RC1/org.springframework.context-sources-3.0.0.RC1.jar" />
|
||||
<classpathentry kind="var" path="IVY_CACHE/org.springframework/org.springframework.core/3.0.0.RC1/org.springframework.core-3.0.0.RC1.jar" sourcepath="/IVY_CACHE/org.springframework/org.springframework.core/3.0.0.RC1/org.springframework.core-sources-3.0.0.RC1.jar" />
|
||||
<classpathentry kind="var" path="IVY_CACHE/org.springframework/org.springframework.expression/3.0.0.RC1/org.springframework.expression-3.0.0.RC1.jar" sourcepath="/IVY_CACHE/org.springframework/org.springframework.expression/3.0.0.RC1/org.springframework.expression-sources-3.0.0.RC1.jar" />
|
||||
<classpathentry kind="var" path="IVY_CACHE/org.springframework/org.springframework.jms/3.0.0.RC1/org.springframework.jms-3.0.0.RC1.jar" sourcepath="/IVY_CACHE/org.springframework/org.springframework.jms/3.0.0.RC1/org.springframework.jms-sources-3.0.0.RC1.jar" />
|
||||
<classpathentry kind="var" path="IVY_CACHE/org.springframework/org.springframework.test/3.0.0.RC1/org.springframework.test-3.0.0.RC1.jar" sourcepath="/IVY_CACHE/org.springframework/org.springframework.test/3.0.0.RC1/org.springframework.test-sources-3.0.0.RC1.jar" />
|
||||
<classpathentry kind="var" path="IVY_CACHE/org.springframework/org.springframework.transaction/3.0.0.RC1/org.springframework.transaction-3.0.0.RC1.jar" sourcepath="/IVY_CACHE/org.springframework/org.springframework.transaction/3.0.0.RC1/org.springframework.transaction-sources-3.0.0.RC1.jar" />
|
||||
<classpathentry kind="var" path="IVY_CACHE/org.springframework/org.springframework.asm/3.0.0.CI-475/org.springframework.asm-3.0.0.CI-475.jar" sourcepath="/IVY_CACHE/org.springframework/org.springframework.asm/3.0.0.CI-475/org.springframework.asm-sources-3.0.0.CI-475.jar" />
|
||||
<classpathentry kind="var" path="IVY_CACHE/org.springframework/org.springframework.beans/3.0.0.CI-475/org.springframework.beans-3.0.0.CI-475.jar" sourcepath="/IVY_CACHE/org.springframework/org.springframework.beans/3.0.0.CI-475/org.springframework.beans-sources-3.0.0.CI-475.jar" />
|
||||
<classpathentry kind="var" path="IVY_CACHE/org.springframework/org.springframework.context/3.0.0.CI-475/org.springframework.context-3.0.0.CI-475.jar" sourcepath="/IVY_CACHE/org.springframework/org.springframework.context/3.0.0.CI-475/org.springframework.context-sources-3.0.0.CI-475.jar" />
|
||||
<classpathentry kind="var" path="IVY_CACHE/org.springframework/org.springframework.core/3.0.0.CI-475/org.springframework.core-3.0.0.CI-475.jar" sourcepath="/IVY_CACHE/org.springframework/org.springframework.core/3.0.0.CI-475/org.springframework.core-sources-3.0.0.CI-475.jar" />
|
||||
<classpathentry kind="var" path="IVY_CACHE/org.springframework/org.springframework.expression/3.0.0.CI-475/org.springframework.expression-3.0.0.CI-475.jar" sourcepath="/IVY_CACHE/org.springframework/org.springframework.expression/3.0.0.CI-475/org.springframework.expression-sources-3.0.0.CI-475.jar" />
|
||||
<classpathentry kind="var" path="IVY_CACHE/org.springframework/org.springframework.jms/3.0.0.CI-475/org.springframework.jms-3.0.0.CI-475.jar" sourcepath="/IVY_CACHE/org.springframework/org.springframework.jms/3.0.0.CI-475/org.springframework.jms-sources-3.0.0.CI-475.jar" />
|
||||
<classpathentry kind="var" path="IVY_CACHE/org.springframework/org.springframework.test/3.0.0.CI-475/org.springframework.test-3.0.0.CI-475.jar" sourcepath="/IVY_CACHE/org.springframework/org.springframework.test/3.0.0.CI-475/org.springframework.test-sources-3.0.0.CI-475.jar" />
|
||||
<classpathentry kind="var" path="IVY_CACHE/org.springframework/org.springframework.transaction/3.0.0.CI-475/org.springframework.transaction-3.0.0.CI-475.jar" sourcepath="/IVY_CACHE/org.springframework/org.springframework.transaction/3.0.0.CI-475/org.springframework.transaction-sources-3.0.0.CI-475.jar" />
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/org.springframework.integration" />
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/org.springframework.integration.adapter" />
|
||||
<classpathentry kind="output" path="target/classes" />
|
||||
|
||||
@@ -23,6 +23,7 @@ import javax.jms.Topic;
|
||||
|
||||
import org.springframework.beans.factory.BeanNameAware;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.context.SmartLifecycle;
|
||||
import org.springframework.integration.channel.SubscribableChannel;
|
||||
import org.springframework.integration.core.Message;
|
||||
import org.springframework.integration.core.MessageChannel;
|
||||
@@ -52,8 +53,8 @@ import org.springframework.util.Assert;
|
||||
* @author Mark Fisher
|
||||
* @since 2.0
|
||||
*/
|
||||
public class JmsDestinationBackedMessageChannel implements
|
||||
SubscribableChannel, MessageListener, BeanNameAware, InitializingBean {
|
||||
public class JmsDestinationBackedMessageChannel implements SubscribableChannel, MessageListener,
|
||||
BeanNameAware, SmartLifecycle, InitializingBean {
|
||||
|
||||
private final JmsTemplate jmsTemplate = new JmsTemplate();
|
||||
|
||||
@@ -158,4 +159,30 @@ public class JmsDestinationBackedMessageChannel implements
|
||||
}
|
||||
}
|
||||
|
||||
// SmartLifecycle implementation (delegates to the MessageListener container)
|
||||
|
||||
public int getPhase() {
|
||||
return this.container.getPhase();
|
||||
}
|
||||
|
||||
public boolean isAutoStartup() {
|
||||
return this.container.isAutoStartup();
|
||||
}
|
||||
|
||||
public boolean isRunning() {
|
||||
return this.container.isRunning();
|
||||
}
|
||||
|
||||
public void start() {
|
||||
this.container.start();
|
||||
}
|
||||
|
||||
public void stop() {
|
||||
this.container.stop();
|
||||
}
|
||||
|
||||
public void stop(Runnable callback) {
|
||||
this.container.stop(callback);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -33,8 +33,6 @@ public class JmsMessageDrivenEndpoint extends AbstractEndpoint implements Dispos
|
||||
|
||||
private final ChannelPublishingJmsMessageListener listener;
|
||||
|
||||
private volatile boolean autoStartup = true;
|
||||
|
||||
|
||||
public JmsMessageDrivenEndpoint(AbstractMessageListenerContainer listenerContainer, ChannelPublishingJmsMessageListener listener) {
|
||||
Assert.notNull(listenerContainer, "listener container must not be null");
|
||||
@@ -45,18 +43,8 @@ public class JmsMessageDrivenEndpoint extends AbstractEndpoint implements Dispos
|
||||
}
|
||||
|
||||
|
||||
public void setAutoStartup(boolean autoStartup) {
|
||||
this.autoStartup = autoStartup;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onInit() throws Exception {
|
||||
if (this.autoStartup) {
|
||||
this.setStartupMode(StartupMode.ON_CONTEXT_REFRESH);
|
||||
}
|
||||
else {
|
||||
this.setStartupMode(StartupMode.MANUAL);
|
||||
}
|
||||
this.listener.afterPropertiesSet();
|
||||
if (!this.listenerContainer.isActive()) {
|
||||
this.listenerContainer.afterPropertiesSet();
|
||||
|
||||
@@ -20,9 +20,14 @@ import org.apache.activemq.ActiveMQConnectionFactory;
|
||||
import org.apache.activemq.command.ActiveMQQueue;
|
||||
import org.apache.activemq.command.ActiveMQTopic;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
|
||||
import org.springframework.context.support.StaticApplicationContext;
|
||||
import org.springframework.integration.core.Message;
|
||||
import org.springframework.integration.message.MessageHandler;
|
||||
import org.springframework.integration.message.StringMessage;
|
||||
@@ -77,6 +82,7 @@ public class JmsDestinationBackedMessageChannelTests {
|
||||
JmsDestinationBackedMessageChannel channel =
|
||||
new JmsDestinationBackedMessageChannel(this.connectionFactory, this.queue);
|
||||
channel.afterPropertiesSet();
|
||||
channel.start();
|
||||
channel.subscribe(handler1);
|
||||
channel.subscribe(handler2);
|
||||
channel.send(new StringMessage("foo"));
|
||||
@@ -88,6 +94,7 @@ public class JmsDestinationBackedMessageChannelTests {
|
||||
assertEquals(1, receivedList2.size());
|
||||
assertNotNull(receivedList2.get(0));
|
||||
assertEquals("bar", receivedList2.get(0).getPayload());
|
||||
channel.stop();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -110,6 +117,7 @@ public class JmsDestinationBackedMessageChannelTests {
|
||||
JmsDestinationBackedMessageChannel channel =
|
||||
new JmsDestinationBackedMessageChannel(this.connectionFactory, this.topic);
|
||||
channel.afterPropertiesSet();
|
||||
channel.start();
|
||||
channel.subscribe(handler1);
|
||||
channel.subscribe(handler2);
|
||||
channel.send(new StringMessage("foo"));
|
||||
@@ -121,6 +129,7 @@ public class JmsDestinationBackedMessageChannelTests {
|
||||
assertEquals(2, receivedList2.size());
|
||||
assertEquals("foo", receivedList2.get(0).getPayload());
|
||||
assertEquals("bar", receivedList2.get(1).getPayload());
|
||||
channel.stop();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -143,6 +152,7 @@ public class JmsDestinationBackedMessageChannelTests {
|
||||
JmsDestinationBackedMessageChannel channel =
|
||||
new JmsDestinationBackedMessageChannel(this.connectionFactory, "dynamicQueue", false);
|
||||
channel.afterPropertiesSet();
|
||||
channel.start();
|
||||
channel.subscribe(handler1);
|
||||
channel.subscribe(handler2);
|
||||
channel.send(new StringMessage("foo"));
|
||||
@@ -154,6 +164,7 @@ public class JmsDestinationBackedMessageChannelTests {
|
||||
assertEquals(1, receivedList2.size());
|
||||
assertNotNull(receivedList2.get(0));
|
||||
assertEquals("bar", receivedList2.get(0).getPayload());
|
||||
channel.stop();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -176,6 +187,7 @@ public class JmsDestinationBackedMessageChannelTests {
|
||||
JmsDestinationBackedMessageChannel channel =
|
||||
new JmsDestinationBackedMessageChannel(this.connectionFactory, "dynamicTopic", true);
|
||||
channel.afterPropertiesSet();
|
||||
channel.start();
|
||||
channel.subscribe(handler1);
|
||||
channel.subscribe(handler2);
|
||||
channel.send(new StringMessage("foo"));
|
||||
@@ -187,6 +199,23 @@ public class JmsDestinationBackedMessageChannelTests {
|
||||
assertEquals(2, receivedList2.size());
|
||||
assertEquals("foo", receivedList2.get(0).getPayload());
|
||||
assertEquals("bar", receivedList2.get(1).getPayload());
|
||||
channel.stop();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void contextManagesLifecycle() {
|
||||
BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(JmsDestinationBackedMessageChannel.class);
|
||||
builder.addConstructorArgValue(this.connectionFactory);
|
||||
builder.addConstructorArgValue("dynamicQueue");
|
||||
builder.addConstructorArgValue(false);
|
||||
StaticApplicationContext context = new StaticApplicationContext();
|
||||
context.registerBeanDefinition("channel", builder.getBeanDefinition());
|
||||
JmsDestinationBackedMessageChannel channel = context.getBean("channel", JmsDestinationBackedMessageChannel.class);
|
||||
assertFalse(channel.isRunning());
|
||||
context.refresh();
|
||||
assertTrue(channel.isRunning());
|
||||
context.stop();
|
||||
assertFalse(channel.isRunning());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user