+ * 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
+ * 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