Class SessionCacheAccessor

  • All Implemented Interfaces:
    org.silverpeas.kernel.cache.service.CacheAccessor<org.silverpeas.kernel.cache.model.SimpleCache>

    public class SessionCacheAccessor
    extends Object
    implements org.silverpeas.kernel.cache.service.CacheAccessor<org.silverpeas.kernel.cache.model.SimpleCache>
    Accessor to a session scoped cache.

    A session cache is a cache whose lifetime span over the session of a user in Silverpeas. As such, a session cache belongs to a given user and should be initialized at the user session opening.

    Author:
    mmoquillon
    • Constructor Detail

      • SessionCacheAccessor

        public SessionCacheAccessor()
    • Method Detail

      • newSessionCache

        public org.silverpeas.kernel.cache.model.SimpleCache newSessionCache​(User user)
        Creates a new session cache for the specified user and sets it as the cache of the current session.
        Parameters:
        user - a Silverpeas user for which a session has to be opened.
        Returns:
        the session cache.
      • setCurrentSessionCache

        public void setCurrentSessionCache​(org.silverpeas.kernel.cache.model.SimpleCache sessionCache)
        Sets the specified session cache as the current one. This is a technical method that shouldn't be used by business operations. It could be removed in the future according to the evolution of the implementation of the cache sessions.
        Parameters:
        sessionCache - the cache session to set.
        Throws:
        IllegalArgumentException - if the specified cache isn't a session cache already initialized by the session cache management mechanism.
      • getCurrentSessionCache

        public org.silverpeas.kernel.cache.model.SimpleCache getCurrentSessionCache()
        Gets the cache mapped with the current user session.
        Returns:
        the current session cache.
      • getUser

        public User getUser​(org.silverpeas.kernel.cache.model.SimpleCache sessionCache)
        Gets the user for whom the specified session cache has been created.
        Parameters:
        sessionCache - a session cache.
        Returns:
        the user to whom the specified session cache belongs.
        Throws:
        IllegalArgumentException - if the specified cache isn't a session cache correctly initialized.
      • getCache

        public org.silverpeas.kernel.cache.model.SimpleCache getCache()
        Gets the cache mapped with the current user session.
        Specified by:
        getCache in interface org.silverpeas.kernel.cache.service.CacheAccessor<org.silverpeas.kernel.cache.model.SimpleCache>
        Returns:
        the current session cache.
        See Also:
        getCurrentSessionCache()