1313import redis .clients .jedis .JedisPool ;
1414import redis .clients .jedis .JedisPoolConfig ;
1515import redis .clients .jedis .Jedis ;
16+ import redis .clients .jedis .Protocol ;
1617
1718import java .io .IOException ;
1819import java .util .ArrayList ;
@@ -32,6 +33,8 @@ public class RedisSessionManager extends ManagerBase implements Lifecycle {
3233 protected String host = "localhost" ;
3334 protected int port = 6379 ;
3435 protected int database = 0 ;
36+ protected String password = null ;
37+ protected int timeout = Protocol .DEFAULT_TIMEOUT ;
3538 protected JedisPool connectionPool ;
3639
3740 protected RedisSessionHandlerValve handlerValve ;
@@ -73,6 +76,22 @@ public void setDatabase(int database) {
7376 this .database = database ;
7477 }
7578
79+ public int getTimeout () {
80+ return timeout ;
81+ }
82+
83+ public void setTimeout (int timeout ) {
84+ this .timeout = timeout ;
85+ }
86+
87+ public String getPassword () {
88+ return password ;
89+ }
90+
91+ public void setPassword (String password ) {
92+ this .password = password ;
93+ }
94+
7695 public void setSerializationStrategyClass (String strategy ) {
7796 this .serializationStrategyClass = strategy ;
7897 }
@@ -446,7 +465,7 @@ public void processExpires() {
446465 private void initializeDatabaseConnection () throws LifecycleException {
447466 try {
448467 // TODO: Allow more parameters (like port).
449- connectionPool = new JedisPool (new JedisPoolConfig (), getHost (), getPort ());
468+ connectionPool = new JedisPool (new JedisPoolConfig (), getHost (), getPort (), getTimeout (), getPassword () );
450469 } catch (Exception e ) {
451470 e .printStackTrace ();
452471 throw new LifecycleException ("Error Connecting to Redis" , e );
0 commit comments