public static void setSessionPassivationAllowed ( final boolean bSessionPassivationAllowed ) { s_aSessionPassivationAllowed . set ( bSessionPassivationAllowed ) ; if ( LOGGER . isInfoEnabled ( ) ) LOGGER . info ( "Session passivation is now " + ( bSessionPassivationAllowed ? "enabled" : "disabled" ) ) ; // For passivation to work, the session scopes may not be invalidated at the // end of the global scope! final ScopeSessionManager aSSM = ScopeSessionManager . getInstance ( ) ; aSSM . setDestroyAllSessionsOnScopeEnd ( ! bSessionPassivationAllowed ) ; aSSM . setEndAllSessionsOnScopeEnd ( ! bSessionPassivationAllowed ) ; // Ensure that all session web scopes have the activator set or removed for ( final ISessionWebScope aSessionWebScope : WebScopeSessionManager . getAllSessionWebScopes ( ) ) { final HttpSession aHttpSession = aSessionWebScope . getSession ( ) ; if ( bSessionPassivationAllowed ) { // Ensure the activator is present if ( aHttpSession . getAttribute ( SESSION_ATTR_SESSION_SCOPE_ACTIVATOR ) == null ) aHttpSession . setAttribute ( SESSION_ATTR_SESSION_SCOPE_ACTIVATOR , new SessionWebScopeActivator ( aSessionWebScope ) ) ; } else { // Ensure the activator is not present aHttpSession . removeAttribute ( SESSION_ATTR_SESSION_SCOPE_ACTIVATOR ) ; } } }
Allow or disallow session passivation