winstone
Class WebAppConfiguration

java.lang.Object
  extended by winstone.WebAppConfiguration
All Implemented Interfaces:
java.util.Comparator, ServletContext

public class WebAppConfiguration
extends java.lang.Object
implements ServletContext, java.util.Comparator

Models the web.xml file's details ... basically just a bunch of configuration details, plus the actual instances of mounted servlets.

Version:
$Id: WebAppConfiguration.java,v 1.55 2007/11/13 01:42:47 rickknowles Exp $
Author:
Rick Knowles

Constructor Summary
WebAppConfiguration(HostConfiguration ownerHostConfig, Cluster cluster, java.lang.String webRoot, java.lang.String prefix, ObjectPool objectPool, java.util.Map startupArgs, org.w3c.dom.Node elm, java.lang.ClassLoader parentClassLoader, java.io.File[] parentClassPaths, java.lang.String contextName)
          Constructor.
 
Method Summary
static void addJspServletParams(java.util.Map jspParams)
           
static boolean booleanArg(java.util.Map args, java.lang.String name, boolean defaultTrue)
           
 int compare(java.lang.Object one, java.lang.Object two)
           
 void destroy()
          Iterates through each of the servlets/filters and calls destroy on them
 AccessLogger getAccessLogger()
           
 java.lang.Object getAttribute(java.lang.String name)
          OK ...
 java.util.Enumeration getAttributeNames()
           
 ServletContext getContext(java.lang.String uri)
           
 java.lang.String getContextName()
           
 java.lang.String getContextPath()
           
 RequestDispatcher getErrorDispatcherByClass(java.lang.Throwable exception)
          Gets a dispatcher, set up for error dispatch.
 RequestDispatcher getErrorDispatcherByCode(java.lang.String requestURI, int statusCode, java.lang.String summaryMessage, java.lang.Throwable exception)
           
 java.lang.Class[] getErrorPageExceptions()
           
 java.util.Map getErrorPagesByCode()
           
 java.util.Map getErrorPagesByException()
           
 java.util.Map getFilterMatchCache()
           
 java.util.Map getFilters()
           
 RequestDispatcher getInitialDispatcher(java.lang.String uriInsideWebapp, WinstoneRequest request, WinstoneResponse response)
          Creates the dispatcher that corresponds to a request level dispatch (ie the initial entry point).
 java.lang.String getInitParameter(java.lang.String name)
           
 java.util.Enumeration getInitParameterNames()
           
 java.lang.ClassLoader getLoader()
           
 java.util.Map getLocaleEncodingMap()
           
 int getMajorVersion()
           
 java.lang.String getMimeType(java.lang.String fileName)
          Look up the map of mimeType extensions, and return the type that matches
 int getMinorVersion()
           
 RequestDispatcher getNamedDispatcher(java.lang.String name)
          Named dispatcher - this basically gets us a simple exact dispatcher (no url matching, no request attributes and no security)
 java.lang.String getOwnerHostname()
           
 java.lang.String getRealPath(java.lang.String path)
           
 ServletRequestAttributeListener[] getRequestAttributeListeners()
           
 RequestDispatcher getRequestDispatcher(java.lang.String uriInsideWebapp)
          Gets a dispatcher, which sets the request attributes, etc on a forward/include.
 ServletRequestListener[] getRequestListeners()
           
 java.net.URL getResource(java.lang.String path)
           
 java.io.InputStream getResourceAsStream(java.lang.String path)
           
 java.util.Set getResourcePaths(java.lang.String path)
           
 java.lang.String getServerInfo()
           
 Servlet getServlet(java.lang.String name)
          Deprecated.  
 java.lang.String getServletContextName()
           
 java.util.Enumeration getServletNames()
          Deprecated.  
 java.util.Enumeration getServlets()
          Deprecated.  
 java.lang.String getServletURIFromRequestURI(java.lang.String requestURI)
           
 WinstoneSession getSessionById(java.lang.String sessionId, boolean localOnly)
          Retrieves the session by id.
static java.lang.String getTextFromNode(org.w3c.dom.Node node)
           
 java.lang.String getWebroot()
           
 java.lang.String[] getWelcomeFiles()
           
static int intArg(java.util.Map args, java.lang.String name, int defaultValue)
           
 void invalidateExpiredSessions()
           
 boolean isDistributable()
           
 void log(java.lang.Exception exception, java.lang.String msg)
          Deprecated.  
 void log(java.lang.String message)
           
 void log(java.lang.String message, java.lang.Throwable throwable)
           
 WinstoneSession makeNewSession(java.lang.String sessionId)
          Constructs a session instance with the given sessionId
 void removeAttribute(java.lang.String name)
           
 void removeServletConfigurationAndMappings(ServletConfiguration config)
           
 void resetClassLoader()
          Triggered by the admin thread on the reloading class loader.
 void setAttribute(java.lang.String name, java.lang.Object object)
           
 void setSessionListeners(WinstoneSession session)
           
static java.lang.String stringArg(java.util.Map args, java.lang.String name, java.lang.String defaultValue)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.util.Comparator
equals
 

Constructor Detail

WebAppConfiguration

public WebAppConfiguration(HostConfiguration ownerHostConfig,
                           Cluster cluster,
                           java.lang.String webRoot,
                           java.lang.String prefix,
                           ObjectPool objectPool,
                           java.util.Map startupArgs,
                           org.w3c.dom.Node elm,
                           java.lang.ClassLoader parentClassLoader,
                           java.io.File[] parentClassPaths,
                           java.lang.String contextName)
Constructor. This parses the xml and sets up for basic routing

Method Detail

booleanArg

public static boolean booleanArg(java.util.Map args,
                                 java.lang.String name,
                                 boolean defaultTrue)

stringArg

public static java.lang.String stringArg(java.util.Map args,
                                         java.lang.String name,
                                         java.lang.String defaultValue)

intArg

public static int intArg(java.util.Map args,
                         java.lang.String name,
                         int defaultValue)

getTextFromNode

public static java.lang.String getTextFromNode(org.w3c.dom.Node node)

getContextPath

public java.lang.String getContextPath()
Specified by:
getContextPath in interface ServletContext

getWebroot

public java.lang.String getWebroot()

getLoader

public java.lang.ClassLoader getLoader()

getAccessLogger

public AccessLogger getAccessLogger()

getFilters

public java.util.Map getFilters()

getContextName

public java.lang.String getContextName()

getErrorPageExceptions

public java.lang.Class[] getErrorPageExceptions()

getErrorPagesByException

public java.util.Map getErrorPagesByException()

getErrorPagesByCode

public java.util.Map getErrorPagesByCode()

getLocaleEncodingMap

public java.util.Map getLocaleEncodingMap()

getWelcomeFiles

public java.lang.String[] getWelcomeFiles()

isDistributable

public boolean isDistributable()

getFilterMatchCache

public java.util.Map getFilterMatchCache()

getOwnerHostname

public java.lang.String getOwnerHostname()

getRequestListeners

public ServletRequestListener[] getRequestListeners()

getRequestAttributeListeners

public ServletRequestAttributeListener[] getRequestAttributeListeners()

addJspServletParams

public static void addJspServletParams(java.util.Map jspParams)

compare

public int compare(java.lang.Object one,
                   java.lang.Object two)
Specified by:
compare in interface java.util.Comparator

getServletURIFromRequestURI

public java.lang.String getServletURIFromRequestURI(java.lang.String requestURI)

destroy

public void destroy()
Iterates through each of the servlets/filters and calls destroy on them


resetClassLoader

public void resetClassLoader()
                      throws java.io.IOException
Triggered by the admin thread on the reloading class loader. This will cause a full shutdown and reinstantiation of the web app - not real graceful, but you shouldn't have reloading turned on in high load environments.

Throws:
java.io.IOException

makeNewSession

public WinstoneSession makeNewSession(java.lang.String sessionId)
Constructs a session instance with the given sessionId

Parameters:
sessionId - The sessionID for the new session
Returns:
A valid session object

getSessionById

public WinstoneSession getSessionById(java.lang.String sessionId,
                                      boolean localOnly)
Retrieves the session by id. If the web app is distributable, it asks the other members of the cluster if it doesn't have it itself.

Parameters:
sessionId - The id of the session we want
Returns:
A valid session instance

invalidateExpiredSessions

public void invalidateExpiredSessions()

setSessionListeners

public void setSessionListeners(WinstoneSession session)

removeServletConfigurationAndMappings

public void removeServletConfigurationAndMappings(ServletConfiguration config)

getAttribute

public java.lang.Object getAttribute(java.lang.String name)
OK ... from here to the end is the interface implementation methods for the servletContext interface.

Specified by:
getAttribute in interface ServletContext

getAttributeNames

public java.util.Enumeration getAttributeNames()
Specified by:
getAttributeNames in interface ServletContext

removeAttribute

public void removeAttribute(java.lang.String name)
Specified by:
removeAttribute in interface ServletContext

setAttribute

public void setAttribute(java.lang.String name,
                         java.lang.Object object)
Specified by:
setAttribute in interface ServletContext

getInitParameter

public java.lang.String getInitParameter(java.lang.String name)
Specified by:
getInitParameter in interface ServletContext

getInitParameterNames

public java.util.Enumeration getInitParameterNames()
Specified by:
getInitParameterNames in interface ServletContext

getServerInfo

public java.lang.String getServerInfo()
Specified by:
getServerInfo in interface ServletContext

getMajorVersion

public int getMajorVersion()
Specified by:
getMajorVersion in interface ServletContext

getMinorVersion

public int getMinorVersion()
Specified by:
getMinorVersion in interface ServletContext

getContext

public ServletContext getContext(java.lang.String uri)
Specified by:
getContext in interface ServletContext

getServletContextName

public java.lang.String getServletContextName()
Specified by:
getServletContextName in interface ServletContext

getMimeType

public java.lang.String getMimeType(java.lang.String fileName)
Look up the map of mimeType extensions, and return the type that matches

Specified by:
getMimeType in interface ServletContext

log

public void log(java.lang.String message)
Specified by:
log in interface ServletContext

log

public void log(java.lang.String message,
                java.lang.Throwable throwable)
Specified by:
log in interface ServletContext

getNamedDispatcher

public RequestDispatcher getNamedDispatcher(java.lang.String name)
Named dispatcher - this basically gets us a simple exact dispatcher (no url matching, no request attributes and no security)

Specified by:
getNamedDispatcher in interface ServletContext

getRequestDispatcher

public RequestDispatcher getRequestDispatcher(java.lang.String uriInsideWebapp)
Gets a dispatcher, which sets the request attributes, etc on a forward/include. Doesn't execute security though.

Specified by:
getRequestDispatcher in interface ServletContext

getInitialDispatcher

public RequestDispatcher getInitialDispatcher(java.lang.String uriInsideWebapp,
                                              WinstoneRequest request,
                                              WinstoneResponse response)
                                       throws java.io.IOException
Creates the dispatcher that corresponds to a request level dispatch (ie the initial entry point). The difference here is that we need to set up the dispatcher so that on a forward, it executes the security checks and the request filters, while not setting any of the request attributes for a forward. Also, we can't return a null dispatcher in error case - instead we have to return a dispatcher pre-init'd for showing an error page (eg 404). A null dispatcher is interpreted to mean a successful 302 has occurred.

Throws:
java.io.IOException

getErrorDispatcherByClass

public RequestDispatcher getErrorDispatcherByClass(java.lang.Throwable exception)
Gets a dispatcher, set up for error dispatch.


getErrorDispatcherByCode

public RequestDispatcher getErrorDispatcherByCode(java.lang.String requestURI,
                                                  int statusCode,
                                                  java.lang.String summaryMessage,
                                                  java.lang.Throwable exception)

getResource

public java.net.URL getResource(java.lang.String path)
                         throws java.net.MalformedURLException
Specified by:
getResource in interface ServletContext
Throws:
java.net.MalformedURLException

getResourceAsStream

public java.io.InputStream getResourceAsStream(java.lang.String path)
Specified by:
getResourceAsStream in interface ServletContext

getRealPath

public java.lang.String getRealPath(java.lang.String path)
Specified by:
getRealPath in interface ServletContext

getResourcePaths

public java.util.Set getResourcePaths(java.lang.String path)
Specified by:
getResourcePaths in interface ServletContext

getServlet

public Servlet getServlet(java.lang.String name)
Deprecated. 

Specified by:
getServlet in interface ServletContext

getServletNames

public java.util.Enumeration getServletNames()
Deprecated. 

Specified by:
getServletNames in interface ServletContext

getServlets

public java.util.Enumeration getServlets()
Deprecated. 

Specified by:
getServlets in interface ServletContext

log

public void log(java.lang.Exception exception,
                java.lang.String msg)
Deprecated. 

Specified by:
log in interface ServletContext


Copyright © 2013. All Rights Reserved.