Class ProxiedSession

  • All Implemented Interfaces:
    Session
    Direct Known Subclasses:
    ImmutableProxiedSession

    public class ProxiedSession
    extends Object
    implements Session
    Simple Session implementation that immediately delegates all corresponding calls to an underlying proxied session instance.

    This class is mostly useful for framework subclassing to intercept certain Session calls and perform additional logic.
    Since:
    0.9
    • Field Detail

      • delegate

        protected final Session delegate
        The proxied instance
    • Constructor Detail

      • ProxiedSession

        public ProxiedSession(Session target)
        Constructs an instance that proxies the specified target. Subclasses may access this target via the protected final 'delegate' attribute, i.e. this.delegate.
        Parameters:
        target - the specified target Session to proxy.
    • Method Detail

      • getId

        public Serializable getId()
        Immediately delegates to the underlying proxied session.
        Specified by:
        getId in interface Session
        Returns:
        The unique identifier assigned to the session upon creation.
      • getStartTimestamp

        public Date getStartTimestamp()
        Immediately delegates to the underlying proxied session.
        Specified by:
        getStartTimestamp in interface Session
        Returns:
        The time the system created the session.
      • getLastAccessTime

        public Date getLastAccessTime()
        Immediately delegates to the underlying proxied session.
        Specified by:
        getLastAccessTime in interface Session
        Returns:
        The time the user last interacted with the system.
        See Also:
        Session.touch()
      • getTimeout

        public long getTimeout()
                        throws InvalidSessionException
        Immediately delegates to the underlying proxied session.
        Specified by:
        getTimeout in interface Session
        Returns:
        the time in milliseconds the session may remain idle before expiring.
        Throws:
        InvalidSessionException - if the session has been stopped or expired prior to calling this method.
      • setTimeout

        public void setTimeout(long maxIdleTimeInMillis)
                        throws InvalidSessionException
        Immediately delegates to the underlying proxied session.
        Specified by:
        setTimeout in interface Session
        Parameters:
        maxIdleTimeInMillis - the time in milliseconds that the session may remain idle before expiring.
        Throws:
        InvalidSessionException - if the session has been stopped or expired prior to calling this method.
      • getHost

        public String getHost()
        Immediately delegates to the underlying proxied session.
        Specified by:
        getHost in interface Session
        Returns:
        the host name or IP string of the host that originated this session, or null if the host address is unknown.
      • getAttributeKeys

        public Collection<Object> getAttributeKeys()
                                            throws InvalidSessionException
        Immediately delegates to the underlying proxied session.
        Specified by:
        getAttributeKeys in interface Session
        Returns:
        the keys of all attributes stored under this session, or an empty collection if there are no session attributes.
        Throws:
        InvalidSessionException - if this session has stopped or expired prior to calling this method.
      • getAttribute

        public Object getAttribute(Object key)
                            throws InvalidSessionException
        Immediately delegates to the underlying proxied session.
        Specified by:
        getAttribute in interface Session
        Parameters:
        key - the unique name of the object bound to this session
        Returns:
        the object bound under the specified key name or null if there is no object bound under that name.
        Throws:
        InvalidSessionException - if this session has stopped or expired prior to calling this method.
      • setAttribute

        public void setAttribute(Object key,
                                 Object value)
                          throws InvalidSessionException
        Immediately delegates to the underlying proxied session.
        Specified by:
        setAttribute in interface Session
        Parameters:
        key - the name under which the value object will be bound in this session
        value - the object to bind in this session.
        Throws:
        InvalidSessionException - if this session has stopped or expired prior to calling this method.
      • removeAttribute

        public Object removeAttribute(Object key)
                               throws InvalidSessionException
        Immediately delegates to the underlying proxied session.
        Specified by:
        removeAttribute in interface Session
        Parameters:
        key - the name uniquely identifying the object to remove
        Returns:
        the object removed or null if there was no object bound under the name key.
        Throws:
        InvalidSessionException - if this session has stopped or expired prior to calling this method.