Merge pull request #1105 from michaelcameron/configurable-child-classes

Separate client construction into separate method
pull/1124/head
Nikita Koksharov 7 years ago committed by GitHub
commit 006e1e7934

@ -162,6 +162,12 @@ public class RedissonSessionManager extends ManagerBase implements Lifecycle {
@Override @Override
public void start() throws LifecycleException { public void start() throws LifecycleException {
redisson = buildClient();
lifecycle.fireLifecycleEvent(START_EVENT, null);
}
protected RedissonClient buildClient() throws LifecycleException {
Config config = null; Config config = null;
try { try {
config = Config.fromJSON(new File(configPath), getClass().getClassLoader()); config = Config.fromJSON(new File(configPath), getClass().getClassLoader());
@ -176,12 +182,10 @@ public class RedissonSessionManager extends ManagerBase implements Lifecycle {
} }
try { try {
redisson = Redisson.create(config); return Redisson.create(config);
} catch (Exception e) { } catch (Exception e) {
throw new LifecycleException(e); throw new LifecycleException(e);
} }
lifecycle.fireLifecycleEvent(START_EVENT, null);
} }
@Override @Override

@ -143,6 +143,13 @@ public class RedissonSessionManager extends ManagerBase {
@Override @Override
protected void startInternal() throws LifecycleException { protected void startInternal() throws LifecycleException {
super.startInternal(); super.startInternal();
redisson = buildClient();
setState(LifecycleState.STARTING);
}
protected RedissonClient buildClient() throws LifecycleException {
Config config = null; Config config = null;
try { try {
config = Config.fromJSON(new File(configPath), getClass().getClassLoader()); config = Config.fromJSON(new File(configPath), getClass().getClassLoader());
@ -166,12 +173,10 @@ public class RedissonSessionManager extends ManagerBase {
throw new IllegalStateException("Unable to initialize codec with ClassLoader parameter", e); throw new IllegalStateException("Unable to initialize codec with ClassLoader parameter", e);
} }
redisson = Redisson.create(config); return Redisson.create(config);
} catch (Exception e) { } catch (Exception e) {
throw new LifecycleException(e); throw new LifecycleException(e);
} }
setState(LifecycleState.STARTING);
} }
@Override @Override

@ -144,6 +144,12 @@ public class RedissonSessionManager extends ManagerBase {
@Override @Override
protected void startInternal() throws LifecycleException { protected void startInternal() throws LifecycleException {
super.startInternal(); super.startInternal();
redisson = buildClient();
setState(LifecycleState.STARTING);
}
protected RedissonClient buildClient() throws LifecycleException {
Config config = null; Config config = null;
try { try {
config = Config.fromJSON(new File(configPath), getClass().getClassLoader()); config = Config.fromJSON(new File(configPath), getClass().getClassLoader());
@ -163,12 +169,10 @@ public class RedissonSessionManager extends ManagerBase {
.newInstance(Thread.currentThread().getContextClassLoader()); .newInstance(Thread.currentThread().getContextClassLoader());
config.setCodec(codec); config.setCodec(codec);
redisson = Redisson.create(config); return Redisson.create(config);
} catch (Exception e) { } catch (Exception e) {
throw new LifecycleException(e); throw new LifecycleException(e);
} }
setState(LifecycleState.STARTING);
} }
@Override @Override

Loading…
Cancel
Save