Package fr.paris.lutece.util.http
Class SessionAttributeCache
java.lang.Object
fr.paris.lutece.util.http.SessionAttributeCache
Reads session attributes once per request.
With a distributed session (OpenLiberty sessionCache over Hazelcast), every getAttribute is a network call, including for an absent attribute (an anonymous user has no Lutece user, no selected locale...). The services called several times while building a page (current user, locale, base URL) read their attribute through this cache: the values read, absent ones included, are kept in a request attribute for the session of the request. The attributes must be written through this class too, so that the requests reading them afterwards see the new value.
-
Method Summary
Modifier and TypeMethodDescriptionstatic ObjectgetAttribute(jakarta.servlet.http.HttpServletRequest request, String strName) Gets an attribute of the session of the request, read once per requeststatic voidremoveAttribute(jakarta.servlet.http.HttpServletRequest request, String strName) Removes an attribute of the session of the request, if there is a sessionstatic voidsetAttribute(jakarta.servlet.http.HttpServletRequest request, String strName, Object value) Sets an attribute of the session of the request (created if needed)
-
Method Details
-
getAttribute
Gets an attribute of the session of the request, read once per request- Parameters:
request- The requeststrName- The attribute name- Returns:
- the attribute value, or null if there is no session or no such attribute
-
setAttribute
public static void setAttribute(jakarta.servlet.http.HttpServletRequest request, String strName, Object value) Sets an attribute of the session of the request (created if needed)- Parameters:
request- The requeststrName- The attribute namevalue- The value, null to remove the attribute
-
removeAttribute
Removes an attribute of the session of the request, if there is a session- Parameters:
request- The requeststrName- The attribute name
-