agonism.dovetail.site
Class DummyRequestContext

java.lang.Object
  |
  +--agonism.dovetail.site.DummyRequestContext
All Implemented Interfaces:
IRequestContext

public class DummyRequestContext
extends java.lang.Object
implements IRequestContext


Inner Class Summary
static class DummyRequestContext.Location
           
 
Constructor Summary
DummyRequestContext()
           
DummyRequestContext(java.util.Hashtable parameters, java.util.Hashtable cookies, java.util.Hashtable session, java.io.PrintWriter writer)
           
DummyRequestContext(java.util.Hashtable parameters, java.util.Hashtable cookies, java.io.PrintWriter writer)
           
DummyRequestContext(java.io.PrintWriter writer)
           
 
Method Summary
 java.lang.String encodeURL(java.lang.String url)
          Encode a URL with the SessionID.
 void forward(Page page)
          Forward a request to a new Page.
 void freeConnection()
          Free the database connection obtained from the getConnection() method.
 java.sql.Connection getConnection()
          Get the database connection.
 java.lang.String getCookieValue(java.lang.String name)
          Get the value of a browser cookie.
 java.util.Collection getErrors()
          Get a Collection of all the errors that have occured in this request.
 DummyRequestContext.Location getLocation()
           
 DummyRequestContext.Location getNextLocation()
           
 agonism.dovetail.db.IParameterSource getParameterSource()
          Get an object that implements IParameterSource
 java.lang.String getParameterValue(java.lang.String name)
          Get the value of a request parameter.
 DummyRequestContext.Location getPrevLocation()
           
 java.lang.String getReferer()
          Get the URL that the request was sent from
 java.lang.Object getRequestValue(java.lang.String key)
          Get a value that has been stored in the Request.
 java.lang.Object getSessionValue(java.lang.String key)
          Get a value that has been stored in the Session.
 Site getSite()
          Get the root Site object.
 java.io.PrintWriter getWriter()
          Get the PrintWriter which is writing the response.
 boolean hasBeenRedirected()
           
 void include(Page page)
          Inculde another page in the response for this page.
 void init(Site site)
          Initialize the IRequestContext with a Site.
 DummyRequestContext processRequest(Form submitForm, java.util.Hashtable parameters, java.util.Hashtable cookies)
          Process a form request with a set of form parameters and return a new DummyRequestContext.
 void reportError(RequestError error)
          Report a request processing error.
 void sendRedirect(Link link)
          Redirect the request to a new Link.
 void sendRedirect(Page page)
          Redirect the request to a new Page.
 void sendRedirect(java.lang.String url)
          Redirect the request to a new URL.
 void setFormValue(java.lang.String name, java.lang.Object value)
           
 void setLocation(Page page)
          If the client of the DummyRequestContext is using SQL database connections, setting the Location will help provide better diagnostic information in case the connections are not properly freed.
 void setParameterValue(java.lang.String name, java.lang.String value)
           
 void setParent(IRequestContext context)
          Set the parent context of the DummyRequestContext.
 void setRequestValue(java.lang.String key, java.lang.Object value)
          Put a value into the Request state.
 void setSessionValue(java.lang.String key, java.lang.Object value)
          Put a value into the Session state.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DummyRequestContext

public DummyRequestContext()

DummyRequestContext

public DummyRequestContext(java.io.PrintWriter writer)

DummyRequestContext

public DummyRequestContext(java.util.Hashtable parameters,
                           java.util.Hashtable cookies,
                           java.io.PrintWriter writer)

DummyRequestContext

public DummyRequestContext(java.util.Hashtable parameters,
                           java.util.Hashtable cookies,
                           java.util.Hashtable session,
                           java.io.PrintWriter writer)
Method Detail

processRequest

public DummyRequestContext processRequest(Form submitForm,
                                          java.util.Hashtable parameters,
                                          java.util.Hashtable cookies)
Process a form request with a set of form parameters and return a new DummyRequestContext.

setLocation

public void setLocation(Page page)
If the client of the DummyRequestContext is using SQL database connections, setting the Location will help provide better diagnostic information in case the connections are not properly freed.

getPrevLocation

public DummyRequestContext.Location getPrevLocation()

getLocation

public DummyRequestContext.Location getLocation()

getNextLocation

public DummyRequestContext.Location getNextLocation()

setFormValue

public void setFormValue(java.lang.String name,
                         java.lang.Object value)

setParent

public void setParent(IRequestContext context)
Set the parent context of the DummyRequestContext. If this method is used, it must be called before getConnection() or freeConnection() have been called.

The parent context is used to manage the database Connection of this context. In this way, clients which are using different contexts can share the same connection.


init

public void init(Site site)
Description copied from interface: IRequestContext
Initialize the IRequestContext with a Site.
Specified by:
init in interface IRequestContext

getConnection

public java.sql.Connection getConnection()
Description copied from interface: IRequestContext
Get the database connection. The connection is reference-counted by the IRequestContext, so that all callers will get the same Connection and it is freed once they have all released it using the IRequestContext.freeConnection() method.

Whenever you call this method, you must always pair it with a call to IRequestContext.freeConnection(), otherwise the Connection will not be promptly returned to the connection pool. If you fail to free connections, the ConnectionHelper.finalize() method will write diagnostic information to the WARN log.

Specified by:
getConnection in interface IRequestContext

freeConnection

public void freeConnection()
Description copied from interface: IRequestContext
Free the database connection obtained from the IRequestContext.getConnection() method.

Whenever you call IRequestContext.getConnection(), you must always pair it with a call to IRequestContext.freeConnection(), otherwise the Connection will not be promptly returned to the connection pool. If you fail to free connections, the ConnectionHelper.finalize() method will write diagnostic information to the WARN log.

Specified by:
freeConnection in interface IRequestContext

encodeURL

public java.lang.String encodeURL(java.lang.String url)
Description copied from interface: IRequestContext
Encode a URL with the SessionID.
Specified by:
encodeURL in interface IRequestContext

sendRedirect

public void sendRedirect(Page page)
Description copied from interface: IRequestContext
Redirect the request to a new Page.
Specified by:
sendRedirect in interface IRequestContext

sendRedirect

public void sendRedirect(Link link)
Description copied from interface: IRequestContext
Redirect the request to a new Link.
Specified by:
sendRedirect in interface IRequestContext

sendRedirect

public void sendRedirect(java.lang.String url)
Description copied from interface: IRequestContext
Redirect the request to a new URL.
Specified by:
sendRedirect in interface IRequestContext

hasBeenRedirected

public boolean hasBeenRedirected()
Specified by:
hasBeenRedirected in interface IRequestContext
Following copied from interface: agonism.dovetail.site.IRequestContext
Returns:
true if a sendRedirect method has been invoked on this request.

forward

public void forward(Page page)
Description copied from interface: IRequestContext
Forward a request to a new Page.
Specified by:
forward in interface IRequestContext

include

public void include(Page page)
Description copied from interface: IRequestContext
Inculde another page in the response for this page.
Specified by:
include in interface IRequestContext

getWriter

public java.io.PrintWriter getWriter()
Description copied from interface: IRequestContext
Get the PrintWriter which is writing the response.
Specified by:
getWriter in interface IRequestContext

getSite

public Site getSite()
Description copied from interface: IRequestContext
Get the root Site object.
Specified by:
getSite in interface IRequestContext

getParameterSource

public agonism.dovetail.db.IParameterSource getParameterSource()
Description copied from interface: IRequestContext
Get an object that implements IParameterSource
Specified by:
getParameterSource in interface IRequestContext

setParameterValue

public void setParameterValue(java.lang.String name,
                              java.lang.String value)

getParameterValue

public java.lang.String getParameterValue(java.lang.String name)
Description copied from interface: IRequestContext
Get the value of a request parameter.
Specified by:
getParameterValue in interface IRequestContext

getCookieValue

public java.lang.String getCookieValue(java.lang.String name)
Description copied from interface: IRequestContext
Get the value of a browser cookie.
Specified by:
getCookieValue in interface IRequestContext

getSessionValue

public java.lang.Object getSessionValue(java.lang.String key)
Description copied from interface: IRequestContext
Get a value that has been stored in the Session.
Specified by:
getSessionValue in interface IRequestContext

setSessionValue

public void setSessionValue(java.lang.String key,
                            java.lang.Object value)
Description copied from interface: IRequestContext
Put a value into the Session state. Session state is persisted between requests, and is unique to a user.
Specified by:
setSessionValue in interface IRequestContext

getRequestValue

public java.lang.Object getRequestValue(java.lang.String key)
Description copied from interface: IRequestContext
Get a value that has been stored in the Request.
Specified by:
getRequestValue in interface IRequestContext

setRequestValue

public void setRequestValue(java.lang.String key,
                            java.lang.Object value)
Description copied from interface: IRequestContext
Put a value into the Request state. Request state is stored only within the context of a single request.
Specified by:
setRequestValue in interface IRequestContext

reportError

public void reportError(RequestError error)
Description copied from interface: IRequestContext
Report a request processing error.
Specified by:
reportError in interface IRequestContext

getErrors

public java.util.Collection getErrors()
Description copied from interface: IRequestContext
Get a Collection of all the errors that have occured in this request.
Specified by:
getErrors in interface IRequestContext
Following copied from interface: agonism.dovetail.site.IRequestContext
Returns:
an unmodifiable Collection of RequestError objects.

getReferer

public java.lang.String getReferer()
Description copied from interface: IRequestContext
Get the URL that the request was sent from
Specified by:
getReferer in interface IRequestContext

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object