-
Notifications
You must be signed in to change notification settings - Fork 348
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use Context.sessionTimeout to set timeout for new sessions.
This is needed for tomcat 6.0.45+ and tomcat 7.0.68+, because there Manager.getMaxInactiveInterval is broken https://github.com/apache/tomcat60/blob/trunk/java/org/apache/catalina/session/ManagerBase.java#L596 https://github.com/apache/tomcat70/blob/trunk/java/org/apache/catalina/session/ManagerBase.java#L426 compared to tomcat 8: https://github.com/apache/tomcat80/blob/trunk/java/org/apache/catalina/session/ManagerBase.java#L427 Fixes #48, #287
- Loading branch information
Martin Grotzke
committed
Feb 23, 2016
1 parent
74a1137
commit c7d17d7
Showing
3 changed files
with
3 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -76,7 +76,7 @@ | |
* @author <a href="mailto:[email protected]">Martin Grotzke</a> | ||
* @version $Id$ | ||
*/ | ||
public class MemcachedBackupSessionManager extends ManagerBase implements Lifecycle, PropertyChangeListener, MemcachedSessionService.SessionManager { | ||
public class MemcachedBackupSessionManager extends ManagerBase implements Lifecycle, MemcachedSessionService.SessionManager { | ||
|
||
protected static final String NAME = MemcachedBackupSessionManager.class.getSimpleName(); | ||
|
||
|
@@ -142,28 +142,6 @@ protected void startInternal( final MemcachedClient memcachedClient ) throws Lif | |
_msm.startInternal(); | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
@Override | ||
public void setContainer( final Container container ) { | ||
|
||
// De-register from the old Container (if any) | ||
if ( this.container != null && this.container instanceof Context ) { | ||
( (Context) this.container ).removePropertyChangeListener( this ); | ||
} | ||
|
||
// Default processing provided by our superclass | ||
super.setContainer( container ); | ||
|
||
// Register with the new Container (if any) | ||
if ( this.container != null && this.container instanceof Context ) { | ||
setMaxInactiveInterval( ( (Context) this.container ).getSessionTimeout() * 60 ); | ||
( (Context) this.container ).addPropertyChangeListener( this ); | ||
} | ||
|
||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
|
@@ -710,31 +688,6 @@ public void backgroundProcess() { | |
super.backgroundProcess(); | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
@Override | ||
public void propertyChange( final PropertyChangeEvent event ) { | ||
|
||
// Validate the source of this event | ||
if ( !( event.getSource() instanceof Context ) ) { | ||
_log.info( "manager.propertyChange("+ event.getPropertyName() +"="+event.getNewValue()+").source: " + event.getSource().getClass() ); | ||
return; | ||
} | ||
|
||
_log.info( "manager.propertyChange("+ event.getPropertyName() +"="+event.getNewValue()+").source: " + event.getSource().getClass() ); | ||
|
||
// Process a relevant property change | ||
if ( event.getPropertyName().equals( "sessionTimeout" ) ) { | ||
try { | ||
setMaxInactiveInterval( ( (Integer) event.getNewValue() ).intValue() * 60 ); | ||
} catch ( final NumberFormatException e ) { | ||
_log.warn( "standardManager.sessionTimeout: " + event.getNewValue().toString() ); | ||
} | ||
} | ||
|
||
} | ||
|
||
/** | ||
* Specifies if the session shall be stored asynchronously in memcached as | ||
* {@link MemcachedClient#set(String, int, Object)} supports it. If this is | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -70,7 +70,7 @@ | |
* @author <a href="mailto:[email protected]">Martin Grotzke</a> | ||
* @version $Id$ | ||
*/ | ||
public class MemcachedBackupSessionManager extends ManagerBase implements Lifecycle, PropertyChangeListener, MemcachedSessionService.SessionManager { | ||
public class MemcachedBackupSessionManager extends ManagerBase implements Lifecycle, MemcachedSessionService.SessionManager { | ||
|
||
protected static final String NAME = MemcachedBackupSessionManager.class.getSimpleName(); | ||
|
||
|