Class MockSessionStore

  • All Implemented Interfaces:
    ISessionStore

    public class MockSessionStore
    extends Object
    implements ISessionStore
    Session store that holds one session.
    Author:
    Matej Knopp
    • Constructor Detail

      • MockSessionStore

        public MockSessionStore()
        Construct.
    • Method Detail

      • bind

        public void bind​(org.apache.wicket.request.Request request,
                         Session newSession)
        Description copied from interface: ISessionStore
        Adds the provided new session to this facade using the provided request.
        Specified by:
        bind in interface ISessionStore
        Parameters:
        request - The request that triggered making a new session
        newSession - The new session
      • destroy

        public void destroy()
        Description copied from interface: ISessionStore
        Called when the WebApplication is destroyed.
        Specified by:
        destroy in interface ISessionStore
      • getAttribute

        public Serializable getAttribute​(org.apache.wicket.request.Request request,
                                         String name)
        Description copied from interface: ISessionStore
        Gets the attribute value with the given name
        Specified by:
        getAttribute in interface ISessionStore
        Parameters:
        request - the current request
        name - The name of the attribute to store
        Returns:
        The value of the attribute
      • getAttributeNames

        public List<String> getAttributeNames​(org.apache.wicket.request.Request request)
        Specified by:
        getAttributeNames in interface ISessionStore
        Parameters:
        request - the current request
        Returns:
        List of attributes for this session
      • getSessionId

        public String getSessionId​(org.apache.wicket.request.Request request,
                                   boolean create)
        Description copied from interface: ISessionStore
        Get the session id for the provided request. If create is false and the creation of the actual session is deferred, this method should return null to reflect it doesn't have one.
        Specified by:
        getSessionId in interface ISessionStore
        Parameters:
        request - The request
        create - Whether to create an actual session (typically an instance of HttpSession) when not already done so
        Returns:
        The session id for the provided request, possibly null if create is false and the creation of the actual session was deferred
      • invalidate

        public void invalidate​(org.apache.wicket.request.Request request)
        Description copied from interface: ISessionStore
        Invalidates the session.
        Specified by:
        invalidate in interface ISessionStore
        Parameters:
        request - the current request
      • lookup

        public Session lookup​(org.apache.wicket.request.Request request)
        Description copied from interface: ISessionStore
        Retrieves the session for the provided request from this facade.

        This method should return null if it is not bound yet, so that Wicket can recognize that it should create a session and call ISessionStore.bind(Request, Session) right after that.

        Specified by:
        lookup in interface ISessionStore
        Parameters:
        request - The current request
        Returns:
        The session for the provided request or null if the session was not bound
      • removeAttribute

        public void removeAttribute​(org.apache.wicket.request.Request request,
                                    String name)
        Description copied from interface: ISessionStore
        Removes the attribute with the given name.
        Specified by:
        removeAttribute in interface ISessionStore
        Parameters:
        request - the current request
        name - the name of the attribute to remove
      • setAttribute

        public void setAttribute​(org.apache.wicket.request.Request request,
                                 String name,
                                 Serializable value)
        Description copied from interface: ISessionStore
        Adds or replaces the attribute with the given name and value.
        Specified by:
        setAttribute in interface ISessionStore
        Parameters:
        request - the current request
        name - the name of the attribute
        value - the value of the attribute
      • flushSession

        public void flushSession​(org.apache.wicket.request.Request request,
                                 Session session)
        Description copied from interface: ISessionStore
        Flushes the session. Flushing the session generally means setting the attribute with the value of the current session. Some servlet containers use the setAttribute() as a signal that the value is dirty and needs to be replicated. Essentially this call comes down to: String attr=getSessionAttributeName(); Session session=getAttribute(attr); setAttribute(attr, session); If the session is not yet bound it will be.
        Specified by:
        flushSession in interface ISessionStore
        Parameters:
        request - current request
        session - session to be flushed