Class SessionFacade

java.lang.Object
org.javalite.activeweb.SessionFacade
All Implemented Interfaces:
Map<String,​Object>

public class SessionFacade extends Object implements Map<String,​Object>
Facade to HTTP session.
Author:
Igor Polevoy
  • Constructor Details

    • SessionFacade

      public SessionFacade()
  • Method Details

    • exists

      public boolean exists()
    • id

      public String id()
      Returns a session ID from underlying session.
      Returns:
      a session ID from underlying session, or null if session does not exist.
    • get

      public Object get(Object key)
      Retrieve object from session.
      Specified by:
      get in interface Map<String,​Object>
      Parameters:
      key - name of object.
      Returns:
      named object.
    • get

      public <T> T get(String name, Class<T> type)
      Convenience method, will do internal check for null and then cast. Will throw ClassCastException only in case the object in session is different type than expected.
      Parameters:
      name - name of session object.
      type - expected type
      Returns:
      object in session, or null if not found.
    • remove

      public Object remove(Object key)
      Removes object from session.
      Specified by:
      remove in interface Map<String,​Object>
      Parameters:
      key - name of object
    • getCreationTime

      public long getCreationTime()
      Returns time when session was created.
      Returns:
      time when session was created or -1 if session is not exists.
    • invalidate

      public void invalidate()
      Invalidates current session. All attributes are discarded.
    • setTimeToLive

      public void setTimeToLive(int seconds)
      Sets time to live in seconds.
      Parameters:
      seconds - time to live.
    • names

      public String[] names()
      Returns names of current attributes as a list.
      Returns:
      names of current attributes as a list.
    • getId

      public String getId()
      returns ID of the underlying session
      Returns:
      ID of the underlying session
    • destroy

      public void destroy()
      Destroys current session
    • size

      public int size()
      Specified by:
      size in interface Map<String,​Object>
    • isEmpty

      public boolean isEmpty()
      Specified by:
      isEmpty in interface Map<String,​Object>
    • containsKey

      public boolean containsKey(Object key)
      Specified by:
      containsKey in interface Map<String,​Object>
    • containsValue

      public boolean containsValue(Object value)
      Specified by:
      containsValue in interface Map<String,​Object>
    • put

      public Object put(String key, Object value)
      Add object to a session.
      Specified by:
      put in interface Map<String,​Object>
      Parameters:
      key - name of object
      value - object reference.
    • putAll

      public void putAll(Map m)
      Specified by:
      putAll in interface Map<String,​Object>
    • clear

      public void clear()
      Specified by:
      clear in interface Map<String,​Object>
    • keySet

      public Set<String> keySet()
      Specified by:
      keySet in interface Map<String,​Object>
    • values

      public Collection<Object> values()
      Specified by:
      values in interface Map<String,​Object>
    • entrySet

      public Set<Map.Entry<String,​Object>> entrySet()
      Specified by:
      entrySet in interface Map<String,​Object>