Skip to content

Commit

Permalink
Use Context.sessionTimeout to set timeout for new sessions.
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Grotzke committed Feb 23, 2016
1 parent 74a1137 commit c7d17d7
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 50 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -677,7 +677,7 @@ public MemcachedBackupSession createSession( String sessionId ) {
session.setNew( true );
session.setValid( true );
session.setCreationTime( System.currentTimeMillis() );
session.setMaxInactiveInterval( _manager.getMaxInactiveInterval() );
session.setMaxInactiveInterval( _manager.getContext().getSessionTimeout() * 60 );

if ( sessionId == null || !_memcachedNodesManager.canHitMemcached( sessionId ) ) {
sessionId = _manager.generateSessionId();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down Expand Up @@ -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}
*/
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down

0 comments on commit c7d17d7

Please sign in to comment.