com.dyuproject.web.rest
Class WebContext

java.lang.Object
  extended by com.dyuproject.web.rest.WebContext
Direct Known Subclasses:
RESTControllerContext, RESTServiceContext

public abstract class WebContext
extends Object

The REST web application context.

Author:
David Yu

Field Summary
static String DEFAULT_ENV_LOCATION
           
static String DEFAULT_MIME_LOCATION
           
static String DISPATCH_ATTR
           
static String PATH_SUFFIX_ATTR
           
static String PATHINFO_ARRAY_ATTR
           
static String PATHINFO_INDEX_ATTR
           
static String SESSION_ENABLED
           
 
Constructor Summary
WebContext()
           
 
Method Summary
 void addAttribute(String name, Object value)
           
 void addViewDispatcher(String mime, ViewDispatcher dispatcher)
           
protected abstract  void destroy()
           
 Object getAttribute(String name)
           
static RequestContext getCurrentRequestContext()
           
static CookieSession getCurrentSession()
           
 DefaultDispatcher getDefaultDispatcher()
           
 JSPDispatcher getJSPDispatcher()
           
 String getProperty(String name)
           
 RequestContext getRequestContext()
           
 ServletContext getServletContext()
           
 CookieSession getSession(HttpServletRequest request)
           
 CookieSession getSession(HttpServletRequest request, boolean create)
           
 ViewDispatcher getViewDispatcher(String name)
           
protected abstract  void handlePath(RequestContext requestContext)
           
protected abstract  void handleRoot(RequestContext requestContext)
           
protected abstract  void init()
           
 boolean invalidateSession(HttpServletResponse response)
           
 boolean isInitialized()
           
 boolean isMimeSupported(String mime)
           
 boolean isSessionEnabled()
           
protected  Object newObjectInstance(String className)
           
 boolean persistSession(CookieSession session, HttpServletRequest request, HttpServletResponse response)
           
protected abstract  void preConfigure(ServletConfig config)
           
 void service(HttpServletRequest request, HttpServletResponse response)
           
 void setAttributes(Map<String,Object> attributes)
           
 void setEnv(File location)
           
 void setEnv(InputStream stream)
           
 void setEnv(Properties env)
           
 void setEnv(URL location)
           
 void setMime(File location)
           
 void setMime(InputStream stream)
           
 void setMime(Properties mimes)
           
 void setMime(URL location)
           
 void setViewDispatchers(Map<String,ViewDispatcher> dispatchers)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DISPATCH_ATTR

public static final String DISPATCH_ATTR
See Also:
Constant Field Values

PATH_SUFFIX_ATTR

public static final String PATH_SUFFIX_ATTR
See Also:
Constant Field Values

DEFAULT_MIME_LOCATION

public static final String DEFAULT_MIME_LOCATION
See Also:
Constant Field Values

DEFAULT_ENV_LOCATION

public static final String DEFAULT_ENV_LOCATION
See Also:
Constant Field Values

SESSION_ENABLED

public static final String SESSION_ENABLED
See Also:
Constant Field Values

PATHINFO_ARRAY_ATTR

public static final String PATHINFO_ARRAY_ATTR
See Also:
Constant Field Values

PATHINFO_INDEX_ATTR

public static final String PATHINFO_INDEX_ATTR
See Also:
Constant Field Values
Constructor Detail

WebContext

public WebContext()
Method Detail

getCurrentRequestContext

public static RequestContext getCurrentRequestContext()

getRequestContext

public RequestContext getRequestContext()

getCurrentSession

public static CookieSession getCurrentSession()

isInitialized

public boolean isInitialized()

getSession

public CookieSession getSession(HttpServletRequest request,
                                boolean create)

getSession

public CookieSession getSession(HttpServletRequest request)

persistSession

public boolean persistSession(CookieSession session,
                              HttpServletRequest request,
                              HttpServletResponse response)
                       throws IOException
Throws:
IOException

invalidateSession

public boolean invalidateSession(HttpServletResponse response)
                          throws IOException
Throws:
IOException

isSessionEnabled

public boolean isSessionEnabled()

getServletContext

public ServletContext getServletContext()

getJSPDispatcher

public JSPDispatcher getJSPDispatcher()

getDefaultDispatcher

public DefaultDispatcher getDefaultDispatcher()

setViewDispatchers

public void setViewDispatchers(Map<String,ViewDispatcher> dispatchers)

addViewDispatcher

public void addViewDispatcher(String mime,
                              ViewDispatcher dispatcher)

getViewDispatcher

public ViewDispatcher getViewDispatcher(String name)

setMime

public void setMime(Properties mimes)

setMime

public void setMime(InputStream stream)

setMime

public void setMime(File location)
             throws IOException
Throws:
IOException

setMime

public void setMime(URL location)
             throws IOException
Throws:
IOException

isMimeSupported

public boolean isMimeSupported(String mime)

setEnv

public void setEnv(Properties env)

setEnv

public void setEnv(InputStream stream)

setEnv

public void setEnv(File location)
            throws IOException
Throws:
IOException

setEnv

public void setEnv(URL location)
            throws IOException
Throws:
IOException

setAttributes

public void setAttributes(Map<String,Object> attributes)

addAttribute

public void addAttribute(String name,
                         Object value)

getAttribute

public Object getAttribute(String name)

getProperty

public String getProperty(String name)

newObjectInstance

protected Object newObjectInstance(String className)
                            throws Exception
Throws:
Exception

service

public void service(HttpServletRequest request,
                    HttpServletResponse response)
             throws ServletException,
                    IOException
Throws:
ServletException
IOException

preConfigure

protected abstract void preConfigure(ServletConfig config)
                              throws Exception
Throws:
Exception

init

protected abstract void init()

destroy

protected abstract void destroy()

handleRoot

protected abstract void handleRoot(RequestContext requestContext)
                            throws ServletException,
                                   IOException
Throws:
ServletException
IOException

handlePath

protected abstract void handlePath(RequestContext requestContext)
                            throws ServletException,
                                   IOException
Throws:
ServletException
IOException


Copyright © 2013. All Rights Reserved.