Skip to content

Commit

Permalink
initialize clients on idManager's startup, not on instantiation time.
Browse files Browse the repository at this point in the history
this is because children classes may require additional configurations
of clients in their constructor.
  • Loading branch information
Yamashita Yuu committed Jan 31, 2012
1 parent a5d1fc9 commit 051d66c
Showing 1 changed file with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,14 @@ public abstract class KeyValueStoreSessionIdManager extends AbstractSessionIdMan
protected String _keyPrefix = "";
protected String _keySuffix = "";
protected IKeyValueStoreClient _client = null;
protected String _serverString = "";

/* ------------------------------------------------------------ */
public KeyValueStoreSessionIdManager(Server server, String serverString) throws IOException {
super(new Random());
this._server = server;
this._client = newClient(serverString);
// this._client = newClient(serverString); // will be initialized on startup
this._serverString = serverString;
}

/* ------------------------------------------------------------ */
Expand Down Expand Up @@ -211,9 +213,11 @@ public void setPurgeValidAge(long purgeValidAge) {
protected void doStart() throws Exception {
log.info("starting...");
super.doStart();
if (_client != null) {
_client.establish();
_client = newClient(_serverString);
if (_client == null) {
throw new IllegalStateException("newClient(" + _serverString + ") returns null.");
}
_client.establish();
log.info("started.");
}

Expand All @@ -223,6 +227,7 @@ protected void doStop() throws Exception {
log.info("stopping...");
if (_client != null) {
_client.shutdown();
_client = null;
}
super.doStop();
log.info("stopped.");
Expand Down

0 comments on commit 051d66c

Please sign in to comment.