INT-965 JmsChannelParser now extends AbstractChannelParser to support interceptors
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
|
||||
package org.springframework.integration.jms.config;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
import javax.jms.ConnectionFactory;
|
||||
@@ -26,6 +27,7 @@ import javax.jms.Session;
|
||||
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.PollableJmsChannel;
|
||||
import org.springframework.integration.jms.SubscribableJmsChannel;
|
||||
@@ -37,6 +39,7 @@ import org.springframework.jms.support.converter.MessageConverter;
|
||||
import org.springframework.jms.support.destination.DestinationResolver;
|
||||
import org.springframework.transaction.PlatformTransactionManager;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.ErrorHandler;
|
||||
|
||||
/**
|
||||
@@ -47,6 +50,8 @@ public class JmsChannelFactoryBean extends AbstractFactoryBean<AbstractJmsChanne
|
||||
|
||||
private volatile AbstractJmsChannel channel;
|
||||
|
||||
private volatile List<ChannelInterceptor> interceptors;
|
||||
|
||||
private final boolean messageDriven;
|
||||
|
||||
private final JmsTemplate jmsTemplate = new JmsTemplate();
|
||||
@@ -125,6 +130,10 @@ public class JmsChannelFactoryBean extends AbstractFactoryBean<AbstractJmsChanne
|
||||
}
|
||||
|
||||
|
||||
public void setInterceptors(List<ChannelInterceptor> interceptors) {
|
||||
this.interceptors = interceptors;
|
||||
}
|
||||
|
||||
/*
|
||||
* Template properties
|
||||
*/
|
||||
@@ -302,6 +311,9 @@ public class JmsChannelFactoryBean extends AbstractFactoryBean<AbstractJmsChanne
|
||||
else {
|
||||
this.channel = new PollableJmsChannel(this.jmsTemplate);
|
||||
}
|
||||
if (!CollectionUtils.isEmpty(this.interceptors)) {
|
||||
this.channel.setInterceptors(this.interceptors);
|
||||
}
|
||||
this.channel.afterPropertiesSet();
|
||||
return this.channel;
|
||||
}
|
||||
|
||||
@@ -21,8 +21,8 @@ import javax.jms.Session;
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
|
||||
import org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser;
|
||||
import org.springframework.beans.factory.xml.ParserContext;
|
||||
import org.springframework.integration.config.xml.AbstractChannelParser;
|
||||
import org.springframework.integration.config.xml.IntegrationNamespaceUtils;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.StringUtils;
|
||||
@@ -34,7 +34,7 @@ import org.springframework.util.StringUtils;
|
||||
* @author Mark Fisher
|
||||
* @since 2.0
|
||||
*/
|
||||
public class JmsChannelParser extends AbstractSingleBeanDefinitionParser {
|
||||
public class JmsChannelParser extends AbstractChannelParser {
|
||||
|
||||
private final static String CONTAINER_TYPE_ATTRIBUTE = "container-type";
|
||||
|
||||
@@ -44,12 +44,9 @@ public class JmsChannelParser extends AbstractSingleBeanDefinitionParser {
|
||||
|
||||
|
||||
@Override
|
||||
protected String getBeanClassName(Element element) {
|
||||
return "org.springframework.integration.jms.config.JmsChannelFactoryBean";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) {
|
||||
protected BeanDefinitionBuilder buildBeanDefinition(Element element, ParserContext parserContext) {
|
||||
BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(
|
||||
"org.springframework.integration.jms.config.JmsChannelFactoryBean");
|
||||
builder.addConstructorArgValue(element.getAttribute("message-driven"));
|
||||
String connectionFactory = element.getAttribute("connection-factory");
|
||||
if (!StringUtils.hasText(connectionFactory)) {
|
||||
@@ -123,6 +120,7 @@ public class JmsChannelParser extends AbstractSingleBeanDefinitionParser {
|
||||
builder.addPropertyValue("maxMessagesPerTask", new Integer(prefetch));
|
||||
}
|
||||
}
|
||||
return builder;
|
||||
}
|
||||
|
||||
private void parseDestination(Element element, ParserContext parserContext, BeanDefinitionBuilder builder, String type) {
|
||||
|
||||
Reference in New Issue
Block a user