INT-4354: Add beanClassLoader support to RedisMS
JIRA: https://jira.spring.io/browse/INT-4354 It's hard to test different ClassLoader in unit tests, so the fix comes without them **Cherry-pick to 4.3.x**
This commit is contained in:
committed by
Gary Russell
parent
442d6c6a90
commit
6ec34c114c
@@ -19,6 +19,7 @@ package org.springframework.integration.redis.store;
|
||||
import java.util.Collection;
|
||||
import java.util.Set;
|
||||
|
||||
import org.springframework.beans.factory.BeanClassLoaderAware;
|
||||
import org.springframework.data.redis.connection.RedisConnectionFactory;
|
||||
import org.springframework.data.redis.core.BoundValueOperations;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
@@ -40,10 +41,12 @@ import org.springframework.util.Assert;
|
||||
*
|
||||
* @since 2.1
|
||||
*/
|
||||
public class RedisMessageStore extends AbstractKeyValueMessageStore {
|
||||
public class RedisMessageStore extends AbstractKeyValueMessageStore implements BeanClassLoaderAware {
|
||||
|
||||
private final RedisTemplate<Object, Object> redisTemplate;
|
||||
|
||||
private boolean valueSerializerSet;
|
||||
|
||||
/**
|
||||
* Construct {@link RedisMessageStore} based on the provided
|
||||
* {@link RedisConnectionFactory} and default empty prefix.
|
||||
@@ -71,9 +74,17 @@ public class RedisMessageStore extends AbstractKeyValueMessageStore {
|
||||
this.redisTemplate.afterPropertiesSet();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBeanClassLoader(ClassLoader classLoader) {
|
||||
if (!this.valueSerializerSet) {
|
||||
this.redisTemplate.setValueSerializer(new JdkSerializationRedisSerializer(classLoader));
|
||||
}
|
||||
}
|
||||
|
||||
public void setValueSerializer(RedisSerializer<?> valueSerializer) {
|
||||
Assert.notNull(valueSerializer, "'valueSerializer' must not be null");
|
||||
this.redisTemplate.setValueSerializer(valueSerializer);
|
||||
this.valueSerializerSet = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user