DATAREDIS-253 - Avoid usage of deprecated API.

Changed usage of TypeFactory to the recommended API.
This commit is contained in:
Thomas Darimont
2014-01-16 10:39:52 +01:00
parent b5137e6dd4
commit 168713aae1
5 changed files with 40 additions and 36 deletions

View File

@@ -16,6 +16,23 @@
package org.springframework.data.redis.connection.srp;
import com.google.common.base.Charsets;
import org.springframework.dao.DataAccessException;
import org.springframework.data.redis.RedisSystemException;
import org.springframework.data.redis.connection.DefaultTuple;
import org.springframework.data.redis.connection.RedisListCommands.Position;
import org.springframework.data.redis.connection.RedisStringCommands.BitOperation;
import org.springframework.data.redis.connection.RedisZSetCommands.Tuple;
import org.springframework.data.redis.connection.ReturnType;
import org.springframework.data.redis.connection.SortParameters;
import org.springframework.util.Assert;
import redis.client.RedisException;
import redis.reply.BulkReply;
import redis.reply.IntegerReply;
import redis.reply.MultiBulkReply;
import redis.reply.Reply;
import redis.reply.StatusReply;
import java.io.StringReader;
import java.util.ArrayList;
import java.util.Arrays;
@@ -26,26 +43,6 @@ import java.util.Map;
import java.util.Properties;
import java.util.Set;
import org.springframework.dao.DataAccessException;
import org.springframework.data.redis.RedisSystemException;
import org.springframework.data.redis.connection.DefaultTuple;
import org.springframework.data.redis.connection.ReturnType;
import org.springframework.data.redis.connection.RedisListCommands.Position;
import org.springframework.data.redis.connection.RedisStringCommands.BitOperation;
import org.springframework.data.redis.connection.RedisZSetCommands.Tuple;
import org.springframework.data.redis.connection.jedis.JedisUtils;
import org.springframework.data.redis.connection.SortParameters;
import org.springframework.util.Assert;
import redis.client.RedisException;
import redis.reply.BulkReply;
import redis.reply.IntegerReply;
import redis.reply.MultiBulkReply;
import redis.reply.Reply;
import redis.reply.StatusReply;
import com.google.common.base.Charsets;
/**
* Helper class featuring methods for SRedis connection handling, providing support for exception translation.
*

View File

@@ -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,22 +15,23 @@
*/
package org.springframework.data.redis.hash;
import java.util.Map;
import org.codehaus.jackson.map.ObjectMapper;
import org.codehaus.jackson.map.type.TypeFactory;
import org.codehaus.jackson.type.JavaType;
import java.util.Map;
/**
* Mapper based on Jackson library. Supports nested properties (rich objects).
*
* @author Costin Leau
* @author Thomas Darimont
*/
public class JacksonHashMapper<T> implements HashMapper<T, String, Object> {
private final ObjectMapper mapper;
private final JavaType userType;
private final JavaType mapType = TypeFactory.mapType(Map.class, String.class, Object.class);
private final JavaType mapType = TypeFactory.defaultInstance().constructMapType(Map.class, String.class, Object.class);
public JacksonHashMapper(Class<T> type) {
this(type, new ObjectMapper());
@@ -38,7 +39,7 @@ public class JacksonHashMapper<T> implements HashMapper<T, String, Object> {
public JacksonHashMapper(Class<T> type, ObjectMapper mapper) {
this.mapper = mapper;
this.userType = TypeFactory.type(type);
this.userType = TypeFactory.defaultInstance().constructType(type);
}
@SuppressWarnings("unchecked")

View File

@@ -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,13 +15,13 @@
*/
package org.springframework.data.redis.serializer;
import java.nio.charset.Charset;
import org.codehaus.jackson.map.ObjectMapper;
import org.codehaus.jackson.map.type.TypeFactory;
import org.codehaus.jackson.type.JavaType;
import org.springframework.util.Assert;
import java.nio.charset.Charset;
/**
* {@link RedisSerializer} that can read and write JSON using <a href="http://jackson.codehaus.org/">Jackson's</a> {@link ObjectMapper}.
*
@@ -30,6 +30,7 @@ import org.springframework.util.Assert;
* <b>Note:</b>Null objects are serialized as empty arrays and vice versa.
*
* @author Costin Leau
* @author Thomas Darimont
*/
public class JacksonJsonRedisSerializer<T> implements RedisSerializer<T> {
@@ -40,7 +41,7 @@ public class JacksonJsonRedisSerializer<T> implements RedisSerializer<T> {
private ObjectMapper objectMapper = new ObjectMapper();
public JacksonJsonRedisSerializer(Class<T> type) {
this.javaType = TypeFactory.type(type);
this.javaType = TypeFactory.defaultInstance().constructType(type);
}
@SuppressWarnings("unchecked")
@@ -100,6 +101,6 @@ public class JacksonJsonRedisSerializer<T> implements RedisSerializer<T> {
* @return the java type
*/
protected JavaType getJavaType(Class<?> clazz) {
return TypeFactory.type(clazz);
return TypeFactory.defaultInstance().constructType(clazz);
}
}