Package org.silverpeas.bridge
Class SafeSessionManager
java.lang.Object
org.silverpeas.bridge.SafeSessionManager
This class allows handling a session safely against the different request calls.
Some synchronized access are performed around session creation and session attribute accesses.
- Author:
- silveryocha
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<T> TgetAttribute(String attributeName, Class<T> aClass) Gets the specified attribute value from the session.<T> TgetAttribute(String attributeName, Class<T> aClass, T defaultValue) Gets the specified attribute value from the session.<T> TremoveAttribute(String attributeName, Class<T> aClass) Removes from the session the specified attribute.<T> voidsetAttribute(String attributeName, T value) Sets the specified attribute value into the session.
-
Constructor Details
-
SafeSessionManager
public SafeSessionManager(jakarta.servlet.http.HttpServletRequest request)
-
-
Method Details
-
getAttribute
Gets the specified attribute value from the session.If the session does not exists, it is not created.
If no value exists, null is returned.
- Type Parameters:
T- the type of the value.- Parameters:
attributeName- the name of the attribute to fetch.aClass- the class of the value fetched.- Returns:
- the value if any, null otherwise.
-
getAttribute
Gets the specified attribute value from the session.If the session does not exists, it is not created.
If no value exists, default one is returned.
- Type Parameters:
T- the type of the value.- Parameters:
attributeName- the name of the attribute to fetch.aClass- the class of the value fetched.defaultValue- default value of no value fetched from session.- Returns:
- the value if any, default value otherwise.
-
setAttribute
Sets the specified attribute value into the session.If the session does not exist, it is created.
- Type Parameters:
T- the type of the value.- Parameters:
attributeName- the name of the attribute to fetch.value- the value to put.
-
removeAttribute
Removes from the session the specified attribute.If the session does not exist, nothing is performed.
- Type Parameters:
T- the type of the value.- Parameters:
attributeName- the name of the attribute to fetch.aClass- the class of the value fetched.- Returns:
- the removed value if any, null otherwise.
-