+ add javadocs
This commit is contained in:
@@ -43,10 +43,21 @@ public enum DataType {
|
||||
this.code = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the code associated with the current enum.
|
||||
*
|
||||
* @return code of this enum
|
||||
*/
|
||||
public String code() {
|
||||
return code;
|
||||
}
|
||||
|
||||
/**
|
||||
* Utility method for converting an enum code to an actual enum.
|
||||
*
|
||||
* @param code enum code
|
||||
* @return actual enum corresponding to the given code
|
||||
*/
|
||||
public static DataType fromCode(String code) {
|
||||
DataType data = codeLookup.get(code);
|
||||
if (data == null)
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
package org.springframework.data.keyvalue.redis.connection;
|
||||
|
||||
/**
|
||||
* Parameters for the SORT operation.
|
||||
* Entity containing the parameters for the SORT operation.
|
||||
*
|
||||
* @author Costin Leau
|
||||
*/
|
||||
|
||||
@@ -41,7 +41,7 @@ import redis.clients.jedis.Transaction;
|
||||
import redis.clients.jedis.ZParams;
|
||||
|
||||
/**
|
||||
* Jedis based {@link RedisConnection}.
|
||||
* {@code RedisConnection} implementation on top of <a href="http://github.com/xetorthio/jedis">Jedis</a> library.
|
||||
*
|
||||
* @author Costin Leau
|
||||
*/
|
||||
@@ -58,6 +58,11 @@ public class JedisConnection implements RedisConnection {
|
||||
private final Client client;
|
||||
private final BinaryTransaction transaction;
|
||||
|
||||
/**
|
||||
* Constructs a new <code>JedisConnection</code> instance.
|
||||
*
|
||||
* @param jedis Jedis entity
|
||||
*/
|
||||
public JedisConnection(Jedis jedis) {
|
||||
this.jedis = jedis;
|
||||
// extract underlying connection for batch operations
|
||||
|
||||
@@ -33,7 +33,7 @@ import redis.clients.jedis.JedisPool;
|
||||
import redis.clients.jedis.JedisShardInfo;
|
||||
|
||||
/**
|
||||
* Connection factory using Jedis underneath.
|
||||
* Connection factory using creating <a href="http://github.com/xetorthio/jedis">Jedis</a> based connections.
|
||||
*
|
||||
* @author Costin Leau
|
||||
*/
|
||||
@@ -48,8 +48,6 @@ public class JedisConnectionFactory implements InitializingBean, DisposableBean,
|
||||
private boolean usePool = true;
|
||||
|
||||
private JedisPool pool = null;
|
||||
// taken from Jedis code
|
||||
private int poolSize = 10;
|
||||
|
||||
/**
|
||||
* Constructs a new <code>JedisConnectionFactory</code> instance.
|
||||
@@ -114,7 +112,6 @@ public class JedisConnectionFactory implements InitializingBean, DisposableBean,
|
||||
}
|
||||
|
||||
if (usePool) {
|
||||
int size = getPoolSize();
|
||||
pool = new JedisPool(new GenericObjectPool.Config(), shardInfo.getHost(), shardInfo.getPort(),
|
||||
shardInfo.getTimeout(), shardInfo.getPassword());
|
||||
}
|
||||
@@ -145,13 +142,17 @@ public class JedisConnectionFactory implements InitializingBean, DisposableBean,
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the password
|
||||
* Returns the password used for authenticating with the Redis server.
|
||||
*
|
||||
* @return password for authentication
|
||||
*/
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the password used for authenticating with the Redis server.
|
||||
*
|
||||
* @param password the password to set
|
||||
*/
|
||||
public void setPassword(String password) {
|
||||
@@ -168,6 +169,8 @@ public class JedisConnectionFactory implements InitializingBean, DisposableBean,
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the shard info for this factory.
|
||||
*
|
||||
* @param shardInfo The shardInfo to set.
|
||||
*/
|
||||
public void setShardInfo(JedisShardInfo shardInfo) {
|
||||
@@ -207,22 +210,4 @@ public class JedisConnectionFactory implements InitializingBean, DisposableBean,
|
||||
public void setPooling(boolean usePool) {
|
||||
this.usePool = usePool;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the poolSize.
|
||||
*
|
||||
* @return Returns the poolSize
|
||||
*/
|
||||
public int getPoolSize() {
|
||||
return poolSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param poolSize The poolSize to set.
|
||||
*/
|
||||
public void setPoolSize(int poolSize) {
|
||||
Assert.isTrue(poolSize > 0, "pool size needs to be bigger then zero");
|
||||
this.poolSize = poolSize;
|
||||
usePool = true;
|
||||
}
|
||||
}
|
||||
@@ -47,10 +47,22 @@ public abstract class JedisUtils {
|
||||
private static final String OK_CODE = "OK";
|
||||
private static final String OK_MULTI_CODE = "+OK";
|
||||
|
||||
/**
|
||||
* Converts the given, native Jedis exception to Spring's DAO hierarchy.
|
||||
*
|
||||
* @param ex Jedis exception
|
||||
* @return converted exception
|
||||
*/
|
||||
public static DataAccessException convertJedisAccessException(JedisException ex) {
|
||||
return new InvalidDataAccessApiUsageException(ex.getMessage(), ex);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the given, native, runtime Jedis exception to Spring's DAO hierarchy.
|
||||
*
|
||||
* @param ex Jedis runtime/unchecked exception
|
||||
* @return converted exception
|
||||
*/
|
||||
public static DataAccessException convertJedisAccessException(RuntimeException ex) {
|
||||
if (ex instanceof JedisException) {
|
||||
return convertJedisAccessException((JedisException) ex);
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
/**
|
||||
* <p/>Connection package for <a href="http://github.com/xetorthio/jedis">Jedis</a> library.
|
||||
*/
|
||||
package org.springframework.data.keyvalue.redis.connection.jedis;
|
||||
|
||||
@@ -2,7 +2,8 @@ package org.springframework.data.keyvalue.redis.connection.jredis;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/** A very fast and memory efficient class to encode and decode to and from BASE64 in full accordance
|
||||
/**
|
||||
* A very fast and memory efficient class to encode and decode to and from BASE64 in full accordance
|
||||
* with RFC 2045.<br><br>
|
||||
* On Windows XP sp1 with 1.4.2_04 and later ;), this encoder and decoder is about 10 times faster
|
||||
* on small arrays (10 - 1000 bytes) and 2-3 times as fast on larger arrays (10000 - 1000000 bytes)
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
*/
|
||||
package org.springframework.data.keyvalue.redis.connection.jredis;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.LinkedHashSet;
|
||||
@@ -35,7 +34,7 @@ import org.springframework.data.keyvalue.redis.connection.RedisConnection;
|
||||
import org.springframework.data.keyvalue.redis.connection.SortParameters;
|
||||
|
||||
/**
|
||||
* JRedis based implementation.
|
||||
* {@code RedisConnection} implementation on top of <a href="http://github.com/alphazero/jredis">JRedis</a> library.
|
||||
*
|
||||
* @author Costin Leau
|
||||
*/
|
||||
@@ -43,11 +42,13 @@ public class JredisConnection implements RedisConnection {
|
||||
|
||||
private final JRedis jredis;
|
||||
|
||||
private final Charset charset;
|
||||
|
||||
public JredisConnection(JRedis jredis, Charset charset) {
|
||||
/**
|
||||
* Constructs a new <code>JredisConnection</code> instance.
|
||||
*
|
||||
* @param jredis JRedis connection
|
||||
*/
|
||||
public JredisConnection(JRedis jredis) {
|
||||
this.jredis = jredis;
|
||||
this.charset = charset;
|
||||
}
|
||||
|
||||
protected DataAccessException convertJedisAccessException(Exception ex) {
|
||||
|
||||
@@ -15,9 +15,6 @@
|
||||
*/
|
||||
package org.springframework.data.keyvalue.redis.connection.jredis;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
import org.jredis.JRedis;
|
||||
import org.jredis.connector.ConnectionSpec;
|
||||
import org.jredis.connector.Connection.Socket.Property;
|
||||
import org.jredis.ri.alphazero.JRedisClient;
|
||||
@@ -32,7 +29,7 @@ import org.springframework.util.Assert;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* Connection factory on top of {@link JRedis} connection.
|
||||
* Connection factory using creating <a href="http://github.com/alphazero/jredis">JRedis</a> based connections.
|
||||
*
|
||||
* @author Costin Leau
|
||||
*/
|
||||
@@ -49,10 +46,6 @@ public class JredisConnectionFactory implements InitializingBean, DisposableBean
|
||||
// taken from JRedis code
|
||||
private int poolSize = 5;
|
||||
|
||||
|
||||
private Charset charset = Charset.forName("UTF8");
|
||||
|
||||
|
||||
/**
|
||||
* Constructs a new <code>JredisConnectionFactory</code> instance.
|
||||
*/
|
||||
@@ -120,7 +113,7 @@ public class JredisConnectionFactory implements InitializingBean, DisposableBean
|
||||
|
||||
@Override
|
||||
public RedisConnection getConnection() {
|
||||
return new JredisConnection((usePool ? pool : new JRedisClient(connectionSpec)), charset);
|
||||
return new JredisConnection((usePool ? pool : new JRedisClient(connectionSpec)));
|
||||
}
|
||||
|
||||
|
||||
@@ -130,13 +123,17 @@ public class JredisConnectionFactory implements InitializingBean, DisposableBean
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the password
|
||||
* Returns the password used for authenticating with the Redis server.
|
||||
*
|
||||
* @return password for authentication
|
||||
*/
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the password used for authenticating with the Redis server.
|
||||
*
|
||||
* @param password the password to set
|
||||
*/
|
||||
public void setPassword(String password) {
|
||||
@@ -162,7 +159,7 @@ public class JredisConnectionFactory implements InitializingBean, DisposableBean
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the poolSize.
|
||||
* Returns the pool size of this factory.
|
||||
*
|
||||
* @return Returns the poolSize
|
||||
*/
|
||||
@@ -171,6 +168,8 @@ public class JredisConnectionFactory implements InitializingBean, DisposableBean
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the connection pool size of the underlying factory.
|
||||
*
|
||||
* @param poolSize The poolSize to set.
|
||||
*/
|
||||
public void setPoolSize(int poolSize) {
|
||||
@@ -178,21 +177,4 @@ public class JredisConnectionFactory implements InitializingBean, DisposableBean
|
||||
this.poolSize = poolSize;
|
||||
usePool = true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Charset getCharset() {
|
||||
return charset;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param charset
|
||||
*/
|
||||
public void setCharset(Charset charset) {
|
||||
this.charset = charset;
|
||||
}
|
||||
}
|
||||
@@ -38,6 +38,12 @@ import org.springframework.data.keyvalue.redis.connection.SortParameters.Range;
|
||||
*/
|
||||
public abstract class JredisUtils {
|
||||
|
||||
/**
|
||||
* Converts the given, native JRedis exception to Spring's DAO hierarchy.
|
||||
*
|
||||
* @param ex JRedis exception
|
||||
* @return converted exception
|
||||
*/
|
||||
public static DataAccessException convertJredisAccessException(RedisException ex) {
|
||||
return new InvalidDataAccessApiUsageException(ex.getMessage(), ex);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
/**
|
||||
* <p/>Connection package for <a href="http://github.com/alphazero/jredis">JRedis</a> library.
|
||||
*/
|
||||
package org.springframework.data.keyvalue.redis.connection.jredis;
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
/**
|
||||
* <p/>Connection package providing low-level abstractions for interacting with
|
||||
* the various Redis 'drivers'/libraries. Performs exception translation between
|
||||
* the underlying library exceptions to Spring's DAO hierarchy.
|
||||
*/
|
||||
package org.springframework.data.keyvalue.redis.connection;
|
||||
|
||||
Reference in New Issue
Block a user