java.lang.Object
cloud.piranha.core.impl.DefaultHttpSessionManager
- All Implemented Interfaces:
HttpSessionManager
,jakarta.servlet.ServletRequestListener
,jakarta.servlet.SessionCookieConfig
,EventListener
public class DefaultHttpSessionManager
extends Object
implements HttpSessionManager, jakarta.servlet.SessionCookieConfig, jakarta.servlet.ServletRequestListener
The default HttpSessionManager.
- Author:
- Manfred Riem ([email protected])
-
Field Summary
Modifier and TypeFieldDescriptionprotected final ArrayList<jakarta.servlet.http.HttpSessionAttributeListener>
Stores the session listeners.protected String
Stores the comment.protected final Set<jakarta.servlet.SessionTrackingMode>
Stores the default session tracking modes.protected String
Stores the domain.protected boolean
Stores the HTTP only flag.protected final ArrayList<jakarta.servlet.http.HttpSessionIdListener>
Stores the session id listeners.protected int
Stores the max age.protected String
Stores the name.protected String
Stores the path.protected boolean
Stores the secure flag.Stores the cookie attributes.protected final Map<String,
AtomicInteger> Stores the session counters.protected final ArrayList<jakarta.servlet.http.HttpSessionListener>
Stores the session listeners.Stores the sessions.protected int
Stores the session timeout (in minutes).protected Set<jakarta.servlet.SessionTrackingMode>
Stores the session tracking modes.protected WebApplication
Stores the web application. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescription<T extends EventListener>
voidaddListener
(T listener) Add a listener.void
attributeAdded
(jakarta.servlet.http.HttpSession session, String name, Object value) Attribute added.void
attributeRemoved
(jakarta.servlet.http.HttpSession session, String name, Object value) Attribute removed.void
attributeReplaced
(jakarta.servlet.http.HttpSession session, String name, Object oldValue, Object newValue) Attribute replaced.changeSessionId
(jakarta.servlet.http.HttpServletRequest request) Change the session id and return it.jakarta.servlet.http.HttpSession
createSession
(jakarta.servlet.http.HttpServletRequest request) Create a session.void
destroySession
(jakarta.servlet.http.HttpSession session) Destroys a session.encodeRedirectURL
(jakarta.servlet.http.HttpServletResponse response, String url) Encode the redirect URL.Encode the URL.getAttribute
(String name) Set<jakarta.servlet.SessionTrackingMode>
Returns the default session tracking modes.Set<jakarta.servlet.SessionTrackingMode>
Returns the effective session tracking modes.int
getName()
getPath()
jakarta.servlet.http.HttpSession
getSession
(jakarta.servlet.http.HttpServletRequest request, String currentSessionId) Returns the session.jakarta.servlet.SessionCookieConfig
Returns the session cookie config.int
Get the session timeout (in minutes).boolean
hasSession
(String sessionId) Is the session manager handling this session?boolean
boolean
isSecure()
protected void
Reap any inactive session.void
requestDestroyed
(jakarta.servlet.ServletRequestEvent event) void
requestInitialized
(jakarta.servlet.ServletRequestEvent event) void
setAttribute
(String name, String value) void
setComment
(String comment) void
void
setHttpOnly
(boolean httpOnly) void
setMaxAge
(int maxAge) void
void
void
setSecure
(boolean secure) void
setSessionTimeout
(int sessionTimeout) Set the session timeout (in minutes).void
setSessionTrackingModes
(Set<jakarta.servlet.SessionTrackingMode> sessionTrackingModes) Set the session tracking modes.void
setWebApplication
(WebApplication webApplication) Set the web application.
-
Field Details
-
attributeListeners
Stores the session listeners. -
comment
Stores the comment. -
defaultSessionTrackingModes
Stores the default session tracking modes. -
domain
Stores the domain. -
httpOnly
protected boolean httpOnlyStores the HTTP only flag. -
idListeners
Stores the session id listeners. -
maxAge
protected int maxAgeStores the max age. -
name
Stores the name. -
path
Stores the path. -
secure
protected boolean secureStores the secure flag. -
sessionCounters
Stores the session counters. -
sessionCookieAttributes
Stores the cookie attributes. -
sessionListeners
Stores the session listeners. -
sessionTimeout
protected int sessionTimeoutStores the session timeout (in minutes). -
sessionTrackingModes
Stores the session tracking modes. -
sessions
Stores the sessions. -
webApplication
Stores the web application.
-
-
Constructor Details
-
DefaultHttpSessionManager
public DefaultHttpSessionManager()Constructor.
-
-
Method Details
-
addListener
Description copied from interface:HttpSessionManager
Add a listener.- Specified by:
addListener
in interfaceHttpSessionManager
- Type Parameters:
T
- the type.- Parameters:
listener
- the listener.
-
attributeAdded
Description copied from interface:HttpSessionManager
Attribute added.- Specified by:
attributeAdded
in interfaceHttpSessionManager
- Parameters:
session
- the HTTP session.name
- the name.value
- the value.
-
attributeRemoved
Description copied from interface:HttpSessionManager
Attribute removed.- Specified by:
attributeRemoved
in interfaceHttpSessionManager
- Parameters:
session
- the HTTP session.name
- the name.value
- the value.
-
attributeReplaced
public void attributeReplaced(jakarta.servlet.http.HttpSession session, String name, Object oldValue, Object newValue) Description copied from interface:HttpSessionManager
Attribute replaced.- Specified by:
attributeReplaced
in interfaceHttpSessionManager
- Parameters:
session
- the HTTP session.name
- the name.oldValue
- the old value.newValue
- the new value.
-
changeSessionId
Description copied from interface:HttpSessionManager
Change the session id and return it.- Specified by:
changeSessionId
in interfaceHttpSessionManager
- Parameters:
request
- the request.- Returns:
- the session id.
-
createSession
public jakarta.servlet.http.HttpSession createSession(jakarta.servlet.http.HttpServletRequest request) Description copied from interface:HttpSessionManager
Create a session.- Specified by:
createSession
in interfaceHttpSessionManager
- Parameters:
request
- the request.- Returns:
- the session.
-
destroySession
public void destroySession(jakarta.servlet.http.HttpSession session) Description copied from interface:HttpSessionManager
Destroys a session.- Specified by:
destroySession
in interfaceHttpSessionManager
- Parameters:
session
- the HTTP session.
-
encodeRedirectURL
Description copied from interface:HttpSessionManager
Encode the redirect URL.- Specified by:
encodeRedirectURL
in interfaceHttpSessionManager
- Parameters:
response
- the HTTP servlet response.url
- the URL.- Returns:
- the encode URL.
-
encodeURL
Description copied from interface:HttpSessionManager
Encode the URL.- Specified by:
encodeURL
in interfaceHttpSessionManager
- Parameters:
response
- the HTTP servlet response.url
- the URL.- Returns:
- the encoded URL.
-
getComment
- Specified by:
getComment
in interfacejakarta.servlet.SessionCookieConfig
-
getDefaultSessionTrackingModes
Description copied from interface:HttpSessionManager
Returns the default session tracking modes.- Specified by:
getDefaultSessionTrackingModes
in interfaceHttpSessionManager
- Returns:
- the default session tracking modes
-
getDomain
- Specified by:
getDomain
in interfacejakarta.servlet.SessionCookieConfig
-
getEffectiveSessionTrackingModes
Description copied from interface:HttpSessionManager
Returns the effective session tracking modes.- Specified by:
getEffectiveSessionTrackingModes
in interfaceHttpSessionManager
- Returns:
- the effective session tracking modes
-
getMaxAge
public int getMaxAge()- Specified by:
getMaxAge
in interfacejakarta.servlet.SessionCookieConfig
-
getName
- Specified by:
getName
in interfacejakarta.servlet.SessionCookieConfig
-
getPath
- Specified by:
getPath
in interfacejakarta.servlet.SessionCookieConfig
-
getSession
public jakarta.servlet.http.HttpSession getSession(jakarta.servlet.http.HttpServletRequest request, String currentSessionId) Description copied from interface:HttpSessionManager
Returns the session.- Specified by:
getSession
in interfaceHttpSessionManager
- Parameters:
request
- the request.currentSessionId
- the current session id.- Returns:
- the session
-
getSessionCookieConfig
public jakarta.servlet.SessionCookieConfig getSessionCookieConfig()Description copied from interface:HttpSessionManager
Returns the session cookie config.- Specified by:
getSessionCookieConfig
in interfaceHttpSessionManager
- Returns:
- the session cookie config
-
getSessionTimeout
public int getSessionTimeout()Description copied from interface:HttpSessionManager
Get the session timeout (in minutes).- Specified by:
getSessionTimeout
in interfaceHttpSessionManager
- Returns:
- the session timeout.
-
hasSession
Description copied from interface:HttpSessionManager
Is the session manager handling this session?- Specified by:
hasSession
in interfaceHttpSessionManager
- Parameters:
sessionId
- the session id.- Returns:
- true if there is a session with the given session id.
-
isHttpOnly
public boolean isHttpOnly()- Specified by:
isHttpOnly
in interfacejakarta.servlet.SessionCookieConfig
-
isSecure
public boolean isSecure()- Specified by:
isSecure
in interfacejakarta.servlet.SessionCookieConfig
-
reapSessions
protected void reapSessions()Reap any inactive session. -
setComment
- Specified by:
setComment
in interfacejakarta.servlet.SessionCookieConfig
-
setDomain
- Specified by:
setDomain
in interfacejakarta.servlet.SessionCookieConfig
-
setHttpOnly
public void setHttpOnly(boolean httpOnly) - Specified by:
setHttpOnly
in interfacejakarta.servlet.SessionCookieConfig
-
setMaxAge
public void setMaxAge(int maxAge) - Specified by:
setMaxAge
in interfacejakarta.servlet.SessionCookieConfig
-
setName
- Specified by:
setName
in interfacejakarta.servlet.SessionCookieConfig
-
setPath
- Specified by:
setPath
in interfacejakarta.servlet.SessionCookieConfig
-
setSecure
public void setSecure(boolean secure) - Specified by:
setSecure
in interfacejakarta.servlet.SessionCookieConfig
-
setSessionTimeout
public void setSessionTimeout(int sessionTimeout) Description copied from interface:HttpSessionManager
Set the session timeout (in minutes).- Specified by:
setSessionTimeout
in interfaceHttpSessionManager
- Parameters:
sessionTimeout
- the timeout.
-
setSessionTrackingModes
Description copied from interface:HttpSessionManager
Set the session tracking modes.- Specified by:
setSessionTrackingModes
in interfaceHttpSessionManager
- Parameters:
sessionTrackingModes
- the session tracking modes.
-
setWebApplication
Description copied from interface:HttpSessionManager
Set the web application.- Specified by:
setWebApplication
in interfaceHttpSessionManager
- Parameters:
webApplication
- the web application.
-
requestInitialized
public void requestInitialized(jakarta.servlet.ServletRequestEvent event) - Specified by:
requestInitialized
in interfacejakarta.servlet.ServletRequestListener
-
requestDestroyed
public void requestDestroyed(jakarta.servlet.ServletRequestEvent event) - Specified by:
requestDestroyed
in interfacejakarta.servlet.ServletRequestListener
-
setAttribute
- Specified by:
setAttribute
in interfacejakarta.servlet.SessionCookieConfig
-
getAttribute
- Specified by:
getAttribute
in interfacejakarta.servlet.SessionCookieConfig
-
getAttributes
- Specified by:
getAttributes
in interfacejakarta.servlet.SessionCookieConfig
-