atg.nucleus
Class RequestScopeManager

java.lang.Object
  extended by atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
      extended by atg.nucleus.GenericService
          extended by atg.nucleus.GenericContext
              extended by atg.nucleus.RequestScopeManager
All Implemented Interfaces:
atg.naming.AbsoluteNameable, NameContext, NameContextBindingEventSource, NameContextBindingListener, atg.naming.NameContextCreator, NameContextElement, atg.naming.NameContextParentable, atg.naming.NameContextPreBindingEventSource, NameResolver, AdminableService, atg.nucleus.ConfigurationLockRegistry, atg.nucleus.Configured, ApplicationLogging, atg.nucleus.logging.ApplicationLoggingSender, atg.nucleus.logging.TraceApplicationLogging, VariableArgumentApplicationLogging, ComponentNameResolver, atg.nucleus.ScopeManager, Service, ServiceListener, Schedulable, java.util.EventListener, javax.servlet.ServletContext

public class RequestScopeManager
extends GenericContext
implements Schedulable, atg.nucleus.ScopeManager

A RequestScopeManager manages a set of hierarchies that are meant to hold "request-scoped" objects. Each hierarchy is associated with a key. One can ask for the hierarchy corresponding to a specified key, which will return or create the Context at the top of that hierarchy.

In normal use, a server will spin off a number of threads that will handle requests. Those threads will each have a request object which is used as the key for its request scope.


Nested Class Summary
 
Nested classes/interfaces inherited from class atg.nucleus.GenericContext
GenericContext.ConcurrencyModel
 
Field Summary
static java.lang.String CLASS_VERSION
          Class version string
 
Fields inherited from class atg.nucleus.GenericService
SERVICE_INFO_KEY
 
Fields inherited from interface atg.nucleus.logging.TraceApplicationLogging
DEFAULT_LOG_TRACE_STATUS
 
Fields inherited from interface atg.nucleus.logging.ApplicationLogging
DEFAULT_LOG_DEBUG_STATUS, DEFAULT_LOG_ERROR_STATUS, DEFAULT_LOG_INFO_STATUS, DEFAULT_LOG_WARNING_STATUS
 
Constructor Summary
RequestScopeManager()
          Constructs a new blank RequestScopeManager
 
Method Summary
 boolean canReferenceOtherScope(atg.nucleus.ScopeManager pScopeManager)
           
 void doStartService()
          This is called after a Service has been created, placed into the naming hierarchy, and initialized with its configured property values.
 void doStopService()
          This is called when a Service is required to shut down.
 int generateId()
          Generates a new id and returns it.
 GenericContext getContext(java.lang.Object pKey)
          Deprecated.  
 GenericContext getContext(java.lang.Object pKey, int pId)
          Returns the GenericContext for the given Key and id
 Schedule getLostRequestScopeSchedule()
           
 java.lang.String getManagedScopeName()
           
 int getNumSavedRequestScopes()
          Read-only property which returns the number of request scopes that we are currently holding onto for pending redirects.
 int getRequestScopeExpirationMilliseconds()
           
 NameContext getRootContextForRequest(DynamoHttpServletRequest pRequest)
          Get the root reqwuest scope for the specified request.
 GenericContext getSavedRequestScope(java.lang.Object pKey, int pId, java.lang.String pSessionId)
          Returns the saved request scope, while also removing it from the saved store.
 boolean getSaveRequestScopeOnRedirect()
           
 Scheduler getScheduler()
          Returns the Scheduler used to run the expiration and swapping checks.
 boolean isInheritsEffectiveScope()
           
 void performScheduledTask(Scheduler pScheduler, ScheduledJob pJob)
          This is called once for the minimum timeout specified by save requestScope.
 int readId()
           
 boolean removeContext(java.lang.Object pKey)
          Removes the request context object stored for the key specified
 int saveRequestScope(java.lang.Object pKey, java.lang.String pSessionId)
          Save a request scope, returning an integer id with which this request scope can later be reclaimed.
 void setLostRequestScopeSchedule(Schedule pLostRequestScopeSchedule)
          Sets the property LostRequestScopeSchedule.
 void setRequestScopeExpirationMilliseconds(int pRequestScopeExpirationMilliseconds)
          Sets the property RequestScopeExpirationMilliseconds.
 void setSaveRequestScopeOnRedirect(boolean pSaveRequestScopeOnRedirect)
          Sets the property SaveRequestScopeOnRedirect.
 void setScheduler(Scheduler pScheduler)
          Sets the Scheduler used to run the expiration and swapping checks.
 
Methods inherited from class atg.nucleus.GenericContext
addNameContextBindingListener, addNameContextPreBindingListener, clearElementLock, complainIfComponentAlreadyHasParentNameContext, createChildNameContext, getAttribute, getAttributeNames, getConfigurationLock, getContext, getContextPath, getDocumentRoot, getElement, getElementLock, getInitParameter, getInitParameterNames, getMajorVersion, getMimeType, getMimeTyper, getMinorVersion, getNameContextBindingListeners, getNameContextPreBindingListeners, getNamedDispatcher, getPendingElement, getRealPath, getRequestDispatcher, getResource, getResourceAsStream, getResourcePaths, getServerInfo, getServlet, getServletContextName, getServletNames, getServlets, isElementBound, isOptimizedForConcurrency, listElement, listElementNames, listElements, log, log, log, notifyAddedObject, notifyRemovedObject, preNotifyAddedObject, preNotifyRemovedObject, putElement, putPendingElement, removeAttribute, removeElement, removeNameContextBindingListener, removeNameContextPreBindingListener, removePendingElement, setAttribute, setDocumentRoot, setMimeTyper, startService
 
Methods inherited from class atg.nucleus.GenericService
addLogListener, createAdminServlet, getAbsoluteName, getAdminServlet, getAdminServletOutputStreamEncoding, getLoggingForVlogging, getLogListenerCount, getLogListeners, getName, getNameContext, getNucleus, getRoot, getServiceConfiguration, getServiceInfo, isAdminServletUseServletOutputStream, isLoggingDebug, isLoggingError, isLoggingInfo, isLoggingTrace, isLoggingWarning, isRunning, logDebug, logDebug, logDebug, logError, logError, logError, logInfo, logInfo, logInfo, logTrace, logTrace, logTrace, logWarning, logWarning, logWarning, nameContextElementBound, nameContextElementUnbound, removeLogListener, reResolveThis, resolveName, resolveName, resolveName, resolveName, sendLogEvent, setAdminServletOutputStreamEncoding, setAdminServletUseServletOutputStream, setLoggingDebug, setLoggingError, setLoggingInfo, setLoggingTrace, setLoggingWarning, setNucleus, setServiceInfo, stopService
 
Methods inherited from class atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
vlogDebug, vlogDebug, vlogDebug, vlogDebug, vlogDebugTrace, vlogError, vlogError, vlogError, vlogError, vlogInfo, vlogInfo, vlogInfo, vlogInfo, vlogTrace, vlogTrace, vlogTrace, vlogTrace, vlogWarning, vlogWarning, vlogWarning, vlogWarning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface atg.naming.NameContextElement
getName, getNameContext
 
Methods inherited from interface atg.naming.NameContextBindingListener
nameContextElementBound, nameContextElementUnbound
 

Field Detail

CLASS_VERSION

public static final java.lang.String CLASS_VERSION
Class version string

See Also:
Constant Field Values
Constructor Detail

RequestScopeManager

public RequestScopeManager()
Constructs a new blank RequestScopeManager

Method Detail

doStartService

public void doStartService()
                    throws ServiceException
Description copied from class: GenericService
This is called after a Service has been created, placed into the naming hierarchy, and initialized with its configured property values. The Service should override this method to start any processes it requires.

Overrides:
doStartService in class GenericService
Throws:
ServiceException - if the Service had a problem starting up

doStopService

public void doStopService()
                   throws ServiceException
Description copied from class: GenericContext
This is called when a Service is required to shut down. The Service should respond by stopping any processes that it has started. This will also stop any services contained by this service.

Overrides:
doStopService in class GenericContext
Throws:
ServiceException - if the Service had a problem shutting down

getScheduler

public Scheduler getScheduler()
Returns the Scheduler used to run the expiration and swapping checks.


setScheduler

public void setScheduler(Scheduler pScheduler)
Sets the Scheduler used to run the expiration and swapping checks.


setLostRequestScopeSchedule

public void setLostRequestScopeSchedule(Schedule pLostRequestScopeSchedule)
Sets the property LostRequestScopeSchedule.


getLostRequestScopeSchedule

public Schedule getLostRequestScopeSchedule()
Returns:
The value of the property LostRequestScopeSchedule.

setRequestScopeExpirationMilliseconds

public void setRequestScopeExpirationMilliseconds(int pRequestScopeExpirationMilliseconds)
Sets the property RequestScopeExpirationMilliseconds. This determines how long we hold onto request scopes after we issue a redirect before they are expired. The default is 5 minutes. As soon as a redirect does come in, its request scope is reattached.


getRequestScopeExpirationMilliseconds

public int getRequestScopeExpirationMilliseconds()
Returns:
The value of the property RequestScopeExpirationMilliseconds.

setSaveRequestScopeOnRedirect

public void setSaveRequestScopeOnRedirect(boolean pSaveRequestScopeOnRedirect)
Sets the property SaveRequestScopeOnRedirect.


getSaveRequestScopeOnRedirect

public boolean getSaveRequestScopeOnRedirect()
Returns:
The value of the property SaveRequestScopeOnRedirect.

getNumSavedRequestScopes

public int getNumSavedRequestScopes()
Read-only property which returns the number of request scopes that we are currently holding onto for pending redirects.


generateId

public int generateId()
Generates a new id and returns it.


readId

public int readId()

getContext

public GenericContext getContext(java.lang.Object pKey)
Deprecated. 

Returns the GenericContext for the given Key.


getContext

public GenericContext getContext(java.lang.Object pKey,
                                 int pId)
Returns the GenericContext for the given Key and id


saveRequestScope

public int saveRequestScope(java.lang.Object pKey,
                            java.lang.String pSessionId)
Save a request scope, returning an integer id with which this request scope can later be reclaimed. If a session id is provides, the request scope can only be retrieved from the same session (this is a security measure).


getSavedRequestScope

public GenericContext getSavedRequestScope(java.lang.Object pKey,
                                           int pId,
                                           java.lang.String pSessionId)
Returns the saved request scope, while also removing it from the saved store.


getManagedScopeName

public java.lang.String getManagedScopeName()
Specified by:
getManagedScopeName in interface atg.nucleus.ScopeManager

performScheduledTask

public void performScheduledTask(Scheduler pScheduler,
                                 ScheduledJob pJob)
This is called once for the minimum timeout specified by save requestScope. We check for request scopes that should be culled because they have expired and we remove them. This should typically not find too many of them because it is rare that a redirect fails to return to the server.

Specified by:
performScheduledTask in interface Schedulable
Parameters:
pScheduler - calling the job
pJob - the ScheduledJob

removeContext

public boolean removeContext(java.lang.Object pKey)
Removes the request context object stored for the key specified

Returns:
true if the element existed and was removed, false otherwise.

getRootContextForRequest

public NameContext getRootContextForRequest(DynamoHttpServletRequest pRequest)
Get the root reqwuest scope for the specified request.

Specified by:
getRootContextForRequest in interface atg.nucleus.ScopeManager
Parameters:
pRequest - the request to access.

canReferenceOtherScope

public boolean canReferenceOtherScope(atg.nucleus.ScopeManager pScopeManager)
Specified by:
canReferenceOtherScope in interface atg.nucleus.ScopeManager

isInheritsEffectiveScope

public boolean isInheritsEffectiveScope()
Specified by:
isInheritsEffectiveScope in interface atg.nucleus.ScopeManager