+ implementing missing constructor functionality when specifying the host or the port for JRedis

This commit is contained in:
Costin Leau
2010-12-07 20:07:09 +02:00
parent 04c566b006
commit 328841f0b9

View File

@@ -15,6 +15,7 @@
*/
package org.springframework.data.keyvalue.redis.connection.jredis;
import org.jredis.connector.Connection;
import org.jredis.connector.ConnectionSpec;
import org.jredis.connector.Connection.Socket.Property;
import org.jredis.ri.alphazero.JRedisClient;
@@ -46,22 +47,27 @@ public class JredisConnectionFactory implements InitializingBean, DisposableBean
// taken from JRedis code
private int poolSize = 5;
private static final int DEFAULT_REDIS_PORT = 6379;
private static final int DEFAULT_REDIS_DB = 0;
private static final byte[] DEFAULT_REDIS_PASSWORD = null;
/**
* Constructs a new <code>JredisConnectionFactory</code> instance.
*/
public JredisConnectionFactory() {
this(DefaultConnectionSpec.newSpec());
ConnectionSpec newSpec = DefaultConnectionSpec.newSpec();
newSpec.setConnectionFlag(Connection.Flag.RELIABLE, false);
this.connectionSpec = newSpec;
}
/**
* Constructs a new <code>JredisConnectionFactory</code> instance.
*
* @param hostName
*/
public JredisConnectionFactory(String hostName) {
Assert.hasText(hostName);
throw new UnsupportedOperationException();
this(hostName, DEFAULT_REDIS_PORT);
}
@@ -73,7 +79,9 @@ public class JredisConnectionFactory implements InitializingBean, DisposableBean
*/
public JredisConnectionFactory(String hostName, int port) {
Assert.hasText(hostName);
throw new UnsupportedOperationException();
ConnectionSpec newSpec = DefaultConnectionSpec.newSpec(hostName, port, DEFAULT_REDIS_DB, DEFAULT_REDIS_PASSWORD);
newSpec.setConnectionFlag(Connection.Flag.RELIABLE, false);
this.connectionSpec = newSpec;
}
/**