org.benow.web.servlet
Class RequestHandlerThread

java.lang.Object
  extended by java.lang.Thread
      extended by org.benow.java.augment.AugmentedThread
          extended by org.benow.security.user.SecureThread
              extended by org.benow.web.servlet.RequestHandlerThread
All Implemented Interfaces:
java.lang.Runnable

public class RequestHandlerThread
extends org.benow.security.user.SecureThread


Nested Class Summary
 class RequestHandlerThread.OnRequestHandlerFinishEvent
           
 
Nested classes/interfaces inherited from class java.lang.Thread
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
static java.text.SimpleDateFormat FORMAT_LAST_MODIFIED
           
static java.lang.String HEADERS
           
static java.lang.String OUT
           
static java.lang.String PARAMS
           
static java.lang.String RESPONSE
           
static java.lang.String SESSION
           
static java.lang.String SESSION_USER
           
static java.lang.String URL
           
 
Fields inherited from class org.benow.security.user.SecureThread
USER
 
Fields inherited from class org.benow.java.augment.AugmentedThread
error
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
RequestHandlerThread(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, QueryParams params, java.lang.String url)
           
RequestHandlerThread(java.lang.Runnable requestHandler, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, QueryParams params, java.lang.String url)
           
 
Method Summary
 void _addCookie(javax.servlet.http.Cookie cookie)
           
 void _addLoginCookie(org.benow.security.user.User user)
           
protected  void _augment(java.lang.String name, java.lang.Object obj)
           
protected  void _forget(java.lang.String... keys)
           
protected  java.lang.Object _getAugment(java.lang.String name)
           
protected  javax.servlet.http.HttpSession _getSession()
           
protected  void _logout()
           
protected  void _setUser(org.benow.security.user.User user)
           
static void addCookie(javax.servlet.http.Cookie cookie)
           
static void addHeader(java.lang.String name, java.lang.String value)
          Add a header to be added to the response before content delivery.
static void addLastModifiedHeader(java.util.Date lastModified)
          Convenience method to add a last modified header (and an eTag header) to the response associated with the current thread.
static void addLoginCookie(org.benow.security.user.User user)
           
static void addOnFinishHandler(org.benow.java.notify.Listener listener)
           
static void addResponseHeader(java.lang.String name, java.lang.String val)
           
static void addXSLParam(java.lang.String name, java.lang.Object value)
           
 void cache(java.lang.String name, java.lang.Object obj)
          Cache object in memory without touching session
static void clearSessionMessage()
           
 java.lang.Object fetchFromCache(java.lang.String name)
          Fetch object from memory not session
static java.util.List<AcceptedLanguage> getAcceptedLanguages()
           
static java.util.Map<java.lang.String,java.lang.String> getAddedHeaders()
          Gets headers that have been added.
static javax.servlet.http.Cookie getCookie(java.lang.String name)
           
static QueryParams getParams()
           
static javax.servlet.http.HttpServletRequest getRequest()
           
static javax.servlet.http.HttpServletResponse getResponse()
           
static java.io.OutputStream getResultStream()
           
static javax.servlet.http.HttpSession getSession()
           
static java.lang.Object getSessionAttributeAssert(java.lang.String attrName)
          Gets a value from the session, throwing a runtime exception if it is not present.
static java.net.URL getURL()
           
static java.lang.String getURLString()
           
static java.util.Map<java.lang.String,java.lang.Object> getXSLParams()
           
static boolean isChrome()
           
static boolean isCurrent()
           
static boolean isIE()
           
static boolean isServiceClientConnect()
           
static void logout()
           
static int manageSpanning(java.lang.String spanType, int spanning)
           
static void removeCookie(java.lang.String cookieName)
           
 void run()
           
static void setSessionMessage(java.lang.String msg)
           
 void startAndWait()
           
static java.lang.Object takeSessionAttributeAssert(java.lang.String attrName)
          Take an attribute by name, removing from session.
static java.lang.String takeSessionMessage()
           
 
Methods inherited from class org.benow.security.user.SecureThread
_getUser, assertPermission, getUser, setUser
 
Methods inherited from class org.benow.java.augment.AugmentedThread
augment, currentThread, forget, getAugment, getAugment, getAugments, getError, hadError, hasAugment, toString
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

URL

public static final java.lang.String URL
See Also:
Constant Field Values

PARAMS

public static final java.lang.String PARAMS
See Also:
Constant Field Values

SESSION

public static final java.lang.String SESSION
See Also:
Constant Field Values

OUT

public static final java.lang.String OUT
See Also:
Constant Field Values

RESPONSE

public static final java.lang.String RESPONSE
See Also:
Constant Field Values

HEADERS

public static final java.lang.String HEADERS
See Also:
Constant Field Values

SESSION_USER

public static final java.lang.String SESSION_USER
See Also:
Constant Field Values

FORMAT_LAST_MODIFIED

public static java.text.SimpleDateFormat FORMAT_LAST_MODIFIED
Constructor Detail

RequestHandlerThread

public RequestHandlerThread(java.lang.Runnable requestHandler,
                            javax.servlet.http.HttpServletRequest request,
                            javax.servlet.http.HttpServletResponse response,
                            QueryParams params,
                            java.lang.String url)
                     throws java.io.IOException
Throws:
java.io.IOException

RequestHandlerThread

public RequestHandlerThread(javax.servlet.http.HttpServletRequest request,
                            javax.servlet.http.HttpServletResponse response,
                            QueryParams params,
                            java.lang.String url)
                     throws java.io.IOException
Throws:
java.io.IOException
Method Detail

addOnFinishHandler

public static void addOnFinishHandler(org.benow.java.notify.Listener listener)

getRequest

public static javax.servlet.http.HttpServletRequest getRequest()

getResponse

public static javax.servlet.http.HttpServletResponse getResponse()

getResultStream

public static java.io.OutputStream getResultStream()

getSession

public static javax.servlet.http.HttpSession getSession()

getParams

public static QueryParams getParams()

getURLString

public static java.lang.String getURLString()

getURL

public static java.net.URL getURL()

_getSession

protected javax.servlet.http.HttpSession _getSession()

cache

public void cache(java.lang.String name,
                  java.lang.Object obj)
Cache object in memory without touching session

Parameters:
name -
obj -

fetchFromCache

public java.lang.Object fetchFromCache(java.lang.String name)
Fetch object from memory not session

Parameters:
name -
Returns:

_augment

protected void _augment(java.lang.String name,
                        java.lang.Object obj)
Overrides:
_augment in class org.benow.java.augment.AugmentedThread

_getAugment

protected java.lang.Object _getAugment(java.lang.String name)
Overrides:
_getAugment in class org.benow.java.augment.AugmentedThread

addLoginCookie

public static void addLoginCookie(org.benow.security.user.User user)

_addLoginCookie

public void _addLoginCookie(org.benow.security.user.User user)

_setUser

protected void _setUser(org.benow.security.user.User user)
Overrides:
_setUser in class org.benow.security.user.SecureThread

startAndWait

public void startAndWait()

_logout

protected void _logout()
Overrides:
_logout in class org.benow.security.user.SecureThread

run

public void run()
Specified by:
run in interface java.lang.Runnable
Overrides:
run in class org.benow.security.user.SecureThread

setSessionMessage

public static void setSessionMessage(java.lang.String msg)

clearSessionMessage

public static void clearSessionMessage()

removeCookie

public static void removeCookie(java.lang.String cookieName)

addCookie

public static void addCookie(javax.servlet.http.Cookie cookie)

_addCookie

public void _addCookie(javax.servlet.http.Cookie cookie)

logout

public static void logout()

isServiceClientConnect

public static boolean isServiceClientConnect()
Returns:
true if accessing client is an HTTPServiceConnection

_forget

protected void _forget(java.lang.String... keys)
Overrides:
_forget in class org.benow.java.augment.AugmentedThread

getCookie

public static javax.servlet.http.Cookie getCookie(java.lang.String name)

manageSpanning

public static int manageSpanning(java.lang.String spanType,
                                 int spanning)

isCurrent

public static boolean isCurrent()
Returns:
true if current thread is RequestHandlerThread

getSessionAttributeAssert

public static java.lang.Object getSessionAttributeAssert(java.lang.String attrName)
Gets a value from the session, throwing a runtime exception if it is not present.

Parameters:
attrName -
Returns:

takeSessionAttributeAssert

public static java.lang.Object takeSessionAttributeAssert(java.lang.String attrName)
Take an attribute by name, removing from session. Throws RuntimeException if attribute not present

Parameters:
attrName -
Returns:

takeSessionMessage

public static java.lang.String takeSessionMessage()

getAddedHeaders

public static java.util.Map<java.lang.String,java.lang.String> getAddedHeaders()
Gets headers that have been added.

Returns:

addLastModifiedHeader

public static void addLastModifiedHeader(java.util.Date lastModified)
Convenience method to add a last modified header (and an eTag header) to the response associated with the current thread. LastModified is used in http conditional gets. If a last modified is provided for a page logic is implemented in PagePathHandler to do conditional gets.

Parameters:
lastModified -

addHeader

public static void addHeader(java.lang.String name,
                             java.lang.String value)
Add a header to be added to the response before content delivery. NOTE: org.mortbay.jetty.HttpHeaders can be useful for header name constants.

Parameters:
name - name of the header
value -

getXSLParams

public static java.util.Map<java.lang.String,java.lang.Object> getXSLParams()

addXSLParam

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

getAcceptedLanguages

public static java.util.List<AcceptedLanguage> getAcceptedLanguages()

isIE

public static boolean isIE()

isChrome

public static boolean isChrome()

addResponseHeader

public static void addResponseHeader(java.lang.String name,
                                     java.lang.String val)