Class SessionAttributeCache

java.lang.Object
fr.paris.lutece.util.http.SessionAttributeCache

public final class SessionAttributeCache extends Object
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 Type
    Method
    Description
    static Object
    getAttribute(jakarta.servlet.http.HttpServletRequest request, String strName)
    Gets an attribute of the session of the request, read once per request
    static void
    removeAttribute(jakarta.servlet.http.HttpServletRequest request, String strName)
    Removes an attribute of the session of the request, if there is a session
    static void
    setAttribute(jakarta.servlet.http.HttpServletRequest request, String strName, Object value)
    Sets an attribute of the session of the request (created if needed)

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • getAttribute

      public static Object getAttribute(jakarta.servlet.http.HttpServletRequest request, String strName)
      Gets an attribute of the session of the request, read once per request
      Parameters:
      request - The request
      strName - 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 request
      strName - The attribute name
      value - The value, null to remove the attribute
    • removeAttribute

      public static void removeAttribute(jakarta.servlet.http.HttpServletRequest request, String strName)
      Removes an attribute of the session of the request, if there is a session
      Parameters:
      request - The request
      strName - The attribute name