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:
@@ -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.
|
||||
@@ -20,6 +20,7 @@ import java.util.List;
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
import org.aopalliance.aop.Advice;
|
||||
|
||||
import org.springframework.amqp.core.AcknowledgeMode;
|
||||
import org.springframework.amqp.core.AmqpAdmin;
|
||||
import org.springframework.amqp.core.AmqpTemplate;
|
||||
@@ -39,7 +40,7 @@ import org.springframework.integration.amqp.channel.AbstractAmqpChannel;
|
||||
import org.springframework.integration.amqp.channel.PointToPointSubscribableAmqpChannel;
|
||||
import org.springframework.integration.amqp.channel.PollableAmqpChannel;
|
||||
import org.springframework.integration.amqp.channel.PublishSubscribeAmqpChannel;
|
||||
import org.springframework.integration.channel.ChannelInterceptor;
|
||||
import org.springframework.messaging.support.ChannelInterceptor;
|
||||
import org.springframework.transaction.PlatformTransactionManager;
|
||||
import org.springframework.transaction.interceptor.TransactionAttribute;
|
||||
import org.springframework.util.Assert;
|
||||
@@ -133,6 +134,7 @@ public class AmqpChannelFactoryBean extends AbstractFactoryBean<AbstractAmqpChan
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setBeanName(String name) {
|
||||
this.beanName = name;
|
||||
}
|
||||
@@ -402,33 +404,39 @@ public class AmqpChannelFactoryBean extends AbstractFactoryBean<AbstractAmqpChan
|
||||
* SmartLifecycle implementation (delegates to the created channel if message-driven)
|
||||
*/
|
||||
|
||||
@Override
|
||||
public boolean isAutoStartup() {
|
||||
return (this.channel instanceof SmartLifecycle) ?
|
||||
((SmartLifecycle) this.channel).isAutoStartup() : false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPhase() {
|
||||
return (this.channel instanceof SmartLifecycle) ?
|
||||
((SmartLifecycle) this.channel).getPhase() : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRunning() {
|
||||
return (this.channel instanceof Lifecycle) ?
|
||||
((Lifecycle) this.channel).isRunning() : false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start() {
|
||||
if (this.channel instanceof Lifecycle) {
|
||||
((Lifecycle) this.channel).start();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stop() {
|
||||
if (this.channel instanceof Lifecycle) {
|
||||
((Lifecycle) this.channel).stop();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stop(Runnable callback) {
|
||||
if (this.channel instanceof SmartLifecycle) {
|
||||
((SmartLifecycle) this.channel).stop(callback);
|
||||
|
||||
@@ -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.
|
||||
@@ -22,11 +22,12 @@ import java.util.List;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
import org.springframework.integration.channel.interceptor.ChannelInterceptorAdapter;
|
||||
import org.springframework.integration.test.util.TestUtils;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
import org.springframework.messaging.support.ChannelInterceptorAdapter;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@ import java.util.concurrent.CopyOnWriteArrayList;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.springframework.core.OrderComparator;
|
||||
import org.springframework.core.convert.ConversionService;
|
||||
import org.springframework.integration.context.IntegrationObjectSupport;
|
||||
@@ -32,6 +33,7 @@ import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
import org.springframework.messaging.MessageDeliveryException;
|
||||
import org.springframework.messaging.MessagingException;
|
||||
import org.springframework.messaging.support.ChannelInterceptor;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
@@ -39,7 +41,7 @@ import org.springframework.util.StringUtils;
|
||||
* Base class for {@link MessageChannel} implementations providing common
|
||||
* properties such as the channel name. Also provides the common functionality
|
||||
* for sending and receiving {@link Message Messages} including the invocation
|
||||
* of any {@link ChannelInterceptor ChannelInterceptors}.
|
||||
* of any {@link org.springframework.messaging.support.ChannelInterceptor ChannelInterceptors}.
|
||||
*
|
||||
* @author Mark Fisher
|
||||
* @author Oleg Zhurakousky
|
||||
@@ -63,6 +65,7 @@ public abstract class AbstractMessageChannel extends IntegrationObjectSupport im
|
||||
return "channel";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setShouldTrack(boolean shouldTrack) {
|
||||
this.shouldTrack = shouldTrack;
|
||||
}
|
||||
@@ -145,6 +148,7 @@ public abstract class AbstractMessageChannel extends IntegrationObjectSupport im
|
||||
* @return <code>true</code> if the message is sent successfully or
|
||||
* <code>false</code> if the sending thread is interrupted.
|
||||
*/
|
||||
@Override
|
||||
public final boolean send(Message<?> message) {
|
||||
return this.send(message, -1);
|
||||
}
|
||||
@@ -163,6 +167,7 @@ public abstract class AbstractMessageChannel extends IntegrationObjectSupport im
|
||||
* <code>false</code> if the message cannot be sent within the allotted
|
||||
* time or the sending thread is interrupted.
|
||||
*/
|
||||
@Override
|
||||
public final boolean send(Message<?> message, long timeout) {
|
||||
Assert.notNull(message, "message must not be null");
|
||||
Assert.notNull(message.getPayload(), "message payload must not be null");
|
||||
|
||||
@@ -1,59 +0,0 @@
|
||||
/*
|
||||
* Copyright 2002-2010 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.integration.channel;
|
||||
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
|
||||
/**
|
||||
* Interface for interceptors that are able to view and/or modify the
|
||||
* {@link Message Messages} being sent-to and/or received-from a
|
||||
* {@link MessageChannel}.
|
||||
*
|
||||
* @author Mark Fisher
|
||||
*/
|
||||
public interface ChannelInterceptor {
|
||||
|
||||
/**
|
||||
* Invoked before the Message is actually sent to the channel.
|
||||
* This allows for modification of the Message if necessary.
|
||||
* If this method returns <code>null</code>, then the actual
|
||||
* send invocation will not occur.
|
||||
*/
|
||||
Message<?> preSend(Message<?> message, MessageChannel channel);
|
||||
|
||||
/**
|
||||
* Invoked immediately after the send invocation. The boolean
|
||||
* value argument represents the return value of that invocation.
|
||||
*/
|
||||
void postSend(Message<?> message, MessageChannel channel, boolean sent);
|
||||
|
||||
/**
|
||||
* Invoked as soon as receive is called and before a Message is
|
||||
* actually retrieved. If the return value is 'false', then no
|
||||
* Message will be retrieved. This only applies to PollableChannels.
|
||||
*/
|
||||
boolean preReceive(MessageChannel channel);
|
||||
|
||||
/**
|
||||
* Invoked immediately after a Message has been retrieved but before
|
||||
* it is returned to the caller. The Message may be modified if
|
||||
* necessary. This only applies to PollableChannels.
|
||||
*/
|
||||
Message<?> postReceive(Message<?> message, MessageChannel channel);
|
||||
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
/*
|
||||
* Copyright 2002-2008 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.integration.channel.interceptor;
|
||||
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
import org.springframework.integration.channel.ChannelInterceptor;
|
||||
|
||||
/**
|
||||
* A {@link ChannelInterceptor} with no-op method implementations so that
|
||||
* subclasses do not have to implement all of the interface's methods.
|
||||
*
|
||||
* @author Mark Fisher
|
||||
*/
|
||||
public class ChannelInterceptorAdapter implements ChannelInterceptor {
|
||||
|
||||
public Message<?> preSend(Message<?> message, MessageChannel channel) {
|
||||
return message;
|
||||
}
|
||||
|
||||
public void postSend(Message<?> message, MessageChannel channel, boolean sent) {
|
||||
}
|
||||
|
||||
public boolean preReceive(MessageChannel channel) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public Message<?> postReceive(Message<?> message, MessageChannel channel) {
|
||||
return message;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2010 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.
|
||||
@@ -34,13 +34,13 @@ import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.beans.factory.config.BeanPostProcessor;
|
||||
import org.springframework.core.OrderComparator;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
import org.springframework.integration.channel.ChannelInterceptor;
|
||||
import org.springframework.messaging.support.ChannelInterceptor;
|
||||
import org.springframework.util.PatternMatchUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* Will apply global interceptors to channels (<channel-interceptor>).
|
||||
*
|
||||
* Will apply global interceptors to channels (<channel-interceptor>).
|
||||
*
|
||||
* @author Oleg Zhurakousky
|
||||
* @author Mark Fisher
|
||||
* @since 2.0
|
||||
@@ -64,33 +64,36 @@ final class GlobalChannelInterceptorBeanPostProcessor implements BeanPostProcess
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
for (GlobalChannelInterceptorWrapper channelInterceptor : this.channelInterceptors) {
|
||||
if (channelInterceptor.getOrder() >= 0) {
|
||||
this.positiveOrderInterceptors.add(channelInterceptor);
|
||||
}
|
||||
}
|
||||
else {
|
||||
this.negativeOrderInterceptors.add(channelInterceptor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
|
||||
return bean;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
|
||||
if (bean instanceof MessageChannel) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Applying global interceptors on channel '" + beanName + "'");
|
||||
}
|
||||
this.addMatchingInterceptors((MessageChannel) bean, beanName);
|
||||
}
|
||||
}
|
||||
return bean;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds any interceptor whose pattern matches against the channel's name.
|
||||
* Adds any interceptor whose pattern matches against the channel's name.
|
||||
*/
|
||||
private void addMatchingInterceptors(MessageChannel channel, String beanName) {
|
||||
List<ChannelInterceptor> interceptors = this.getExistingInterceptors(channel);
|
||||
@@ -128,7 +131,7 @@ final class GlobalChannelInterceptorBeanPostProcessor implements BeanPostProcess
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private List<ChannelInterceptor> getExistingInterceptors(MessageChannel channel) {
|
||||
private List<ChannelInterceptor> getExistingInterceptors(MessageChannel channel) {
|
||||
try {
|
||||
MessageChannel targetChannel = channel;
|
||||
if (AopUtils.isAopProxy(channel)) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2010 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.
|
||||
@@ -17,7 +17,7 @@
|
||||
package org.springframework.integration.channel.interceptor;
|
||||
|
||||
import org.springframework.core.Ordered;
|
||||
import org.springframework.integration.channel.ChannelInterceptor;
|
||||
import org.springframework.messaging.support.ChannelInterceptor;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
@@ -53,6 +53,7 @@ public class GlobalChannelInterceptorWrapper implements Ordered {
|
||||
this.order = order;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOrder() {
|
||||
return this.order;
|
||||
}
|
||||
@@ -65,6 +66,7 @@ public class GlobalChannelInterceptorWrapper implements Ordered {
|
||||
return this.patterns;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return this.channelInterceptor.toString();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2008 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.
|
||||
@@ -23,9 +23,10 @@ import org.springframework.integration.core.MessageSelector;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
import org.springframework.messaging.MessageDeliveryException;
|
||||
import org.springframework.messaging.support.ChannelInterceptorAdapter;
|
||||
|
||||
/**
|
||||
* A {@link org.springframework.integration.channel.ChannelInterceptor} that
|
||||
* A {@link org.springframework.messaging.support.ChannelInterceptor ChannelInterceptor} that
|
||||
* delegates to a list of {@link MessageSelector MessageSelectors} to decide
|
||||
* whether a {@link Message} should be accepted on the {@link MessageChannel}.
|
||||
*
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2011 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.
|
||||
@@ -18,20 +18,22 @@ package org.springframework.integration.channel.interceptor;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.springframework.context.Lifecycle;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
import org.springframework.integration.channel.ChannelInterceptor;
|
||||
import org.springframework.integration.core.MessageSelector;
|
||||
import org.springframework.jmx.export.annotation.ManagedAttribute;
|
||||
import org.springframework.jmx.export.annotation.ManagedOperation;
|
||||
import org.springframework.jmx.export.annotation.ManagedResource;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
import org.springframework.messaging.support.ChannelInterceptor;
|
||||
import org.springframework.messaging.support.ChannelInterceptorAdapter;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* A {@link ChannelInterceptor} that publishes a copy of the intercepted message
|
||||
* to a secondary target while still sending the original message to the main channel.
|
||||
*
|
||||
*
|
||||
* @author Mark Fisher
|
||||
*/
|
||||
@ManagedResource
|
||||
@@ -50,7 +52,7 @@ public class WireTap extends ChannelInterceptorAdapter implements Lifecycle {
|
||||
|
||||
/**
|
||||
* Create a new wire tap with <em>no</em> {@link MessageSelector}.
|
||||
*
|
||||
*
|
||||
* @param channel the MessageChannel to which intercepted messages will be sent
|
||||
*/
|
||||
public WireTap(MessageChannel channel) {
|
||||
@@ -59,7 +61,7 @@ public class WireTap extends ChannelInterceptorAdapter implements Lifecycle {
|
||||
|
||||
/**
|
||||
* Create a new wire tap with the provided {@link MessageSelector}.
|
||||
*
|
||||
*
|
||||
* @param channel the channel to which intercepted messages will be sent
|
||||
* @param selector the selector that must accept a message for it to be
|
||||
* sent to the intercepting channel
|
||||
@@ -73,7 +75,7 @@ public class WireTap extends ChannelInterceptorAdapter implements Lifecycle {
|
||||
|
||||
/**
|
||||
* Specify the timeout value for sending to the intercepting target.
|
||||
*
|
||||
*
|
||||
* @param timeout the timeout in milliseconds
|
||||
*/
|
||||
public void setTimeout(long timeout) {
|
||||
@@ -83,6 +85,7 @@ public class WireTap extends ChannelInterceptorAdapter implements Lifecycle {
|
||||
/**
|
||||
* Check whether the wire tap is currently running.
|
||||
*/
|
||||
@Override
|
||||
@ManagedAttribute
|
||||
public boolean isRunning() {
|
||||
return this.running;
|
||||
@@ -91,6 +94,7 @@ public class WireTap extends ChannelInterceptorAdapter implements Lifecycle {
|
||||
/**
|
||||
* Restart the wire tap if it has been stopped. It is running by default.
|
||||
*/
|
||||
@Override
|
||||
@ManagedOperation
|
||||
public void start() {
|
||||
this.running = true;
|
||||
@@ -99,6 +103,7 @@ public class WireTap extends ChannelInterceptorAdapter implements Lifecycle {
|
||||
/**
|
||||
* Stop the wire tap. To restart, invoke {@link #start()}.
|
||||
*/
|
||||
@Override
|
||||
@ManagedOperation
|
||||
public void stop() {
|
||||
this.running = false;
|
||||
|
||||
@@ -18,8 +18,8 @@ package org.springframework.integration.transformer;
|
||||
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
import org.springframework.integration.channel.ChannelInterceptor;
|
||||
import org.springframework.integration.channel.interceptor.ChannelInterceptorAdapter;
|
||||
import org.springframework.messaging.support.ChannelInterceptor;
|
||||
import org.springframework.messaging.support.ChannelInterceptorAdapter;
|
||||
|
||||
/**
|
||||
* A {@link ChannelInterceptor} which invokes a {@link Transformer}
|
||||
|
||||
@@ -37,17 +37,17 @@ import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
import org.springframework.integration.channel.DirectChannel;
|
||||
import org.springframework.integration.channel.PublishSubscribeChannel;
|
||||
import org.springframework.integration.channel.QueueChannel;
|
||||
import org.springframework.integration.channel.interceptor.ChannelInterceptorAdapter;
|
||||
import org.springframework.integration.config.TestChannelInterceptor;
|
||||
import org.springframework.integration.dispatcher.RoundRobinLoadBalancingStrategy;
|
||||
import org.springframework.integration.dispatcher.UnicastingDispatcher;
|
||||
import org.springframework.messaging.support.GenericMessage;
|
||||
import org.springframework.integration.support.MessageBuilder;
|
||||
import org.springframework.integration.util.ErrorHandlingTaskExecutor;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
import org.springframework.messaging.MessageDeliveryException;
|
||||
import org.springframework.messaging.PollableChannel;
|
||||
import org.springframework.messaging.support.ChannelInterceptorAdapter;
|
||||
import org.springframework.messaging.support.GenericMessage;
|
||||
|
||||
/**
|
||||
* @author Mark Fisher
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2010 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.
|
||||
@@ -31,12 +31,13 @@ import org.junit.Test;
|
||||
import org.springframework.beans.DirectFieldAccessor;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
import org.springframework.integration.channel.AbstractMessageChannel;
|
||||
import org.springframework.integration.channel.QueueChannel;
|
||||
import org.springframework.messaging.support.GenericMessage;
|
||||
import org.springframework.integration.support.MessageBuilder;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
import org.springframework.messaging.support.ChannelInterceptorAdapter;
|
||||
import org.springframework.messaging.support.GenericMessage;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
@@ -120,7 +121,7 @@ public class ChannelInterceptorTests {
|
||||
channel.send(message);
|
||||
Message<?> result = channel.receive(0);
|
||||
assertEquals(1, PreReceiveReturnsTrueInterceptor.counter.get());
|
||||
assertNotNull(result);
|
||||
assertNotNull(result);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -130,7 +131,7 @@ public class ChannelInterceptorTests {
|
||||
channel.send(message);
|
||||
Message<?> result = channel.receive(0);
|
||||
assertEquals(1, PreReceiveReturnsFalseInterceptor.counter.get());
|
||||
assertNull(result);
|
||||
assertNull(result);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -154,7 +155,7 @@ public class ChannelInterceptorTests {
|
||||
assertEquals(0, messageCount.get());
|
||||
channel.send(new GenericMessage<String>("test"));
|
||||
Message<?> result = channel.receive(0);
|
||||
assertNotNull(result);
|
||||
assertNotNull(result);
|
||||
assertEquals(2, invokedCount.get());
|
||||
assertEquals(1, messageCount.get());
|
||||
}
|
||||
@@ -174,7 +175,7 @@ public class ChannelInterceptorTests {
|
||||
}
|
||||
|
||||
|
||||
public static class PreSendReturnsMessageInterceptor extends ChannelInterceptorAdapter {
|
||||
public static class PreSendReturnsMessageInterceptor extends ChannelInterceptorAdapter {
|
||||
private String foo;
|
||||
|
||||
private static AtomicInteger counter = new AtomicInteger();
|
||||
@@ -196,7 +197,7 @@ public class ChannelInterceptorTests {
|
||||
}
|
||||
|
||||
|
||||
private static class PreSendReturnsNullInterceptor extends ChannelInterceptorAdapter {
|
||||
private static class PreSendReturnsNullInterceptor extends ChannelInterceptorAdapter {
|
||||
|
||||
private static AtomicInteger counter = new AtomicInteger();
|
||||
|
||||
@@ -213,7 +214,7 @@ public class ChannelInterceptorTests {
|
||||
}
|
||||
|
||||
|
||||
private static class PreReceiveReturnsTrueInterceptor extends ChannelInterceptorAdapter {
|
||||
private static class PreReceiveReturnsTrueInterceptor extends ChannelInterceptorAdapter {
|
||||
|
||||
private static AtomicInteger counter = new AtomicInteger();
|
||||
|
||||
@@ -225,7 +226,7 @@ public class ChannelInterceptorTests {
|
||||
}
|
||||
|
||||
|
||||
private static class PreReceiveReturnsFalseInterceptor extends ChannelInterceptorAdapter {
|
||||
private static class PreReceiveReturnsFalseInterceptor extends ChannelInterceptorAdapter {
|
||||
|
||||
private static AtomicInteger counter = new AtomicInteger();
|
||||
|
||||
|
||||
@@ -25,16 +25,17 @@ import org.aopalliance.intercept.MethodInvocation;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.aop.framework.Advised;
|
||||
import org.springframework.aop.support.AopUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.core.Ordered;
|
||||
import org.springframework.integration.test.util.TestUtils;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
import org.springframework.integration.channel.ChannelInterceptor;
|
||||
import org.springframework.integration.test.util.TestUtils;
|
||||
import org.springframework.messaging.support.ChannelInterceptor;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
@@ -48,7 +49,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
public class GlobalChannelInterceptorTests {
|
||||
@Autowired
|
||||
ApplicationContext applicationContext;
|
||||
|
||||
|
||||
@Test
|
||||
public void validateGlobalInterceptor() throws Exception{
|
||||
Map<String, MessageChannel> channels = applicationContext.getBeansOfType(MessageChannel.class);
|
||||
@@ -61,7 +62,7 @@ public class GlobalChannelInterceptorTests {
|
||||
channel = (MessageChannel) ((Advised)channel).getTargetSource().getTarget();
|
||||
}
|
||||
List<?> interceptorList = TestUtils.getPropertyValue(channel, "interceptors.interceptors", List.class);
|
||||
ChannelInterceptor[] interceptors = interceptorList.toArray(new ChannelInterceptor[] {});
|
||||
ChannelInterceptor[] interceptors = interceptorList.toArray(new ChannelInterceptor[] {});
|
||||
if (channelName.equals("inputA")){ // 328741
|
||||
Assert.assertTrue(interceptors.length ==10);
|
||||
Assert.assertEquals("interceptor-three", interceptors[0].toString());
|
||||
@@ -74,7 +75,7 @@ public class GlobalChannelInterceptorTests {
|
||||
Assert.assertEquals("interceptor-eleven", interceptors[7].toString());
|
||||
Assert.assertEquals("interceptor-four", interceptors[8].toString());
|
||||
Assert.assertEquals("interceptor-one", interceptors[9].toString());
|
||||
}
|
||||
}
|
||||
else if (channelName.equals("inputB")) {
|
||||
Assert.assertTrue(interceptors.length == 6);
|
||||
Assert.assertEquals("interceptor-three", interceptors[0].toString());
|
||||
@@ -83,7 +84,7 @@ public class GlobalChannelInterceptorTests {
|
||||
Assert.assertEquals("interceptor-eleven", interceptors[3].toString());
|
||||
Assert.assertEquals("interceptor-four", interceptors[4].toString());
|
||||
Assert.assertEquals("interceptor-one", interceptors[5].toString());
|
||||
}
|
||||
}
|
||||
else if (channelName.equals("foo")) {
|
||||
Assert.assertTrue(interceptors.length == 6);
|
||||
Assert.assertEquals("interceptor-two", interceptors[0].toString());
|
||||
@@ -111,13 +112,13 @@ public class GlobalChannelInterceptorTests {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Autowired
|
||||
@Qualifier("inpuC")
|
||||
MessageChannel inpuCchannel;
|
||||
@Test
|
||||
public void testWildCardPatternMatch() {
|
||||
|
||||
|
||||
List<?> interceptorList = TestUtils.getPropertyValue(inpuCchannel, "interceptors.interceptors", List.class);
|
||||
List<String> interceptorNames = new ArrayList<String>();
|
||||
for (Object interceptor : interceptorList) {
|
||||
@@ -127,7 +128,7 @@ public class GlobalChannelInterceptorTests {
|
||||
Assert.assertTrue(interceptorNames.contains("interceptor-eleven"));
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static class SampleInterceptor implements ChannelInterceptor {
|
||||
|
||||
private String testIdentifier;
|
||||
@@ -153,10 +154,11 @@ public class GlobalChannelInterceptorTests {
|
||||
|
||||
public Message<?> preSend(Message<?> message, MessageChannel channel) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "interceptor-" + testIdentifier;
|
||||
return "interceptor-" + testIdentifier;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -165,21 +167,23 @@ public class GlobalChannelInterceptorTests {
|
||||
|
||||
private int order;
|
||||
|
||||
@Override
|
||||
public int getOrder() {
|
||||
return order;
|
||||
}
|
||||
}
|
||||
|
||||
public void setOrder(int order) {
|
||||
this.order = order;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static class TestInterceptor implements MethodInterceptor{
|
||||
|
||||
@Override
|
||||
public Object invoke(MethodInvocation invocation) throws Throwable {
|
||||
return invocation.proceed();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
import org.springframework.integration.channel.interceptor.ChannelInterceptorAdapter;
|
||||
import org.springframework.messaging.support.ChannelInterceptorAdapter;
|
||||
|
||||
/**
|
||||
* @author Mark Fisher
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2008 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.
|
||||
@@ -20,7 +20,7 @@ import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
import org.springframework.integration.channel.interceptor.ChannelInterceptorAdapter;
|
||||
import org.springframework.messaging.support.ChannelInterceptorAdapter;
|
||||
|
||||
/**
|
||||
* @author Mark Fisher
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2010 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.
|
||||
@@ -16,6 +16,10 @@
|
||||
|
||||
package org.springframework.integration.security.config;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
@@ -26,25 +30,22 @@ import java.util.regex.Pattern;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.aop.Advisor;
|
||||
import org.springframework.aop.framework.Advised;
|
||||
import org.springframework.aop.support.AopUtils;
|
||||
import org.springframework.beans.DirectFieldAccessor;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
import org.springframework.integration.channel.AbstractPollableChannel;
|
||||
import org.springframework.integration.channel.ChannelInterceptor;
|
||||
import org.springframework.integration.core.MessageSelector;
|
||||
import org.springframework.integration.security.channel.ChannelAccessPolicy;
|
||||
import org.springframework.integration.security.channel.ChannelSecurityInterceptor;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
import org.springframework.messaging.support.ChannelInterceptor;
|
||||
import org.springframework.security.access.ConfigAttribute;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.AbstractJUnit4SpringContextTests;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
/**
|
||||
* @author Jonas Partner
|
||||
* @author Mark Fisher
|
||||
|
||||
Reference in New Issue
Block a user