org.barracudamvc.core.util.http
Class ContextServices

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

public class ContextServices
extends ContextServices

This class defines a convenience method to get the servlet context. 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.ContextServices
KEY, logger
 
Constructor Summary
ContextServices()
           
 
Method Summary
static javax.servlet.ServletContext getContext(ControlEventContext ec)
          get the servlet context from a ControlEventContext
static javax.servlet.ServletContext getContext(ViewContext vc)
          get the servlet context from a ViewContext
static Object getObjectFromCache(ControlEventContext ec, Object key, ReferenceFactory factory)
          This method retrieves the servlet context from a ControlEventContext, and then looks for an object in the servlet context based on a given key.
static Object getObjectFromCache(ViewContext vc, Object key, ReferenceFactory factory)
          This method retrieves the servlet context from a ViewContext, and then looks for an object in the servlet context based on a given key.
 
Methods inherited from class org.barracudamvc.plankton.http.ContextServices
getObjectFromCache
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ContextServices

public ContextServices()
Method Detail

getContext

public static javax.servlet.ServletContext getContext(ViewContext vc)
get the servlet context from a ViewContext

Parameters:
vc - the ControlEventContext object
Returns:
the users session

getContext

public static javax.servlet.ServletContext getContext(ControlEventContext ec)
get the servlet context from a ControlEventContext

Parameters:
ec - the ControlEventContext object
Returns:
the users session

getObjectFromCache

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

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

getObjectFromCache

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

Parameters:
ec - 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.