diff --git a/build.gradle b/build.gradle index 13bf948aa..82cc1df87 100644 --- a/build.gradle +++ b/build.gradle @@ -55,6 +55,8 @@ dependencies { // Mappers compile("org.codehaus.jackson:jackson-mapper-asl:$jacksonVersion", optional) compile("commons-beanutils:commons-beanutils-core:1.8.3", optional) + compile("com.fasterxml.jackson.core:jackson-core:$fasterXmlJacksonVersion", optional) + compile("com.fasterxml.jackson.core:jackson-databind:$fasterXmlJacksonDatabindVersion", optional) // Pool compile("commons-pool:commons-pool:1.5.6", optional) diff --git a/docs/src/reference/docbook/reference/redis.xml b/docs/src/reference/docbook/reference/redis.xml index 6b59dfa0b..3704d0d39 100644 --- a/docs/src/reference/docbook/reference/redis.xml +++ b/docs/src/reference/docbook/reference/redis.xml @@ -394,8 +394,8 @@ (package org.springframework.data.redis.serializer) which as the name implies, takes care of the serialization process. Multiple implementations are available out of the box, two of which have been already mentioned before in this documentation: the StringRedisSerializer and the JdkSerializationRedisSerializer. However one can use OxmSerializer for Object/XML mapping through Spring 3 - OXM support or JacksonJsonRedisSerializer for storing - data in JSON format. Do note that the storage format is not limited only to values - it can be used for keys, values or hashes + OXM support or either JacksonJsonRedisSerializer or + Jackson2JsonRedisSerializer for storing data in JSON format. Do note that the storage format is not limited only to values - it can be used for keys, values or hashes without any restrictions. diff --git a/gradle.properties b/gradle.properties index f1e9c33e2..791df65e6 100644 --- a/gradle.properties +++ b/gradle.properties @@ -9,3 +9,5 @@ srpVersion=0.7 jacksonVersion=1.8.8 lettuceVersion=2.3.3 mockitoVersion=1.9.5 +fasterXmlJacksonVersion=2.2.0 +fasterXmlJacksonDatabindVersion=2.2.2 diff --git a/src/main/java/org/springframework/data/redis/serializer/Jackson2JsonRedisSerializer.java b/src/main/java/org/springframework/data/redis/serializer/Jackson2JsonRedisSerializer.java new file mode 100644 index 000000000..19e0ea7c2 --- /dev/null +++ b/src/main/java/org/springframework/data/redis/serializer/Jackson2JsonRedisSerializer.java @@ -0,0 +1,112 @@ +/* + * Copyright 2011-2014 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.data.redis.serializer; + +import java.nio.charset.Charset; + +import org.springframework.util.Assert; + +import com.fasterxml.jackson.databind.JavaType; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.ser.SerializerFactory; +import com.fasterxml.jackson.databind.type.TypeFactory; + +/** + * {@link RedisSerializer} that can read and write JSON using Jackson's and Jackson Databind {@link ObjectMapper}. + *

+ * This converter can be used to bind to typed beans, or untyped {@link java.util.HashMap HashMap} instances. + * Note:Null objects are serialized as empty arrays and vice versa. + * + * @author Thomas Darimont + * @since 1.2 + */ +public class Jackson2JsonRedisSerializer implements RedisSerializer { + + public static final Charset DEFAULT_CHARSET = Charset.forName("UTF-8"); + + private final JavaType javaType; + + private ObjectMapper objectMapper = new ObjectMapper(); + + public Jackson2JsonRedisSerializer(Class type) { + this.javaType = TypeFactory.defaultInstance().constructType(type); + } + + @SuppressWarnings("unchecked") + public T deserialize(byte[] bytes) throws SerializationException { + + if (SerializationUtils.isEmpty(bytes)) { + return null; + } + try { + return (T) this.objectMapper.readValue(bytes, 0, bytes.length, javaType); + } catch (Exception ex) { + throw new SerializationException("Could not read JSON: " + ex.getMessage(), ex); + } + } + + public byte[] serialize(Object t) throws SerializationException { + + if (t == null) { + return SerializationUtils.EMPTY_ARRAY; + } + try { + return this.objectMapper.writeValueAsBytes(t); + } catch (Exception ex) { + throw new SerializationException("Could not write JSON: " + ex.getMessage(), ex); + } + } + + /** + * Sets the {@code ObjectMapper} for this view. If not set, a default {@link ObjectMapper#ObjectMapper() ObjectMapper} + * is used. + *

+ * Setting a custom-configured {@code ObjectMapper} is one way to take further control of the JSON serialization + * process. For example, an extended {@link SerializerFactory} can be configured that provides custom serializers for + * specific types. The other option for refining the serialization process is to use Jackson's provided annotations on + * the types to be serialized, in which case a custom-configured ObjectMapper is unnecessary. + */ + public void setObjectMapper(ObjectMapper objectMapper) { + + Assert.notNull(objectMapper, "'objectMapper' must not be null"); + this.objectMapper = objectMapper; + } + + /** + * Returns the Jackson {@link JavaType} for the specific class. + *

+ * Default implementation returns {@link TypeFactory#constructType(java.lang.reflect.Type)}, but this can be + * overridden in subclasses, to allow for custom generic collection handling. For instance: + * + *

+	 * protected JavaType getJavaType(Class<?> clazz) {
+	 * 	if (List.class.isAssignableFrom(clazz)) {
+	 * 		return TypeFactory.defaultInstance().constructCollectionType(ArrayList.class, MyBean.class);
+	 * 	} else {
+	 * 		return super.getJavaType(clazz);
+	 * 	}
+	 * }
+	 * 
+ * + * @param clazz the class to return the java type for + * @return the java type + */ + protected JavaType getJavaType(Class clazz) { + return TypeFactory.defaultInstance().constructType(clazz); + } +} diff --git a/src/test/java/org/springframework/data/redis/core/AbstractOperationsTestParams.java b/src/test/java/org/springframework/data/redis/core/AbstractOperationsTestParams.java index 748229d85..6b7192bb3 100644 --- a/src/test/java/org/springframework/data/redis/core/AbstractOperationsTestParams.java +++ b/src/test/java/org/springframework/data/redis/core/AbstractOperationsTestParams.java @@ -1,5 +1,5 @@ /* - * Copyright 2013 the original author or authors. + * Copyright 2013 - 2014 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,6 +28,7 @@ import org.springframework.data.redis.SettingsUtils; import org.springframework.data.redis.StringObjectFactory; import org.springframework.data.redis.connection.srp.SrpConnectionFactory; import org.springframework.data.redis.serializer.GenericToStringSerializer; +import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer; import org.springframework.data.redis.serializer.JacksonJsonRedisSerializer; import org.springframework.data.redis.serializer.OxmSerializer; import org.springframework.data.redis.serializer.StringRedisSerializer; @@ -35,13 +36,17 @@ import org.springframework.oxm.xstream.XStreamMarshaller; /** * Parameters for testing implementations of {@link AbstractOperations} - * + * * @author Jennifer Hickey - * + * @author Thomas Darimont */ abstract public class AbstractOperationsTestParams { + /** + * @see DATAREDIS-241 + */ public static Collection testParams() { + ObjectFactory stringFactory = new StringObjectFactory(); ObjectFactory longFactory = new LongObjectFactory(); ObjectFactory doubleFactory = new DoubleObjectFactory(); @@ -56,31 +61,28 @@ abstract public class AbstractOperationsTestParams { throw new RuntimeException("Cannot init XStream", ex); } - OxmSerializer serializer = new OxmSerializer(xstream, xstream); - JacksonJsonRedisSerializer jsonSerializer = new JacksonJsonRedisSerializer(Person.class); - SrpConnectionFactory srConnFactory = new SrpConnectionFactory(); srConnFactory.setPort(SettingsUtils.getPort()); srConnFactory.setHostName(SettingsUtils.getHost()); srConnFactory.afterPropertiesSet(); - RedisTemplate stringTemplate = new StringRedisTemplate(); + RedisTemplate stringTemplate = new StringRedisTemplate(); stringTemplate.setConnectionFactory(srConnFactory); stringTemplate.afterPropertiesSet(); - RedisTemplate longTemplate = new RedisTemplate(); + RedisTemplate longTemplate = new RedisTemplate(); longTemplate.setKeySerializer(new StringRedisSerializer()); longTemplate.setValueSerializer(new GenericToStringSerializer(Long.class)); longTemplate.setConnectionFactory(srConnFactory); longTemplate.afterPropertiesSet(); - RedisTemplate doubleTemplate = new RedisTemplate(); + RedisTemplate doubleTemplate = new RedisTemplate(); doubleTemplate.setKeySerializer(new StringRedisSerializer()); doubleTemplate.setValueSerializer(new GenericToStringSerializer(Double.class)); doubleTemplate.setConnectionFactory(srConnFactory); doubleTemplate.afterPropertiesSet(); - RedisTemplate rawTemplate = new RedisTemplate(); + RedisTemplate rawTemplate = new RedisTemplate(); rawTemplate.setEnableDefaultSerializer(false); rawTemplate.setConnectionFactory(srConnFactory); rawTemplate.afterPropertiesSet(); @@ -89,6 +91,7 @@ abstract public class AbstractOperationsTestParams { personTemplate.setConnectionFactory(srConnFactory); personTemplate.afterPropertiesSet(); + OxmSerializer serializer = new OxmSerializer(xstream, xstream); RedisTemplate xstreamStringTemplate = new RedisTemplate(); xstreamStringTemplate.setConnectionFactory(srConnFactory); xstreamStringTemplate.setDefaultSerializer(serializer); @@ -99,15 +102,28 @@ abstract public class AbstractOperationsTestParams { xstreamPersonTemplate.setValueSerializer(serializer); xstreamPersonTemplate.afterPropertiesSet(); + JacksonJsonRedisSerializer jacksonJsonSerializer = new JacksonJsonRedisSerializer(Person.class); RedisTemplate jsonPersonTemplate = new RedisTemplate(); jsonPersonTemplate.setConnectionFactory(srConnFactory); - jsonPersonTemplate.setValueSerializer(jsonSerializer); + jsonPersonTemplate.setValueSerializer(jacksonJsonSerializer); jsonPersonTemplate.afterPropertiesSet(); - return Arrays.asList(new Object[][] { { stringTemplate, stringFactory, stringFactory }, - { longTemplate, stringFactory, longFactory }, { doubleTemplate, stringFactory, doubleFactory }, - { rawTemplate, rawFactory, rawFactory}, { personTemplate, stringFactory, personFactory }, - { xstreamStringTemplate, stringFactory, stringFactory }, { xstreamPersonTemplate, stringFactory, personFactory }, - { jsonPersonTemplate, stringFactory, personFactory }}); + Jackson2JsonRedisSerializer jackson2JsonSerializer = new Jackson2JsonRedisSerializer(Person.class); + RedisTemplate jackson2JsonPersonTemplate = new RedisTemplate(); + jackson2JsonPersonTemplate.setConnectionFactory(srConnFactory); + jackson2JsonPersonTemplate.setValueSerializer(jackson2JsonSerializer); + jackson2JsonPersonTemplate.afterPropertiesSet(); + + return Arrays.asList(new Object[][] { // + { stringTemplate, stringFactory, stringFactory }, // + { longTemplate, stringFactory, longFactory }, // + { doubleTemplate, stringFactory, doubleFactory }, // + { rawTemplate, rawFactory, rawFactory }, // + { personTemplate, stringFactory, personFactory }, // + { xstreamStringTemplate, stringFactory, stringFactory }, // + { xstreamPersonTemplate, stringFactory, personFactory }, // + { jsonPersonTemplate, stringFactory, personFactory }, // + { jackson2JsonPersonTemplate, stringFactory, personFactory } // + }); } } diff --git a/src/test/java/org/springframework/data/redis/serializer/Jackson2JsonRedisSerializerTests.java b/src/test/java/org/springframework/data/redis/serializer/Jackson2JsonRedisSerializerTests.java new file mode 100644 index 000000000..5d691f0ac --- /dev/null +++ b/src/test/java/org/springframework/data/redis/serializer/Jackson2JsonRedisSerializerTests.java @@ -0,0 +1,89 @@ +/* + * Copyright 2014 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.data.redis.serializer; + +import static org.junit.Assert.*; + +import java.util.Arrays; + +import org.hamcrest.core.Is; +import org.hamcrest.core.IsNull; +import org.junit.Before; +import org.junit.Test; +import org.springframework.data.redis.Person; +import org.springframework.data.redis.PersonObjectFactory; + +/** + * @author Thomas Darimont + * @author Christoph Strobl + */ +public class Jackson2JsonRedisSerializerTests { + + private Jackson2JsonRedisSerializer serializer; + + @Before + public void setUp() { + this.serializer = new Jackson2JsonRedisSerializer(Person.class); + } + + /** + * @see DATAREDIS-241 + */ + @Test + public void testJackson2JsonSerializer() throws Exception { + + Person person = new PersonObjectFactory().instance(); + assertEquals(person, serializer.deserialize(serializer.serialize(person))); + } + + /** + * @see DATAREDIS-241 + */ + @Test + public void testJackson2JsonSerializerShouldReturnEmptyByteArrayWhenSerializingNull() { + assertThat(serializer.serialize(null), Is.is(new byte[0])); + } + + /** + * @see DTATREDIS-241 + */ + @Test + public void testJackson2JsonSerializerShouldReturnNullWhenDerserializingEmtyByteArray() { + assertThat(serializer.deserialize(new byte[0]), IsNull.nullValue()); + } + + /** + * @see DTATREDIS-241 + */ + @Test(expected=SerializationException.class) + public void testJackson2JsonSerilizerShouldThrowExceptionWhenDeserializingInvalidByteArray() { + + Person person = new PersonObjectFactory().instance(); + byte [] serializedValue = serializer.serialize(person); + Arrays.sort(serializedValue); //corrupt serialization result + + serializer.deserialize(serializedValue); + } + + /** + * @see DTATREDIS-241 + */ + @Test(expected=IllegalArgumentException.class) + public void testJackson2JsonSerilizerThrowsExceptionWhenSettingNullObjectMapper() { + serializer.setObjectMapper(null); + } + +} diff --git a/src/test/java/org/springframework/data/redis/serializer/SimpleRedisSerializerTests.java b/src/test/java/org/springframework/data/redis/serializer/SimpleRedisSerializerTests.java index 484a3479d..6d4dbdf45 100644 --- a/src/test/java/org/springframework/data/redis/serializer/SimpleRedisSerializerTests.java +++ b/src/test/java/org/springframework/data/redis/serializer/SimpleRedisSerializerTests.java @@ -25,19 +25,16 @@ import org.junit.Before; import org.junit.Test; import org.springframework.data.redis.Address; import org.springframework.data.redis.Person; -import org.springframework.data.redis.serializer.JacksonJsonRedisSerializer; -import org.springframework.data.redis.serializer.JdkSerializationRedisSerializer; -import org.springframework.data.redis.serializer.OxmSerializer; -import org.springframework.data.redis.serializer.RedisSerializer; import org.springframework.oxm.xstream.XStreamMarshaller; - +/** + * @author Jennifer Hickey + */ public class SimpleRedisSerializerTests { private static class A implements Serializable { private Integer value = Integer.valueOf(30); - public int hashCode() { final int prime = 31; int result = 1; @@ -45,7 +42,6 @@ public class SimpleRedisSerializerTests { return result; } - public boolean equals(Object obj) { if (this == obj) return true; @@ -57,8 +53,7 @@ public class SimpleRedisSerializerTests { if (value == null) { if (other.value != null) return false; - } - else if (!value.equals(other.value)) + } else if (!value.equals(other.value)) return false; return true; } @@ -68,7 +63,6 @@ public class SimpleRedisSerializerTests { private String name = getClass().getName(); private A a = new A(); - public int hashCode() { final int prime = 31; int result = 1; @@ -77,7 +71,6 @@ public class SimpleRedisSerializerTests { return result; } - public boolean equals(Object obj) { if (this == obj) return true; @@ -89,14 +82,12 @@ public class SimpleRedisSerializerTests { if (a == null) { if (other.a != null) return false; - } - else if (!a.equals(other.a)) + } else if (!a.equals(other.a)) return false; if (name == null) { if (other.name != null) return false; - } - else if (!name.equals(other.name)) + } else if (!name.equals(other.name)) return false; return true; } @@ -164,4 +155,5 @@ public class SimpleRedisSerializerTests { assertEquals(p1, serializer.deserialize(serializer.serialize(p1))); assertEquals(p1, serializer.deserialize(serializer.serialize(p1))); } -} \ No newline at end of file + +} diff --git a/src/test/java/org/springframework/data/redis/support/collections/CollectionTestParams.java b/src/test/java/org/springframework/data/redis/support/collections/CollectionTestParams.java index 7e88347ae..c0d844091 100644 --- a/src/test/java/org/springframework/data/redis/support/collections/CollectionTestParams.java +++ b/src/test/java/org/springframework/data/redis/support/collections/CollectionTestParams.java @@ -1,5 +1,5 @@ /* - * Copyright 2011-2013 the original author or authors. + * Copyright 2011-2014 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,6 +31,7 @@ import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactor import org.springframework.data.redis.connection.srp.SrpConnectionFactory; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.core.StringRedisTemplate; +import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer; import org.springframework.data.redis.serializer.JacksonJsonRedisSerializer; import org.springframework.data.redis.serializer.OxmSerializer; import org.springframework.data.redis.serializer.StringRedisSerializer; @@ -38,6 +39,7 @@ import org.springframework.oxm.xstream.XStreamMarshaller; /** * @author Costin Leau + * @author Thomas Darimont */ public abstract class CollectionTestParams { @@ -51,6 +53,7 @@ public abstract class CollectionTestParams { } OxmSerializer serializer = new OxmSerializer(xstream, xstream); JacksonJsonRedisSerializer jsonSerializer = new JacksonJsonRedisSerializer(Person.class); + Jackson2JsonRedisSerializer jackson2JsonSerializer = new Jackson2JsonRedisSerializer(Person.class); StringRedisSerializer stringSerializer = new StringRedisSerializer(); // create Jedis Factory @@ -87,15 +90,21 @@ public abstract class CollectionTestParams { jsonPersonTemplate.setValueSerializer(jsonSerializer); jsonPersonTemplate.afterPropertiesSet(); - RedisTemplate rawTemplate = new RedisTemplate(); + // jackson2 + RedisTemplate jackson2JsonPersonTemplate = new RedisTemplate(); + jackson2JsonPersonTemplate.setConnectionFactory(jedisConnFactory); + jackson2JsonPersonTemplate.setValueSerializer(jackson2JsonSerializer); + jackson2JsonPersonTemplate.afterPropertiesSet(); + + RedisTemplate rawTemplate = new RedisTemplate(); rawTemplate.setConnectionFactory(jedisConnFactory); rawTemplate.setEnableDefaultSerializer(false); rawTemplate.setKeySerializer(stringSerializer); rawTemplate.afterPropertiesSet(); // jredis - JredisConnectionFactory jredisConnFactory = new JredisConnectionFactory(new JredisPool( - SettingsUtils.getHost(), SettingsUtils.getPort())); + JredisConnectionFactory jredisConnFactory = new JredisConnectionFactory(new JredisPool(SettingsUtils.getHost(), + SettingsUtils.getPort())); jredisConnFactory.afterPropertiesSet(); RedisTemplate stringTemplateJR = new StringRedisTemplate(jredisConnFactory); @@ -118,7 +127,12 @@ public abstract class CollectionTestParams { jsonPersonTemplateJR.setConnectionFactory(jredisConnFactory); jsonPersonTemplateJR.afterPropertiesSet(); - RedisTemplate rawTemplateJR = new RedisTemplate(); + RedisTemplate jackson2JsonPersonTemplateJR = new RedisTemplate(); + jackson2JsonPersonTemplateJR.setValueSerializer(jackson2JsonSerializer); + jackson2JsonPersonTemplateJR.setConnectionFactory(jredisConnFactory); + jackson2JsonPersonTemplateJR.afterPropertiesSet(); + + RedisTemplate rawTemplateJR = new RedisTemplate(); rawTemplateJR.setConnectionFactory(jredisConnFactory); rawTemplateJR.setEnableDefaultSerializer(false); rawTemplateJR.setKeySerializer(stringSerializer); @@ -150,7 +164,12 @@ public abstract class CollectionTestParams { jsonPersonTemplateSRP.setConnectionFactory(srConnFactory); jsonPersonTemplateSRP.afterPropertiesSet(); - RedisTemplate rawTemplateSRP = new RedisTemplate(); + RedisTemplate jackson2JsonPersonTemplateSRP = new RedisTemplate(); + jackson2JsonPersonTemplateSRP.setValueSerializer(jackson2JsonSerializer); + jackson2JsonPersonTemplateSRP.setConnectionFactory(srConnFactory); + jackson2JsonPersonTemplateSRP.afterPropertiesSet(); + + RedisTemplate rawTemplateSRP = new RedisTemplate(); rawTemplateSRP.setConnectionFactory(srConnFactory); rawTemplateSRP.setEnableDefaultSerializer(false); rawTemplateSRP.setKeySerializer(stringSerializer); @@ -182,30 +201,44 @@ public abstract class CollectionTestParams { jsonPersonTemplateLtc.setConnectionFactory(lettuceConnFactory); jsonPersonTemplateLtc.afterPropertiesSet(); - RedisTemplate rawTemplateLtc = new RedisTemplate(); + RedisTemplate jackson2JsonPersonTemplateLtc = new RedisTemplate(); + jackson2JsonPersonTemplateLtc.setValueSerializer(jackson2JsonSerializer); + jackson2JsonPersonTemplateLtc.setConnectionFactory(lettuceConnFactory); + jackson2JsonPersonTemplateLtc.afterPropertiesSet(); + + RedisTemplate rawTemplateLtc = new RedisTemplate(); rawTemplateLtc.setConnectionFactory(lettuceConnFactory); rawTemplateLtc.setEnableDefaultSerializer(false); rawTemplateLtc.setKeySerializer(stringSerializer); rawTemplateLtc.afterPropertiesSet(); - return Arrays.asList(new Object[][] { { stringFactory, stringTemplate }, + return Arrays.asList(new Object[][] { + { stringFactory, stringTemplate }, { personFactory, personTemplate }, - { stringFactory, xstreamStringTemplate }, { personFactory, xstreamPersonTemplate }, - { personFactory, jsonPersonTemplate }, {rawFactory, rawTemplate}, + { stringFactory, xstreamStringTemplate }, + { personFactory, xstreamPersonTemplate }, + { personFactory, jsonPersonTemplate }, + { personFactory, jackson2JsonPersonTemplate }, + { rawFactory, rawTemplate }, // Jredis { stringFactory, stringTemplateJR }, { personFactory, personTemplateJR }, { stringFactory, xstreamStringTemplateJR }, { personFactory, xstreamPersonTemplateJR }, - { personFactory, jsonPersonTemplateJR }, {rawFactory, rawTemplateJR}, + { personFactory, jsonPersonTemplateJR }, + { personFactory, jackson2JsonPersonTemplateJR }, + { rawFactory, rawTemplateJR }, // srp - { stringFactory, stringTemplateSRP },{ personFactory, personTemplateSRP }, - { stringFactory, xstreamStringTemplateSRP }, { personFactory, xstreamPersonTemplateSRP }, - { personFactory, jsonPersonTemplateSRP }, {rawFactory, rawTemplateSRP}, + { stringFactory, stringTemplateSRP }, { personFactory, personTemplateSRP }, + { stringFactory, xstreamStringTemplateSRP }, + { personFactory, xstreamPersonTemplateSRP }, + { personFactory, jsonPersonTemplateSRP }, + { personFactory, jackson2JsonPersonTemplateSRP }, + { rawFactory, rawTemplateSRP }, // lettuce { stringFactory, stringTemplateLtc }, { personFactory, personTemplateLtc }, { stringFactory, xstreamStringTemplateLtc }, { personFactory, xstreamPersonTemplateLtc }, - { personFactory, jsonPersonTemplateLtc }, {rawFactory, rawTemplateLtc} - }); + { personFactory, jsonPersonTemplateLtc }, { personFactory, jackson2JsonPersonTemplateLtc }, + { rawFactory, rawTemplateLtc } }); } } diff --git a/src/test/java/org/springframework/data/redis/support/collections/RedisMapTests.java b/src/test/java/org/springframework/data/redis/support/collections/RedisMapTests.java index e57130e87..37901f138 100644 --- a/src/test/java/org/springframework/data/redis/support/collections/RedisMapTests.java +++ b/src/test/java/org/springframework/data/redis/support/collections/RedisMapTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2011-2013 the original author or authors. + * Copyright 2011-2014 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. @@ -27,13 +27,15 @@ import org.springframework.data.redis.PersonObjectFactory; import org.springframework.data.redis.RawObjectFactory; import org.springframework.data.redis.SettingsUtils; import org.springframework.data.redis.StringObjectFactory; +import org.springframework.data.redis.connection.PoolConfig; import org.springframework.data.redis.connection.jedis.JedisConnectionFactory; -import org.springframework.data.redis.connection.jredis.JredisPool; import org.springframework.data.redis.connection.jredis.JredisConnectionFactory; +import org.springframework.data.redis.connection.jredis.JredisPool; import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory; import org.springframework.data.redis.connection.srp.SrpConnectionFactory; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.core.StringRedisTemplate; +import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer; import org.springframework.data.redis.serializer.JacksonJsonRedisSerializer; import org.springframework.data.redis.serializer.OxmSerializer; import org.springframework.data.redis.serializer.StringRedisSerializer; @@ -44,6 +46,7 @@ import org.springframework.oxm.xstream.XStreamMarshaller; * * @author Costin Leau * @author Jennifer Hickey + * @author Thomas Darimont */ public class RedisMapTests extends AbstractRedisMapTests { @@ -52,16 +55,19 @@ public class RedisMapTests extends AbstractRedisMapTests { super(keyFactory, valueFactory, template); } - @SuppressWarnings("unchecked") RedisMap createMap() { String redisName = getClass().getSimpleName(); return new DefaultRedisMap(redisName, template); } + /** + * @see DATAREDIS-241 + */ @SuppressWarnings("rawtypes") @Parameters public static Collection testParams() { + // XStream serializer XStreamMarshaller xstream = new XStreamMarshaller(); try { @@ -72,8 +78,14 @@ public class RedisMapTests extends AbstractRedisMapTests { OxmSerializer serializer = new OxmSerializer(xstream, xstream); JacksonJsonRedisSerializer jsonSerializer = new JacksonJsonRedisSerializer(Person.class); JacksonJsonRedisSerializer jsonStringSerializer = new JacksonJsonRedisSerializer(String.class); + Jackson2JsonRedisSerializer jackson2JsonSerializer = new Jackson2JsonRedisSerializer(Person.class); + Jackson2JsonRedisSerializer jackson2JsonStringSerializer = new Jackson2JsonRedisSerializer( + String.class); StringRedisSerializer stringSerializer = new StringRedisSerializer(); + PoolConfig defaultPoolConfig = new PoolConfig(); + defaultPoolConfig.setMaxActive(1000); + // create Jedis Factory ObjectFactory stringFactory = new StringObjectFactory(); ObjectFactory personFactory = new PersonObjectFactory(); @@ -82,6 +94,7 @@ public class RedisMapTests extends AbstractRedisMapTests { ObjectFactory rawFactory = new RawObjectFactory(); JedisConnectionFactory jedisConnFactory = new JedisConnectionFactory(); + jedisConnFactory.getPoolConfig().setMaxActive(defaultPoolConfig.maxActive); jedisConnFactory.setUsePool(true); jedisConnFactory.setPort(SettingsUtils.getPort()); jedisConnFactory.setHostName(SettingsUtils.getHost()); @@ -103,6 +116,13 @@ public class RedisMapTests extends AbstractRedisMapTests { jsonPersonTemplate.setHashValueSerializer(jsonStringSerializer); jsonPersonTemplate.afterPropertiesSet(); + RedisTemplate jackson2JsonPersonTemplate = new RedisTemplate(); + jackson2JsonPersonTemplate.setConnectionFactory(jedisConnFactory); + jackson2JsonPersonTemplate.setDefaultSerializer(jackson2JsonSerializer); + jackson2JsonPersonTemplate.setHashKeySerializer(jackson2JsonSerializer); + jackson2JsonPersonTemplate.setHashValueSerializer(jackson2JsonStringSerializer); + jackson2JsonPersonTemplate.afterPropertiesSet(); + RedisTemplate rawTemplate = new RedisTemplate(); rawTemplate.setEnableDefaultSerializer(false); rawTemplate.setConnectionFactory(jedisConnFactory); @@ -110,8 +130,8 @@ public class RedisMapTests extends AbstractRedisMapTests { rawTemplate.afterPropertiesSet(); // JRedis - JredisConnectionFactory jredisConnFactory = new JredisConnectionFactory(new JredisPool( - SettingsUtils.getHost(), SettingsUtils.getPort())); + JredisConnectionFactory jredisConnFactory = new JredisConnectionFactory(new JredisPool(SettingsUtils.getHost(), + SettingsUtils.getPort(), defaultPoolConfig)); jredisConnFactory.afterPropertiesSet(); RedisTemplate genericTemplateJR = new RedisTemplate(); @@ -130,6 +150,13 @@ public class RedisMapTests extends AbstractRedisMapTests { jsonPersonTemplateJR.setHashValueSerializer(jsonStringSerializer); jsonPersonTemplateJR.afterPropertiesSet(); + RedisTemplate jackson2JsonPersonTemplateJR = new RedisTemplate(); + jackson2JsonPersonTemplateJR.setConnectionFactory(jredisConnFactory); + jackson2JsonPersonTemplateJR.setDefaultSerializer(jackson2JsonSerializer); + jackson2JsonPersonTemplateJR.setHashKeySerializer(jackson2JsonSerializer); + jackson2JsonPersonTemplateJR.setHashValueSerializer(jackson2JsonStringSerializer); + jackson2JsonPersonTemplateJR.afterPropertiesSet(); + RedisTemplate rawTemplateJR = new RedisTemplate(); rawTemplateJR.setEnableDefaultSerializer(false); rawTemplateJR.setConnectionFactory(jredisConnFactory); @@ -138,8 +165,8 @@ public class RedisMapTests extends AbstractRedisMapTests { // Lettuce LettuceConnectionFactory lettuceConnFactory = new LettuceConnectionFactory(); - lettuceConnFactory.setPort(SettingsUtils.getPort()); lettuceConnFactory.setHostName(SettingsUtils.getHost()); + lettuceConnFactory.setPort(SettingsUtils.getPort()); lettuceConnFactory.afterPropertiesSet(); RedisTemplate genericTemplateLettuce = new RedisTemplate(); @@ -158,6 +185,13 @@ public class RedisMapTests extends AbstractRedisMapTests { jsonPersonTemplateLettuce.setHashValueSerializer(jsonStringSerializer); jsonPersonTemplateLettuce.afterPropertiesSet(); + RedisTemplate jackson2JsonPersonTemplateLettuce = new RedisTemplate(); + jackson2JsonPersonTemplateLettuce.setConnectionFactory(lettuceConnFactory); + jackson2JsonPersonTemplateLettuce.setDefaultSerializer(jackson2JsonSerializer); + jackson2JsonPersonTemplateLettuce.setHashKeySerializer(jackson2JsonSerializer); + jackson2JsonPersonTemplateLettuce.setHashValueSerializer(jackson2JsonStringSerializer); + jackson2JsonPersonTemplateLettuce.afterPropertiesSet(); + RedisTemplate stringTemplateLtc = new StringRedisTemplate(); stringTemplateLtc.setConnectionFactory(lettuceConnFactory); stringTemplateLtc.afterPropertiesSet(); @@ -190,6 +224,13 @@ public class RedisMapTests extends AbstractRedisMapTests { jsonPersonTemplateSrp.setHashValueSerializer(jsonStringSerializer); jsonPersonTemplateSrp.afterPropertiesSet(); + RedisTemplate jackson2JsonPersonTemplateSrp = new RedisTemplate(); + jackson2JsonPersonTemplateSrp.setConnectionFactory(srpConnFactory); + jackson2JsonPersonTemplateSrp.setDefaultSerializer(jackson2JsonSerializer); + jackson2JsonPersonTemplateSrp.setHashKeySerializer(jackson2JsonSerializer); + jackson2JsonPersonTemplateSrp.setHashValueSerializer(jackson2JsonStringSerializer); + jackson2JsonPersonTemplateSrp.afterPropertiesSet(); + RedisTemplate stringTemplateSrp = new StringRedisTemplate(); stringTemplateSrp.setConnectionFactory(srpConnFactory); stringTemplateSrp.afterPropertiesSet(); @@ -200,39 +241,28 @@ public class RedisMapTests extends AbstractRedisMapTests { rawTemplateSrp.setKeySerializer(stringSerializer); rawTemplateSrp.afterPropertiesSet(); - - return Arrays.asList(new Object[][] { - { stringFactory, stringFactory, genericTemplate }, - { personFactory, personFactory, genericTemplate }, - { stringFactory, personFactory, genericTemplate }, - { personFactory, stringFactory, genericTemplate }, - { personFactory, stringFactory, xstreamGenericTemplate }, + return Arrays.asList(new Object[][] { { stringFactory, stringFactory, genericTemplate }, + { personFactory, personFactory, genericTemplate }, { stringFactory, personFactory, genericTemplate }, + { personFactory, stringFactory, genericTemplate }, { personFactory, stringFactory, xstreamGenericTemplate }, { personFactory, stringFactory, jsonPersonTemplate }, - { rawFactory, rawFactory, rawTemplate}, - { stringFactory, stringFactory, genericTemplateJR }, - { personFactory, personFactory, genericTemplateJR }, - { stringFactory, personFactory, genericTemplateJR }, - { personFactory, stringFactory, genericTemplateJR }, - { personFactory, stringFactory, xGenericTemplateJR }, - { personFactory, stringFactory, jsonPersonTemplateJR }, - { rawFactory, rawFactory, rawTemplateJR}, + { personFactory, stringFactory, jackson2JsonPersonTemplate }, { rawFactory, rawFactory, rawTemplate }, + { stringFactory, stringFactory, genericTemplateJR }, { personFactory, personFactory, genericTemplateJR }, + { stringFactory, personFactory, genericTemplateJR }, { personFactory, stringFactory, genericTemplateJR }, + { personFactory, stringFactory, xGenericTemplateJR }, { personFactory, stringFactory, jsonPersonTemplateJR }, + { personFactory, stringFactory, jackson2JsonPersonTemplateJR }, { rawFactory, rawFactory, rawTemplateJR }, { stringFactory, stringFactory, genericTemplateLettuce }, { personFactory, personFactory, genericTemplateLettuce }, { stringFactory, personFactory, genericTemplateLettuce }, { personFactory, stringFactory, genericTemplateLettuce }, { personFactory, stringFactory, xGenericTemplateLettuce }, { personFactory, stringFactory, jsonPersonTemplateLettuce }, - { stringFactory, doubleFactory, stringTemplateLtc}, - { stringFactory, longFactory, stringTemplateLtc}, - { rawFactory, rawFactory, rawTemplateLtc}, - { stringFactory, stringFactory, genericTemplateSrp }, - { personFactory, personFactory, genericTemplateSrp }, - { stringFactory, personFactory, genericTemplateSrp }, - { personFactory, stringFactory, genericTemplateSrp }, - { personFactory, stringFactory, xGenericTemplateSrp }, - { stringFactory, doubleFactory, stringTemplateSrp}, - { stringFactory, longFactory, stringTemplateSrp}, + { personFactory, stringFactory, jackson2JsonPersonTemplateLettuce }, + { stringFactory, doubleFactory, stringTemplateLtc }, { stringFactory, longFactory, stringTemplateLtc }, + { rawFactory, rawFactory, rawTemplateLtc }, { stringFactory, stringFactory, genericTemplateSrp }, + { personFactory, personFactory, genericTemplateSrp }, { stringFactory, personFactory, genericTemplateSrp }, + { personFactory, stringFactory, genericTemplateSrp }, { personFactory, stringFactory, xGenericTemplateSrp }, + { stringFactory, doubleFactory, stringTemplateSrp }, { stringFactory, longFactory, stringTemplateSrp }, { personFactory, stringFactory, jsonPersonTemplateSrp }, - { rawFactory, rawFactory, rawTemplateSrp}}); + { personFactory, stringFactory, jackson2JsonPersonTemplateSrp }, { rawFactory, rawFactory, rawTemplateSrp } }); } -} \ No newline at end of file +} diff --git a/src/test/java/org/springframework/data/redis/support/collections/RedisPropertiesTests.java b/src/test/java/org/springframework/data/redis/support/collections/RedisPropertiesTests.java index 091a1f713..64ab31322 100644 --- a/src/test/java/org/springframework/data/redis/support/collections/RedisPropertiesTests.java +++ b/src/test/java/org/springframework/data/redis/support/collections/RedisPropertiesTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2011-2013 the original author or authors. + * Copyright 2011-2014 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. @@ -15,11 +15,7 @@ */ package org.springframework.data.redis.support.collections; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; +import static org.junit.Assert.*; import java.io.ByteArrayOutputStream; import java.io.InputStream; @@ -42,18 +38,20 @@ import org.springframework.data.redis.Person; import org.springframework.data.redis.SettingsUtils; import org.springframework.data.redis.StringObjectFactory; import org.springframework.data.redis.connection.jedis.JedisConnectionFactory; -import org.springframework.data.redis.connection.jredis.JredisPool; import org.springframework.data.redis.connection.jredis.JredisConnectionFactory; +import org.springframework.data.redis.connection.jredis.JredisPool; import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory; import org.springframework.data.redis.connection.srp.SrpConnectionFactory; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.core.StringRedisTemplate; +import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer; import org.springframework.data.redis.serializer.JacksonJsonRedisSerializer; import org.springframework.data.redis.serializer.OxmSerializer; import org.springframework.oxm.xstream.XStreamMarshaller; /** * @author Costin Leau + * @author Thomas Darimont */ public class RedisPropertiesTests extends RedisMapTests { @@ -62,7 +60,7 @@ public class RedisPropertiesTests extends RedisMapTests { /** * Constructs a new RedisPropertiesTests instance. - * + * * @param keyFactory * @param valueFactory * @param template @@ -72,14 +70,12 @@ public class RedisPropertiesTests extends RedisMapTests { super(keyFactory, valueFactory, template); } - RedisMap createMap() { String redisName = getClass().getSimpleName(); props = new RedisProperties(defaults, redisName, new StringRedisTemplate(template.getConnectionFactory())); return props; } - protected RedisStore copyStore(RedisStore store) { return new RedisProperties(store.getKey(), store.getOperations()); } @@ -139,7 +135,6 @@ public class RedisPropertiesTests extends RedisMapTests { StringWriter writer = new StringWriter(); props.store(writer, "no-comment"); - //System.out.println(writer.toString()); } @Test @@ -225,8 +220,12 @@ public class RedisPropertiesTests extends RedisMapTests { assertTrue(keys.contains(key3)); } + /** + * @see DATAREDIS-241 + */ @Parameters public static Collection testParams() { + // XStream serializer XStreamMarshaller xstream = new XStreamMarshaller(); try { @@ -237,6 +236,9 @@ public class RedisPropertiesTests extends RedisMapTests { OxmSerializer serializer = new OxmSerializer(xstream, xstream); JacksonJsonRedisSerializer jsonSerializer = new JacksonJsonRedisSerializer(Person.class); JacksonJsonRedisSerializer jsonStringSerializer = new JacksonJsonRedisSerializer(String.class); + Jackson2JsonRedisSerializer jackson2JsonSerializer = new Jackson2JsonRedisSerializer(Person.class); + Jackson2JsonRedisSerializer jackson2JsonStringSerializer = new Jackson2JsonRedisSerializer( + String.class); // create Jedis Factory ObjectFactory stringFactory = new StringObjectFactory(); @@ -265,9 +267,16 @@ public class RedisPropertiesTests extends RedisMapTests { jsonPersonTemplate.setHashValueSerializer(jsonStringSerializer); jsonPersonTemplate.afterPropertiesSet(); + RedisTemplate jackson2JsonPersonTemplate = new RedisTemplate(); + jackson2JsonPersonTemplate.setConnectionFactory(jedisConnFactory); + jackson2JsonPersonTemplate.setDefaultSerializer(jackson2JsonSerializer); + jackson2JsonPersonTemplate.setHashKeySerializer(jackson2JsonSerializer); + jackson2JsonPersonTemplate.setHashValueSerializer(jackson2JsonStringSerializer); + jackson2JsonPersonTemplate.afterPropertiesSet(); + // JRedis - JredisConnectionFactory jredisConnFactory = new JredisConnectionFactory(new JredisPool( - SettingsUtils.getHost(), SettingsUtils.getPort())); + JredisConnectionFactory jredisConnFactory = new JredisConnectionFactory(new JredisPool(SettingsUtils.getHost(), + SettingsUtils.getPort())); jredisConnFactory.afterPropertiesSet(); RedisTemplate genericTemplateJR = new StringRedisTemplate(jredisConnFactory); @@ -283,6 +292,12 @@ public class RedisPropertiesTests extends RedisMapTests { jsonPersonTemplateJR.setHashValueSerializer(jsonStringSerializer); jsonPersonTemplateJR.afterPropertiesSet(); + RedisTemplate jackson2JsonPersonTemplateJR = new RedisTemplate(); + jackson2JsonPersonTemplateJR.setConnectionFactory(jredisConnFactory); + jackson2JsonPersonTemplateJR.setDefaultSerializer(jackson2JsonSerializer); + jackson2JsonPersonTemplateJR.setHashKeySerializer(jackson2JsonSerializer); + jackson2JsonPersonTemplateJR.setHashValueSerializer(jackson2JsonStringSerializer); + jackson2JsonPersonTemplateJR.afterPropertiesSet(); // Lettuce LettuceConnectionFactory lettuceConnFactory = new LettuceConnectionFactory(); @@ -303,6 +318,13 @@ public class RedisPropertiesTests extends RedisMapTests { jsonPersonTemplateLtc.setHashValueSerializer(jsonStringSerializer); jsonPersonTemplateLtc.afterPropertiesSet(); + RedisTemplate jackson2JsonPersonTemplateLtc = new RedisTemplate(); + jackson2JsonPersonTemplateLtc.setConnectionFactory(lettuceConnFactory); + jackson2JsonPersonTemplateLtc.setDefaultSerializer(jackson2JsonSerializer); + jackson2JsonPersonTemplateLtc.setHashKeySerializer(jackson2JsonSerializer); + jackson2JsonPersonTemplateLtc.setHashValueSerializer(jackson2JsonStringSerializer); + jackson2JsonPersonTemplateLtc.afterPropertiesSet(); + // SRP SrpConnectionFactory srpConnFactory = new SrpConnectionFactory(); srpConnFactory.setPort(SettingsUtils.getPort()); @@ -322,34 +344,31 @@ public class RedisPropertiesTests extends RedisMapTests { jsonPersonTemplateSrp.setHashValueSerializer(jsonStringSerializer); jsonPersonTemplateSrp.afterPropertiesSet(); + RedisTemplate jackson2JsonPersonTemplateSrp = new RedisTemplate(); + jackson2JsonPersonTemplateSrp.setConnectionFactory(srpConnFactory); + jackson2JsonPersonTemplateSrp.setDefaultSerializer(jackson2JsonSerializer); + jackson2JsonPersonTemplateSrp.setHashKeySerializer(jackson2JsonSerializer); + jackson2JsonPersonTemplateSrp.setHashValueSerializer(jackson2JsonStringSerializer); + jackson2JsonPersonTemplateSrp.afterPropertiesSet(); return Arrays.asList(new Object[][] { { stringFactory, stringFactory, genericTemplate }, - { stringFactory, stringFactory, genericTemplate }, - { stringFactory, stringFactory, genericTemplate }, - { stringFactory, stringFactory, genericTemplate }, - { stringFactory, stringFactory, xstreamGenericTemplate }, - { stringFactory, stringFactory, genericTemplateJR }, - { stringFactory, stringFactory, genericTemplateJR }, - { stringFactory, stringFactory, genericTemplateJR }, - { stringFactory, stringFactory, genericTemplateJR }, - { stringFactory, stringFactory, xGenericTemplateJR }, - { stringFactory, stringFactory, jsonPersonTemplate }, + { stringFactory, stringFactory, genericTemplate }, { stringFactory, stringFactory, genericTemplate }, + { stringFactory, stringFactory, genericTemplate }, { stringFactory, stringFactory, xstreamGenericTemplate }, + { stringFactory, stringFactory, genericTemplateJR }, { stringFactory, stringFactory, genericTemplateJR }, + { stringFactory, stringFactory, genericTemplateJR }, { stringFactory, stringFactory, genericTemplateJR }, + { stringFactory, stringFactory, xGenericTemplateJR }, { stringFactory, stringFactory, jsonPersonTemplate }, + { stringFactory, stringFactory, jackson2JsonPersonTemplate }, { stringFactory, stringFactory, jsonPersonTemplateJR }, - { stringFactory, stringFactory, genericTemplateLtc }, - { stringFactory, stringFactory, genericTemplateLtc }, - { stringFactory, stringFactory, genericTemplateLtc }, - { stringFactory, stringFactory, genericTemplateLtc }, - { stringFactory, doubleFactory, genericTemplateLtc }, - { stringFactory, longFactory, genericTemplateLtc }, - { stringFactory, stringFactory, xGenericTemplateLtc }, - { stringFactory, stringFactory, jsonPersonTemplateLtc }, - { stringFactory, stringFactory, genericTemplateSrp }, - { stringFactory, stringFactory, genericTemplateSrp }, - { stringFactory, stringFactory, genericTemplateSrp }, - { stringFactory, stringFactory, genericTemplateSrp }, - { stringFactory, doubleFactory, genericTemplateSrp }, - { stringFactory, longFactory, genericTemplateSrp }, - { stringFactory, stringFactory, xGenericTemplateSrp }, - { stringFactory, stringFactory, jsonPersonTemplateSrp }}); + { stringFactory, stringFactory, jackson2JsonPersonTemplateJR }, + { stringFactory, stringFactory, genericTemplateLtc }, { stringFactory, stringFactory, genericTemplateLtc }, + { stringFactory, stringFactory, genericTemplateLtc }, { stringFactory, stringFactory, genericTemplateLtc }, + { stringFactory, doubleFactory, genericTemplateLtc }, { stringFactory, longFactory, genericTemplateLtc }, + { stringFactory, stringFactory, xGenericTemplateLtc }, { stringFactory, stringFactory, jsonPersonTemplateLtc }, + { stringFactory, stringFactory, jackson2JsonPersonTemplateLtc }, + { stringFactory, stringFactory, genericTemplateSrp }, { stringFactory, stringFactory, genericTemplateSrp }, + { stringFactory, stringFactory, genericTemplateSrp }, { stringFactory, stringFactory, genericTemplateSrp }, + { stringFactory, doubleFactory, genericTemplateSrp }, { stringFactory, longFactory, genericTemplateSrp }, + { stringFactory, stringFactory, xGenericTemplateSrp }, { stringFactory, stringFactory, jsonPersonTemplateSrp }, + { stringFactory, stringFactory, jackson2JsonPersonTemplateSrp } }); } -} \ No newline at end of file +} diff --git a/template.mf b/template.mf index 6ac1ae4d8..ae1f23753 100644 --- a/template.mf +++ b/template.mf @@ -23,6 +23,7 @@ Import-Template: redis.clients.*;resolution:="optional";version="[2.1.0, 2.1.0]", org.apache.commons.pool.*;resolution:="optional";version="[1.0.0, 3.0.0)", org.codehaus.jackson.*;resolution:="optional";version="[1.6, 2.0.0)", + com.fasterxml.jackson.*;resolution:="optional";version="[2.0.0, 3.0.0)", org.apache.commons.beanutils.*;resolution:="optional";version=1.8.5, redis.*;resolution:="optional";version="[0.2, 1.0)", com.google.common.*;resolution:="optional";version="[11.0.0, 20.0.0)",