INT-3245 Remove SI ChannelInterceptor

Replace with the same class from spring-messaging.

JIRA: https://jira.springsource.org/browse/INT-3245
This commit is contained in:
Gary Russell
2013-12-17 16:08:44 -05:00
parent c2ee2161a1
commit ca0bddffbd
20 changed files with 122 additions and 183 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -28,7 +28,6 @@ import org.springframework.beans.factory.BeanNameAware;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.config.AbstractFactoryBean;
import org.springframework.context.SmartLifecycle;
import org.springframework.integration.channel.ChannelInterceptor;
import org.springframework.integration.jms.AbstractJmsChannel;
import org.springframework.integration.jms.DynamicJmsTemplate;
import org.springframework.integration.jms.PollableJmsChannel;
@@ -39,6 +38,7 @@ import org.springframework.jms.listener.DefaultMessageListenerContainer;
import org.springframework.jms.listener.SimpleMessageListenerContainer;
import org.springframework.jms.support.converter.MessageConverter;
import org.springframework.jms.support.destination.DestinationResolver;
import org.springframework.messaging.support.ChannelInterceptor;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.util.Assert;
import org.springframework.util.CollectionUtils;
@@ -320,6 +320,7 @@ public class JmsChannelFactoryBean extends AbstractFactoryBean<AbstractJmsChanne
this.maxSubscribers = maxSubscribers;
}
@Override
public void setBeanName(String name) {
this.beanName = name;
}
@@ -464,33 +465,39 @@ public class JmsChannelFactoryBean extends AbstractFactoryBean<AbstractJmsChanne
* SmartLifecycle implementation (delegates to the created channel if message-driven)
*/
@Override
public boolean isAutoStartup() {
return (this.channel instanceof SubscribableJmsChannel) ?
((SubscribableJmsChannel) this.channel).isAutoStartup() : false;
}
@Override
public int getPhase() {
return (this.channel instanceof SubscribableJmsChannel) ?
((SubscribableJmsChannel) this.channel).getPhase() : 0;
}
@Override
public boolean isRunning() {
return (this.channel instanceof SubscribableJmsChannel) ?
((SubscribableJmsChannel) this.channel).isRunning() : false;
}
@Override
public void start() {
if (this.channel instanceof SubscribableJmsChannel) {
((SubscribableJmsChannel) this.channel).start();
}
}
@Override
public void stop() {
if (this.channel instanceof SubscribableJmsChannel) {
((SubscribableJmsChannel) this.channel).stop();
}
}
@Override
public void stop(Runnable callback) {
if (this.channel instanceof SubscribableJmsChannel) {
((SubscribableJmsChannel) this.channel).stop(callback);

View File

@@ -16,9 +16,9 @@
package org.springframework.integration.jms;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.times;
@@ -40,16 +40,17 @@ import org.apache.activemq.ActiveMQConnectionFactory;
import org.apache.activemq.command.ActiveMQQueue;
import org.junit.Test;
import org.mockito.Mockito;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageChannel;
import org.springframework.integration.channel.ChannelInterceptor;
import org.springframework.integration.jms.config.ActiveMqTestUtils;
import org.springframework.integration.jms.config.JmsChannelFactoryBean;
import org.springframework.messaging.support.GenericMessage;
import org.springframework.integration.support.MessageBuilder;
import org.springframework.jms.connection.CachingConnectionFactory;
import org.springframework.jms.core.JmsTemplate;
import org.springframework.jms.core.MessageCreator;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.support.ChannelInterceptor;
import org.springframework.messaging.support.GenericMessage;
/**
* @author Mark Fisher
@@ -182,6 +183,7 @@ public class PollableJmsChannelTests {
final AtomicReference<javax.jms.Message> message = new AtomicReference<javax.jms.Message>();
final CountDownLatch latch1 = new CountDownLatch(1);
Executors.newSingleThreadExecutor().execute(new Runnable() {
@Override
public void run() {
message.set(receiver.receive(queue));
latch1.countDown();
@@ -196,6 +198,7 @@ public class PollableJmsChannelTests {
boolean sent2 = channel.send(MessageBuilder.withPayload("foo").setPriority(6).build());
assertTrue(sent2);
Executors.newSingleThreadExecutor().execute(new Runnable() {
@Override
public void run() {
message.set(receiver.receive(queue));
latch2.countDown();
@@ -231,6 +234,7 @@ public class PollableJmsChannelTests {
jmsTemplate.setDefaultDestinationName("pollableJmsChannelSelectorTestQueue");
jmsTemplate.send(new MessageCreator() {
@Override
public javax.jms.Message createMessage(Session session) throws JMSException {
TextMessage message = session.createTextMessage("bar");
message.setStringProperty("baz", "qux");

View File

@@ -27,8 +27,8 @@ import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.integration.channel.AbstractMessageChannel;
import org.springframework.integration.channel.interceptor.ChannelInterceptorAdapter;
import org.springframework.integration.test.util.TestUtils;
import org.springframework.messaging.support.ChannelInterceptorAdapter;
/**
* @author Oleg Zhurakousky

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -30,12 +30,10 @@ import javax.jms.Topic;
import org.junit.After;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.DirectFieldAccessor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.support.AbstractApplicationContext;
import org.springframework.messaging.MessageChannel;
import org.springframework.integration.channel.ChannelInterceptor;
import org.springframework.integration.channel.interceptor.ChannelInterceptorAdapter;
import org.springframework.integration.jms.PollableJmsChannel;
import org.springframework.integration.jms.SubscribableJmsChannel;
import org.springframework.integration.test.util.TestUtils;
@@ -44,6 +42,9 @@ import org.springframework.jms.listener.AbstractMessageListenerContainer;
import org.springframework.jms.listener.DefaultMessageListenerContainer;
import org.springframework.jms.listener.SimpleMessageListenerContainer;
import org.springframework.jms.support.destination.DestinationResolver;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.support.ChannelInterceptor;
import org.springframework.messaging.support.ChannelInterceptorAdapter;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@@ -307,6 +308,7 @@ public class JmsChannelParserTests {
@Autowired
private Topic topic;
@Override
public Destination resolveDestinationName(Session session, String destinationName, boolean pubSubDomain)
throws JMSException {
if (!"foo".equals(destinationName)) {