+ remove unused generic on Connection interface
This commit is contained in:
@@ -33,5 +33,5 @@ public interface MyRedisCallback<T> {
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
T doInRedis(RedisConnection<?> connection) throws Exception;
|
||||
T doInRedis(RedisConnection connection) throws Exception;
|
||||
}
|
||||
|
||||
@@ -64,12 +64,12 @@ public class MyRedisTemplate extends MyRedisAccessor {
|
||||
Assert.notNull(action, "Callback object must not be null");
|
||||
|
||||
RedisConnectionFactory factory = getConnectionFactory();
|
||||
RedisConnection<?> conn = RedisConnectionUtils.getRedisConnection(factory);
|
||||
RedisConnection conn = RedisConnectionUtils.getRedisConnection(factory);
|
||||
|
||||
boolean existingConnection = TransactionSynchronizationManager.hasResource(factory);
|
||||
|
||||
try {
|
||||
RedisConnection<?> connToExpose = (exposeConnection ? conn : createRedisConnectionProxy(conn));
|
||||
RedisConnection connToExpose = (exposeConnection ? conn : createRedisConnectionProxy(conn));
|
||||
T result = action.doInRedis(connToExpose);
|
||||
// TODO: should do flush?
|
||||
return postProcessResult(result, conn, existingConnection);
|
||||
@@ -81,13 +81,13 @@ public class MyRedisTemplate extends MyRedisAccessor {
|
||||
}
|
||||
}
|
||||
|
||||
protected RedisConnection<?> createRedisConnectionProxy(RedisConnection<?> pm) {
|
||||
protected RedisConnection createRedisConnectionProxy(RedisConnection pm) {
|
||||
Class<?>[] ifcs = ClassUtils.getAllInterfacesForClass(pm.getClass(), getClass().getClassLoader());
|
||||
return (RedisConnection<?>) Proxy.newProxyInstance(pm.getClass().getClassLoader(), ifcs,
|
||||
return (RedisConnection) Proxy.newProxyInstance(pm.getClass().getClassLoader(), ifcs,
|
||||
new CloseSuppressingInvocationHandler(pm));
|
||||
}
|
||||
|
||||
protected <T> T postProcessResult(T result, RedisConnection<?> pm, boolean existingConnection) {
|
||||
protected <T> T postProcessResult(T result, RedisConnection conn, boolean existingConnection) {
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -122,9 +122,9 @@ public class MyRedisTemplate extends MyRedisAccessor {
|
||||
*/
|
||||
private class CloseSuppressingInvocationHandler implements InvocationHandler {
|
||||
|
||||
private final RedisConnection<?> target;
|
||||
private final RedisConnection target;
|
||||
|
||||
public CloseSuppressingInvocationHandler(RedisConnection<?> target) {
|
||||
public CloseSuppressingInvocationHandler(RedisConnection target) {
|
||||
this.target = target;
|
||||
}
|
||||
|
||||
|
||||
@@ -33,36 +33,36 @@ public abstract class RedisConnectionUtils {
|
||||
|
||||
private static final Log log = LogFactory.getLog(RedisConnectionUtils.class);
|
||||
|
||||
public static RedisConnection<?> getRedisConnection(RedisConnectionFactory factory) {
|
||||
public static RedisConnection getRedisConnection(RedisConnectionFactory factory) {
|
||||
return doGetRedisConnection(factory, true);
|
||||
}
|
||||
|
||||
public static RedisConnection<?> doGetRedisConnection(RedisConnectionFactory factory, boolean allowCreate) {
|
||||
public static RedisConnection doGetRedisConnection(RedisConnectionFactory factory, boolean allowCreate) {
|
||||
Assert.notNull(factory, "No RedisConnectionFactory specified");
|
||||
|
||||
RedisConnectionHolder pmHolder = (RedisConnectionHolder) TransactionSynchronizationManager.getResource(factory);
|
||||
RedisConnectionHolder connHolder = (RedisConnectionHolder) TransactionSynchronizationManager.getResource(factory);
|
||||
//TODO: investigate tx synchronization
|
||||
|
||||
if (pmHolder != null)
|
||||
return pmHolder.getConnection();
|
||||
if (connHolder != null)
|
||||
return connHolder.getConnection();
|
||||
|
||||
if (log.isDebugEnabled())
|
||||
log.debug("Opening RedisConnection");
|
||||
|
||||
RedisConnection<?> conn = factory.getConnection();
|
||||
RedisConnection conn = factory.getConnection();
|
||||
|
||||
if (TransactionSynchronizationManager.isSynchronizationActive()) {
|
||||
pmHolder = new RedisConnectionHolder(conn);
|
||||
TransactionSynchronizationManager.registerSynchronization(new RedisConnectionSynchronization(pmHolder,
|
||||
connHolder = new RedisConnectionHolder(conn);
|
||||
TransactionSynchronizationManager.registerSynchronization(new RedisConnectionSynchronization(connHolder,
|
||||
factory, true));
|
||||
TransactionSynchronizationManager.bindResource(factory, pmHolder);
|
||||
TransactionSynchronizationManager.bindResource(factory, connHolder);
|
||||
|
||||
}
|
||||
return pmHolder.getConnection();
|
||||
return connHolder.getConnection();
|
||||
|
||||
}
|
||||
|
||||
public static void releaseConnection(RedisConnection<?> conn, RedisConnectionFactory factory) {
|
||||
public static void releaseConnection(RedisConnection conn, RedisConnectionFactory factory) {
|
||||
if (conn == null) {
|
||||
return;
|
||||
}
|
||||
@@ -73,7 +73,7 @@ public abstract class RedisConnectionUtils {
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isConnectionTransactional(RedisConnection<?> conn, RedisConnectionFactory connFactory) {
|
||||
public static boolean isConnectionTransactional(RedisConnection conn, RedisConnectionFactory connFactory) {
|
||||
if (connFactory == null) {
|
||||
return false;
|
||||
}
|
||||
@@ -106,9 +106,9 @@ public abstract class RedisConnectionUtils {
|
||||
private static class RedisConnectionHolder implements ResourceHolder {
|
||||
|
||||
private boolean isVoid = false;
|
||||
private final RedisConnection<?> conn;
|
||||
private final RedisConnection conn;
|
||||
|
||||
public RedisConnectionHolder(RedisConnection<?> conn) {
|
||||
public RedisConnectionHolder(RedisConnection conn) {
|
||||
this.conn = conn;
|
||||
}
|
||||
|
||||
@@ -117,7 +117,7 @@ public abstract class RedisConnectionUtils {
|
||||
return isVoid;
|
||||
}
|
||||
|
||||
public RedisConnection<?> getConnection() {
|
||||
public RedisConnection getConnection() {
|
||||
return conn;
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ import org.springframework.datastore.redis.UncategorizedRedisException;
|
||||
*
|
||||
* @author Costin Leau
|
||||
*/
|
||||
public interface RedisConnection<T> extends RedisCommands, RedisHashCommands, RedisListCommands, RedisSetCommands,
|
||||
public interface RedisConnection extends RedisCommands, RedisHashCommands, RedisListCommands, RedisSetCommands,
|
||||
RedisStringCommands, RedisZSetCommands {
|
||||
|
||||
/**
|
||||
@@ -36,7 +36,7 @@ public interface RedisConnection<T> extends RedisCommands, RedisHashCommands, Re
|
||||
|
||||
boolean isClosed();
|
||||
|
||||
T getNativeConnection();
|
||||
Object getNativeConnection();
|
||||
|
||||
String getCharset();
|
||||
|
||||
|
||||
@@ -26,5 +26,5 @@ import org.springframework.dao.support.PersistenceExceptionTranslator;
|
||||
*/
|
||||
public interface RedisConnectionFactory extends PersistenceExceptionTranslator {
|
||||
|
||||
RedisConnection<?> getConnection();
|
||||
RedisConnection getConnection();
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ import redis.clients.jedis.Transaction;
|
||||
*
|
||||
* @author Costin Leau
|
||||
*/
|
||||
public class JedisConnection implements RedisConnection<Jedis> {
|
||||
public class JedisConnection implements RedisConnection {
|
||||
|
||||
private static final Field CLIENT_FIELD;
|
||||
|
||||
|
||||
@@ -123,9 +123,10 @@ public class JedisConnectionFactory implements InitializingBean, DisposableBean,
|
||||
}
|
||||
|
||||
public void destroy() throws Exception {
|
||||
// TODO: should this component do tracking of all returned connections
|
||||
// normally not but then again we're the ones creating the connections
|
||||
// so we end up behaving like a pool
|
||||
if (usePool && pool != null) {
|
||||
pool.destroy();
|
||||
pool = null;
|
||||
}
|
||||
}
|
||||
|
||||
public JedisConnection getConnection() {
|
||||
|
||||
Reference in New Issue
Block a user