Deprecate connection Utils in favor of Converters

DATAREDIS-200
This commit is contained in:
Jennifer Hickey
2013-07-16 10:44:32 -07:00
parent daca61be03
commit 470dd4654d
7 changed files with 50 additions and 6 deletions

View File

@@ -153,7 +153,7 @@ public class JedisConnectionFactory implements InitializingBean, DisposableBean,
public DataAccessException translateExceptionIfPossible(RuntimeException ex) {
return JedisUtils.convertJedisAccessException(ex);
return JedisConverters.toDataAccessException(ex);
}
/**

View File

@@ -52,11 +52,14 @@ import redis.clients.jedis.exceptions.JedisException;
import redis.clients.util.SafeEncoder;
/**
* Helper class featuring methods for Jedis connection handling, providing support for exception translation.
* Helper class featuring methods for Jedis connection handling, providing support for exception translation.
*
* Deprecated in favor of {@link JedisConverters}
*
* @author Costin Leau
* @author Jennifer Hickey
*/
@Deprecated
public abstract class JedisUtils {
private static final String OK_CODE = "OK";
@@ -111,10 +114,18 @@ public abstract class JedisUtils {
return status != null && (OK_CODE.equals(status) || OK_MULTI_CODE.equals(status));
}
/**
* Deprecated. Use #{@link JedisConverters#toBoolean(Long)}
*/
@Deprecated
static Boolean convertCodeReply(Number code) {
return (code != null ? code.intValue() == 1 : null);
}
/**
* Deprecated. Use #{@link JedisConverters#toTupleSet(Set)}
*/
@Deprecated
static Set<Tuple> convertJedisTuple(Set<redis.clients.jedis.Tuple> tuples) {
Set<Tuple> value = new LinkedHashSet<Tuple>(tuples.size());
for (redis.clients.jedis.Tuple tuple : tuples) {
@@ -135,6 +146,10 @@ public abstract class JedisUtils {
return result;
}
/**
* Deprecated. Implement a method in {@link JedisConverters} instead
*/
@Deprecated
static Map<String, String> convert(String[] fields, String[] values) {
Map<String, String> result = new LinkedHashMap<String, String>(fields.length);
@@ -144,6 +159,10 @@ public abstract class JedisUtils {
return result;
}
/**
* Deprecated. Implement a method in {@link JedisConverters} instead
*/
@Deprecated
static String[] arrange(String[] keys, String[] values) {
String[] result = new String[keys.length * 2];
@@ -189,6 +208,10 @@ public abstract class JedisUtils {
return jedisParams;
}
/**
* Deprecated. Use #{@link JedisConverters#toBit(Boolean)}
*/
@Deprecated
static byte[] asBit(boolean value) {
return (value ? ONE : ZERO);
}
@@ -198,6 +221,10 @@ public abstract class JedisUtils {
return (Position.AFTER.equals(where) ? LIST_POSITION.AFTER : LIST_POSITION.BEFORE);
}
/**
* Deprecated. Use #{@link JedisConverters#toProperties(String)}
*/
@Deprecated
static Properties info(String string) {
Properties info = new Properties();
StringReader stringReader = new StringReader(string);
@@ -215,6 +242,10 @@ public abstract class JedisUtils {
return new JedisMessageListener(listener);
}
/**
* Deprecated. Use #{@link JedisConverters#toStrings(byte[][])}
*/
@Deprecated
static String[] convert(byte[]... raw) {
String[] result = new String[raw.length];
@@ -234,10 +265,18 @@ public abstract class JedisUtils {
return args.toArray(new byte[args.size()][]);
}
/**
* Deprecated. Use #{@link JedisConverters#toBytes(Integer)}
*/
@Deprecated
static byte[] asBytes(int number) {
return String.valueOf(number).getBytes();
}
/**
* Deprecated. Use #{@link JedisConverters#toString(byte[])}
*/
@Deprecated
static String asString(byte[] raw) {
return SafeEncoder.encode(raw);
}

View File

@@ -249,7 +249,7 @@ public class DefaultLettucePool implements LettucePool, InitializingBean {
}
public Object makeObject() throws Exception {
return client.connectAsync(LettuceUtils.CODEC);
return client.connectAsync(LettuceConnection.CODEC);
}
@SuppressWarnings("rawtypes")

View File

@@ -149,7 +149,7 @@ public class LettuceConnectionFactory implements InitializingBean, DisposableBea
}
public DataAccessException translateExceptionIfPossible(RuntimeException ex) {
return LettuceUtils.convertRedisAccessException(ex);
return LettuceConverters.toDataAccessException(ex);
}
/**
@@ -340,7 +340,7 @@ public class LettuceConnectionFactory implements InitializingBean, DisposableBea
protected RedisAsyncConnection<byte[], byte[]> createLettuceConnector() {
try {
RedisAsyncConnection<byte[], byte[]> connection = client.connectAsync(LettuceUtils.CODEC);
RedisAsyncConnection<byte[], byte[]> connection = client.connectAsync(LettuceConnection.CODEC);
if(dbIndex > 0) {
connection.select(dbIndex);
}

View File

@@ -49,8 +49,10 @@ import com.lambdaworks.redis.protocol.Charsets;
* Helper class featuring methods for Lettuce connection handling, providing
* support for exception translation.
*
* Deprecated in favor of {@link LettuceConverters}
* @author Costin Leau
*/
@Deprecated
abstract class LettuceUtils {
static final RedisCodec<byte[], byte[]> CODEC = new BytesRedisCodec();

View File

@@ -78,7 +78,7 @@ public class SrpConnectionFactory implements InitializingBean, DisposableBean, R
}
public DataAccessException translateExceptionIfPossible(RuntimeException ex) {
return SrpUtils.convertSRedisAccessException(ex);
return SrpConverters.toDataAccessException(ex);
}
/**

View File

@@ -49,9 +49,12 @@ import com.google.common.base.Charsets;
/**
* Helper class featuring methods for SRedis connection handling, providing support for exception translation.
*
* Deprecated. Use {@link SrpConverters} instead.
*
* @author Costin Leau
* @author Jennifer Hickey
*/
@Deprecated
abstract class SrpUtils {
private static final byte[] ONE = new byte[] { '1' };