org.barracudamvc.core.util.http
Class SessionServices

java.lang.Object
  extended byorg.barracudamvc.plankton.http.SessionServices
      extended byorg.barracudamvc.core.util.http.SessionServices

public class SessionServices
extends SessionServices

This class defines a convenience method to get the session and set the timeout at the same time. It also provides a mechanism to easily cache objects in the session by Reference (which allows them to automatically be removed from the session if the system starts running low on memory)


Field Summary
 
Fields inherited from class org.barracudamvc.plankton.http.SessionServices
KEY, logger
 
Constructor Summary
SessionServices()
           
 
Method Summary
static Object getObjectFromCache(ControlEventContext context, Object key, ReferenceFactory factory)
          This method retrieves the session from the Context, and then looks for an object in the session based on a given key.
static javax.servlet.http.HttpSession getSession(ViewContext vc)
          get the session from the view context (it will automatically extract the event context and cast it to ControlEventContext for you, then retrieve the request from there and use that to get the session info).
static javax.servlet.http.HttpSession getSession(ViewContext vc, boolean create)
          get the session from the view context (allowing you to specify whether or not to create it)
static javax.servlet.http.HttpSession getSession(ViewContext vc, boolean create, Integer timeout)
          get the session from the view context (allowing you to specify whether or not to create it).
 
Methods inherited from class org.barracudamvc.plankton.http.SessionServices
getObjectFromCache, getSession, getSession, getSession
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SessionServices

public SessionServices()
Method Detail

getSession

public static javax.servlet.http.HttpSession getSession(ViewContext vc)
get the session from the view context (it will automatically extract the event context and cast it to ControlEventContext for you, then retrieve the request from there and use that to get the session info). If no session exists it will create it for us. Ensures that the timeout is set to DEFAULT_TIMEOUT.

Parameters:
vc - the ViewContext
Returns:
the users session

getSession

public static javax.servlet.http.HttpSession getSession(ViewContext vc,
                                                        boolean create)
get the session from the view context (allowing you to specify whether or not to create it)

Parameters:
vc - the ViewContext
create - if true, the session will be created if it does not already exist
Returns:
the users session (may be null if the session does not yet exist and create is false)

getSession

public static javax.servlet.http.HttpSession getSession(ViewContext vc,
                                                        boolean create,
                                                        Integer timeout)
get the session from the view context (allowing you to specify whether or not to create it). If the session exists, it will set the default timeout for us.

Parameters:
vc - the ViewContext
create - if true, the session will be created if it does not already exist
timeout - the default timeout value (null indicates do not set)
Returns:
the users session (may be null if the session does not yet exist and create is false)

getObjectFromCache

public static Object getObjectFromCache(ControlEventContext context,
                                        Object key,
                                        ReferenceFactory factory)
This method retrieves the session from the Context, and then looks for an object in the session based on a given key. If the object is not present, it will be created using the ReferenceFactory and cached in session for future use.

Parameters:
context - the ControlEventContext
key - the key that identifies this object
factory - the ReferenceFactory used to create the object
Returns:
the object from the cache


Copyright © 2004 BarracudaMVC.org All Rights Reserved.