moved codec registartion to CommandAsyncService

pull/1552/head
Rui Gu 7 years ago
parent 67a2f119fd
commit 7c2dfebbaa

@ -158,7 +158,7 @@ public class Redisson implements RedissonClient {
public static RedissonClient create(Config config) {
Redisson redisson = new Redisson(config);
if (config.isReferenceEnabled()) {
redisson.enableRedissonReferenceSupport(config);
redisson.enableRedissonReferenceSupport();
}
return redisson;
}
@ -186,7 +186,7 @@ public class Redisson implements RedissonClient {
public static RedissonReactiveClient createReactive(Config config) {
RedissonReactive react = new RedissonReactive(config);
if (config.isReferenceEnabled()) {
react.enableRedissonReferenceSupport(config);
react.enableRedissonReferenceSupport();
}
return react;
}
@ -664,10 +664,8 @@ public class Redisson implements RedissonClient {
return connectionManager.isShuttingDown();
}
protected void enableRedissonReferenceSupport(Config config) {
protected void enableRedissonReferenceSupport() {
this.connectionManager.getCommandExecutor().enableRedissonReferenceSupport(this);
Codec codec = config.getCodec();
config.getReferenceCodecProvider().registerCodec((Class<Codec>) codec.getClass(), codec);
}
@Override

@ -389,10 +389,8 @@ public class RedissonReactive implements RedissonReactiveClient {
return connectionManager.isShuttingDown();
}
protected void enableRedissonReferenceSupport(Config config) {
protected void enableRedissonReferenceSupport() {
this.commandExecutor.enableRedissonReferenceSupport(this);
Codec codec = config.getCodec();
config.getReferenceCodecProvider().registerCodec((Class<Codec>) codec.getClass(), codec);
}
@Override

@ -55,6 +55,8 @@ import org.redisson.client.protocol.RedisCommands;
import org.redisson.client.protocol.ScoredEntry;
import org.redisson.client.protocol.decoder.ListScanResult;
import org.redisson.client.protocol.decoder.MapScanResult;
import org.redisson.codec.ReferenceCodecProvider;
import org.redisson.config.Config;
import org.redisson.config.MasterSlaveServersConfig;
import org.redisson.connection.ConnectionManager;
import org.redisson.connection.MasterSlaveEntry;
@ -102,6 +104,7 @@ public class CommandAsyncService implements CommandAsyncExecutor {
public CommandAsyncExecutor enableRedissonReferenceSupport(RedissonClient redisson) {
if (redisson != null) {
this.redisson = redisson;
enableRedissonReferenceSupport(redisson.getConfig());
this.redissonReactive = null;
}
return this;
@ -111,11 +114,18 @@ public class CommandAsyncService implements CommandAsyncExecutor {
public CommandAsyncExecutor enableRedissonReferenceSupport(RedissonReactiveClient redissonReactive) {
if (redissonReactive != null) {
this.redissonReactive = redissonReactive;
enableRedissonReferenceSupport(redissonReactive.getConfig());
this.redisson = null;
}
return this;
}
private void enableRedissonReferenceSupport(Config config) {
Codec codec = config.getCodec();
ReferenceCodecProvider codecProvider = config.getReferenceCodecProvider();
codecProvider.registerCodec((Class<Codec>) codec.getClass(), codec);
}
@Override
public boolean isRedissonReferenceSupportEnabled() {
return redisson != null || redissonReactive != null;

Loading…
Cancel
Save