Created
September 16, 2011 14:12
-
-
Save mente/1222206 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
public void setSessionMode(String sessionMode) { | |
String mode = sessionMode; | |
if (mode == null) { | |
throw new IllegalArgumentException("sessionMode argument cannot be null."); | |
} | |
mode = sessionMode.toLowerCase(); | |
if (!HTTP_SESSION_MODE.equals(mode) && !NATIVE_SESSION_MODE.equals(mode)) { | |
String msg = "Invalid sessionMode [" + sessionMode + "]. Allowed values are " + | |
"public static final String constants in the " + getClass().getName() + " class: '" | |
+ HTTP_SESSION_MODE + "' or '" + NATIVE_SESSION_MODE + "', with '" + | |
HTTP_SESSION_MODE + "' being the default."; | |
throw new IllegalArgumentException(msg); | |
} | |
boolean recreate = this.sessionMode == null || !this.sessionMode.equals(mode); | |
this.sessionMode = mode; | |
if (recreate) { | |
LifecycleUtils.destroy(getSessionManager()); | |
SessionManager sessionManager = createSessionManager(mode); | |
setSessionManager(sessionManager); | |
} | |
} | |
/** | |
* @since 1.0 | |
*/ | |
public boolean isHttpSessionMode() { | |
return this.sessionMode == null || this.sessionMode.equals(HTTP_SESSION_MODE); | |
} | |
protected SessionManager createSessionManager(String sessionMode) { | |
if (sessionMode == null || sessionMode.equalsIgnoreCase(HTTP_SESSION_MODE)) { | |
if (log.isInfoEnabled()) { | |
log.info(HTTP_SESSION_MODE + " mode - enabling ServletContainerSessionManager (HTTP-only Sessions)"); | |
} | |
return new ServletContainerSessionManager(); | |
} else { | |
if (log.isInfoEnabled()) { | |
log.info(NATIVE_SESSION_MODE + " mode - enabling DefaultWebSessionManager (HTTP + heterogeneous-client sessions)"); | |
} | |
return new DefaultWebSessionManager(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment