INT-2325
* fix RedisChannelParser 'serializer' ref * some RedisChannelParser polishing * test for 'serializer' attribute * SubscribableRedisChannel delegates getPhase() to container
This commit is contained in:
@@ -126,7 +126,7 @@ public class SubscribableRedisChannel extends AbstractMessageChannel implements
|
||||
}
|
||||
|
||||
public int getPhase() {
|
||||
return 0;
|
||||
return (this.container != null) ? this.container.getPhase() : 0;
|
||||
}
|
||||
|
||||
public boolean isRunning() {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2010 the original author or authors.
|
||||
* Copyright 2002-2011 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,6 +22,7 @@ import org.springframework.beans.factory.support.BeanDefinitionBuilder;
|
||||
import org.springframework.beans.factory.xml.ParserContext;
|
||||
import org.springframework.integration.config.xml.AbstractChannelParser;
|
||||
import org.springframework.integration.config.xml.IntegrationNamespaceUtils;
|
||||
import org.springframework.integration.redis.channel.SubscribableRedisChannel;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
@@ -29,14 +30,14 @@ import org.springframework.util.StringUtils;
|
||||
* Spring Integration Redis namespace.
|
||||
*
|
||||
* @author Oleg Zhurakusky
|
||||
* @author Artem Bilan
|
||||
* @since 2.1
|
||||
*/
|
||||
public class RedisChannelParser extends AbstractChannelParser {
|
||||
|
||||
@Override
|
||||
protected BeanDefinitionBuilder buildBeanDefinition(Element element, ParserContext parserContext) {
|
||||
BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(
|
||||
"org.springframework.integration.redis.channel.SubscribableRedisChannel");
|
||||
BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(SubscribableRedisChannel.class);
|
||||
String connectionFactory = element.getAttribute("connection-factory");
|
||||
if (!StringUtils.hasText(connectionFactory)) {
|
||||
connectionFactory = "redisConnectionFactory";
|
||||
@@ -47,9 +48,11 @@ public class RedisChannelParser extends AbstractChannelParser {
|
||||
|
||||
IntegrationNamespaceUtils.setReferenceIfAttributeDefined(builder, element, "task-executor");
|
||||
IntegrationNamespaceUtils.setReferenceIfAttributeDefined(builder, element, "message-converter");
|
||||
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "phase");
|
||||
// IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "auto-startup");
|
||||
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "serializer");
|
||||
IntegrationNamespaceUtils.setReferenceIfAttributeDefined(builder, element, "serializer");
|
||||
// The following 2 attributes should be added once configurable on the RedisMessageListenerContainer
|
||||
// IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "phase");
|
||||
// IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "auto-startup");
|
||||
return builder;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -119,6 +119,7 @@
|
||||
</xsd:appinfo>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
<!-- The following two attributes should be added once configurable on the RedisMessageListenerContainer -->
|
||||
<!-- <xsd:attribute name="auto-startup" type="xsd:string"> -->
|
||||
<!-- <xsd:annotation> -->
|
||||
<!-- <xsd:documentation><![CDATA[ -->
|
||||
|
||||
@@ -9,9 +9,13 @@
|
||||
http://www.springframework.org/schema/integration/redis http://www.springframework.org/schema/integration/redis/spring-integration-redis.xsd
|
||||
http://www.springframework.org/schema/redis http://www.springframework.org/schema/redis/spring-redis.xsd">
|
||||
|
||||
<int-redis:publish-subscribe-channel id="redisChannel" topic-name="si.test.topic"/>
|
||||
<int-redis:publish-subscribe-channel id="redisChannel" topic-name="si.test.topic"
|
||||
serializer="redisSerializer"/>
|
||||
|
||||
<bean id="redisConnectionFactory" class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory">
|
||||
<property name="port" value="7379"/>
|
||||
</bean>
|
||||
|
||||
<bean id="redisSerializer" class="org.springframework.data.redis.serializer.StringRedisSerializer"/>
|
||||
|
||||
</beans>
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.integration.redis.config;
|
||||
|
||||
import org.junit.Test;
|
||||
@@ -20,6 +21,7 @@ import org.mockito.Mockito;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
|
||||
import org.springframework.data.redis.serializer.RedisSerializer;
|
||||
import org.springframework.integration.Message;
|
||||
import org.springframework.integration.MessagingException;
|
||||
import org.springframework.integration.core.MessageHandler;
|
||||
@@ -33,7 +35,6 @@ import static junit.framework.Assert.assertEquals;
|
||||
|
||||
/**
|
||||
* @author Oleg Zhurakousky
|
||||
*
|
||||
*/
|
||||
public class RedisChannelParserTests extends RedisAvailableTests{
|
||||
|
||||
@@ -44,7 +45,9 @@ public class RedisChannelParserTests extends RedisAvailableTests{
|
||||
SubscribableChannel redisChannel = context.getBean("redisChannel", SubscribableChannel.class);
|
||||
JedisConnectionFactory connectionFactory =
|
||||
TestUtils.getPropertyValue(redisChannel, "connectionFactory", JedisConnectionFactory.class);
|
||||
RedisSerializer<?> redisSerializer = TestUtils.getPropertyValue(redisChannel, "serializer", RedisSerializer.class);
|
||||
assertEquals(connectionFactory, context.getBean("redisConnectionFactory"));
|
||||
assertEquals(redisSerializer, context.getBean("redisSerializer"));
|
||||
assertEquals("si.test.topic", TestUtils.getPropertyValue(redisChannel, "topicName"));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user