diff --git a/spring-data-redis/src/main/java/org/springframework/data/keyvalue/redis/connection/DataType.java b/spring-data-redis/src/main/java/org/springframework/data/keyvalue/redis/connection/DataType.java index a09aa52dd..78a6ec7bd 100644 --- a/spring-data-redis/src/main/java/org/springframework/data/keyvalue/redis/connection/DataType.java +++ b/spring-data-redis/src/main/java/org/springframework/data/keyvalue/redis/connection/DataType.java @@ -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) diff --git a/spring-data-redis/src/main/java/org/springframework/data/keyvalue/redis/connection/SortParameters.java b/spring-data-redis/src/main/java/org/springframework/data/keyvalue/redis/connection/SortParameters.java index f33ab25a2..ec6cf7d42 100644 --- a/spring-data-redis/src/main/java/org/springframework/data/keyvalue/redis/connection/SortParameters.java +++ b/spring-data-redis/src/main/java/org/springframework/data/keyvalue/redis/connection/SortParameters.java @@ -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 */ diff --git a/spring-data-redis/src/main/java/org/springframework/data/keyvalue/redis/connection/jedis/JedisConnection.java b/spring-data-redis/src/main/java/org/springframework/data/keyvalue/redis/connection/jedis/JedisConnection.java index 92736fc2a..b50bf7e67 100644 --- a/spring-data-redis/src/main/java/org/springframework/data/keyvalue/redis/connection/jedis/JedisConnection.java +++ b/spring-data-redis/src/main/java/org/springframework/data/keyvalue/redis/connection/jedis/JedisConnection.java @@ -41,7 +41,7 @@ import redis.clients.jedis.Transaction; import redis.clients.jedis.ZParams; /** - * Jedis based {@link RedisConnection}. + * {@code RedisConnection} implementation on top of Jedis library. * * @author Costin Leau */ @@ -58,6 +58,11 @@ public class JedisConnection implements RedisConnection { private final Client client; private final BinaryTransaction transaction; + /** + * Constructs a new JedisConnection instance. + * + * @param jedis Jedis entity + */ public JedisConnection(Jedis jedis) { this.jedis = jedis; // extract underlying connection for batch operations diff --git a/spring-data-redis/src/main/java/org/springframework/data/keyvalue/redis/connection/jedis/JedisConnectionFactory.java b/spring-data-redis/src/main/java/org/springframework/data/keyvalue/redis/connection/jedis/JedisConnectionFactory.java index 527f236bf..2cb20a879 100644 --- a/spring-data-redis/src/main/java/org/springframework/data/keyvalue/redis/connection/jedis/JedisConnectionFactory.java +++ b/spring-data-redis/src/main/java/org/springframework/data/keyvalue/redis/connection/jedis/JedisConnectionFactory.java @@ -33,7 +33,7 @@ import redis.clients.jedis.JedisPool; import redis.clients.jedis.JedisShardInfo; /** - * Connection factory using Jedis underneath. + * Connection factory using creating Jedis 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 JedisConnectionFactory 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; - } } \ No newline at end of file diff --git a/spring-data-redis/src/main/java/org/springframework/data/keyvalue/redis/connection/jedis/JedisUtils.java b/spring-data-redis/src/main/java/org/springframework/data/keyvalue/redis/connection/jedis/JedisUtils.java index d1074328d..3cd72cf8c 100644 --- a/spring-data-redis/src/main/java/org/springframework/data/keyvalue/redis/connection/jedis/JedisUtils.java +++ b/spring-data-redis/src/main/java/org/springframework/data/keyvalue/redis/connection/jedis/JedisUtils.java @@ -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); diff --git a/spring-data-redis/src/main/java/org/springframework/data/keyvalue/redis/connection/jedis/package-info.java b/spring-data-redis/src/main/java/org/springframework/data/keyvalue/redis/connection/jedis/package-info.java new file mode 100644 index 000000000..b1f4bfd97 --- /dev/null +++ b/spring-data-redis/src/main/java/org/springframework/data/keyvalue/redis/connection/jedis/package-info.java @@ -0,0 +1,5 @@ +/** + *

Connection package for Jedis library. + */ +package org.springframework.data.keyvalue.redis.connection.jedis; + diff --git a/spring-data-redis/src/main/java/org/springframework/data/keyvalue/redis/connection/jredis/Base64.java b/spring-data-redis/src/main/java/org/springframework/data/keyvalue/redis/connection/jredis/Base64.java index ac698be82..6feb3a4d6 100644 --- a/spring-data-redis/src/main/java/org/springframework/data/keyvalue/redis/connection/jredis/Base64.java +++ b/spring-data-redis/src/main/java/org/springframework/data/keyvalue/redis/connection/jredis/Base64.java @@ -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.

* 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) diff --git a/spring-data-redis/src/main/java/org/springframework/data/keyvalue/redis/connection/jredis/JredisConnection.java b/spring-data-redis/src/main/java/org/springframework/data/keyvalue/redis/connection/jredis/JredisConnection.java index d78ef1233..1fa82e638 100644 --- a/spring-data-redis/src/main/java/org/springframework/data/keyvalue/redis/connection/jredis/JredisConnection.java +++ b/spring-data-redis/src/main/java/org/springframework/data/keyvalue/redis/connection/jredis/JredisConnection.java @@ -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 JRedis 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 JredisConnection instance. + * + * @param jredis JRedis connection + */ + public JredisConnection(JRedis jredis) { this.jredis = jredis; - this.charset = charset; } protected DataAccessException convertJedisAccessException(Exception ex) { diff --git a/spring-data-redis/src/main/java/org/springframework/data/keyvalue/redis/connection/jredis/JredisConnectionFactory.java b/spring-data-redis/src/main/java/org/springframework/data/keyvalue/redis/connection/jredis/JredisConnectionFactory.java index 48fe18a24..1ac47a300 100644 --- a/spring-data-redis/src/main/java/org/springframework/data/keyvalue/redis/connection/jredis/JredisConnectionFactory.java +++ b/spring-data-redis/src/main/java/org/springframework/data/keyvalue/redis/connection/jredis/JredisConnectionFactory.java @@ -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 JRedis 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 JredisConnectionFactory 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; - } } \ No newline at end of file diff --git a/spring-data-redis/src/main/java/org/springframework/data/keyvalue/redis/connection/jredis/JredisUtils.java b/spring-data-redis/src/main/java/org/springframework/data/keyvalue/redis/connection/jredis/JredisUtils.java index 042ab7257..53bb8b1c2 100644 --- a/spring-data-redis/src/main/java/org/springframework/data/keyvalue/redis/connection/jredis/JredisUtils.java +++ b/spring-data-redis/src/main/java/org/springframework/data/keyvalue/redis/connection/jredis/JredisUtils.java @@ -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); } diff --git a/spring-data-redis/src/main/java/org/springframework/data/keyvalue/redis/connection/jredis/package-info.java b/spring-data-redis/src/main/java/org/springframework/data/keyvalue/redis/connection/jredis/package-info.java new file mode 100644 index 000000000..50fad613e --- /dev/null +++ b/spring-data-redis/src/main/java/org/springframework/data/keyvalue/redis/connection/jredis/package-info.java @@ -0,0 +1,5 @@ +/** + *

Connection package for JRedis library. + */ +package org.springframework.data.keyvalue.redis.connection.jredis; + diff --git a/spring-data-redis/src/main/java/org/springframework/data/keyvalue/redis/connection/package-info.java b/spring-data-redis/src/main/java/org/springframework/data/keyvalue/redis/connection/package-info.java new file mode 100644 index 000000000..096008586 --- /dev/null +++ b/spring-data-redis/src/main/java/org/springframework/data/keyvalue/redis/connection/package-info.java @@ -0,0 +1,7 @@ +/** + *

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