org.enhydra.barracuda.core.event
Class DefaultEventContext

java.lang.Object
  |
  +--org.enhydra.barracuda.core.event.DefaultEventContext
All Implemented Interfaces:
ControlEventContext, EventContext, StateMap, ViewEventContext

public class DefaultEventContext
extends java.lang.Object
implements ViewEventContext

The context contains information about the event (event, queue, plus request and response info if appropriate). The context also implements StateMap, so you can use it to pass information between event handlers. The scope of the context is only for the duration of an event dispatch cycle (ie. from Http Request to Http Response)

Note that because DefaultEventContext implements ViewEventContext it can safely be cast to its two parent interfaces: EventContext and ControlEventContext. This is in fact what the DefaultEventDispatcher actually does to control access to the appropriate information (ie. a ControlEvent handler should get a reference to an ControlEventContext, NOT an ViewEventContext, since the control handlers shouldn't have access to the HttpServletResponse object.)


Field Summary
protected static org.apache.log4j.Logger logger
           
 
Fields inherited from interface org.enhydra.barracuda.core.event.ViewEventContext
HTTP_SERVLET_RESPONSE
 
Fields inherited from interface org.enhydra.barracuda.core.event.ControlEventContext
HTTP_SERVLET_REQUEST, SERVLET_CONFIG
 
Fields inherited from interface org.enhydra.barracuda.core.event.EventContext
BASE_EVENT, DISPATCH_QUEUE, VIEW_CAPABILITIES
 
Constructor Summary
DefaultEventContext(DispatchQueue queue, ViewCapabilities vc, javax.servlet.ServletConfig config, javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp, HttpResponseEvent defaultResponseEvent)
          Public constructor.
 
Method Summary
 javax.servlet.ServletConfig getConfig()
          Get the associated ServletConfig structure
 BaseEvent getEvent()
          Get the underlying BaseEvent
 DispatchQueue getQueue()
          Get the underlying DispatchQueue
 javax.servlet.http.HttpServletRequest getRequest()
          Get the associated HttpServletRequest
 javax.servlet.http.HttpServletResponse getResponse()
          Get the associated HttpServletResponse
 java.lang.Object getState(java.lang.Object key)
          get a property in this StateMap
 java.util.List getStateKeys()
          get a list of the keys for this StateMap
 java.util.Map getStateValues()
          get a copy of the underlying Map
 ViewCapabilities getViewCapabilities()
          Get the underlying ViewCapabilities
 void persistContext()
          The event context must be able to persist its state in the user's session
 void putState(java.lang.Object key, java.lang.Object val)
          set a property in this StateMap
 java.lang.Object removeState(java.lang.Object key)
          remove a property in this StateMap
 void restoreContext(javax.servlet.http.HttpServletRequest req)
          The event context must also be able to restore state from the user's session.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected static org.apache.log4j.Logger logger
Constructor Detail

DefaultEventContext

public DefaultEventContext(DispatchQueue queue,
                           ViewCapabilities vc,
                           javax.servlet.ServletConfig config,
                           javax.servlet.http.HttpServletRequest req,
                           javax.servlet.http.HttpServletResponse resp,
                           HttpResponseEvent defaultResponseEvent)
Public constructor.

Parameters:
queue - the event dispatch queue
config - the servlet config structure
req - the HttpServletRequest
resp - the HttpServlet Response
defaultResponseEvent - the default response event to be used if none is generated by the control event handlers
Method Detail

getEvent

public BaseEvent getEvent()
Get the underlying BaseEvent

Specified by:
getEvent in interface EventContext
Returns:
the underlying BaseEvent

getQueue

public DispatchQueue getQueue()
Get the underlying DispatchQueue

Specified by:
getQueue in interface EventContext
Returns:
the underlying DispatchQueue

getViewCapabilities

public ViewCapabilities getViewCapabilities()
Get the underlying ViewCapabilities

Specified by:
getViewCapabilities in interface EventContext

getConfig

public javax.servlet.ServletConfig getConfig()
Get the associated ServletConfig structure

Specified by:
getConfig in interface ControlEventContext
Returns:
the associated ServletConfig structure

getRequest

public javax.servlet.http.HttpServletRequest getRequest()
Get the associated HttpServletRequest

Specified by:
getRequest in interface ControlEventContext
Returns:
the associated HttpServletRequest

getResponse

public javax.servlet.http.HttpServletResponse getResponse()
Get the associated HttpServletResponse

Specified by:
getResponse in interface ViewEventContext
Returns:
the associated HttpServletResponse

persistContext

public void persistContext()
The event context must be able to persist its state in the user's session

Specified by:
persistContext in interface EventContext

restoreContext

public void restoreContext(javax.servlet.http.HttpServletRequest req)
The event context must also be able to restore state from the user's session. Calling this method effectively removes the state from the session.


putState

public void putState(java.lang.Object key,
                     java.lang.Object val)
set a property in this StateMap

Specified by:
putState in interface StateMap
Parameters:
key - the state key object
val - the state value object

getState

public java.lang.Object getState(java.lang.Object key)
get a property in this StateMap

Specified by:
getState in interface StateMap
Parameters:
key - the state key object
Returns:
the value for the given key

removeState

public java.lang.Object removeState(java.lang.Object key)
remove a property in this StateMap

Specified by:
removeState in interface StateMap
Parameters:
key - the key object
Returns:
the object which was removed

getStateKeys

public java.util.List getStateKeys()
get a list of the keys for this StateMap

Specified by:
getStateKeys in interface StateMap
Returns:
a list the keys for this StateMap

getStateValues

public java.util.Map getStateValues()
get a copy of the underlying Map

Specified by:
getStateValues in interface StateMap
Returns:
a copy of the underlying state Map


Copyright © 2001 Enhydra.org