com.caucho.server.webapp
Class WebAppContainer

java.lang.Object
  extended by com.caucho.server.webapp.WebAppContainer
All Implemented Interfaces:
ClassLoaderListener, EnvironmentListener, InvocationBuilder, java.util.EventListener

public class WebAppContainer
extends java.lang.Object
implements InvocationBuilder, ClassLoaderListener, EnvironmentListener

Resin's webApp implementation.


Constructor Summary
WebAppContainer(Server server, Host host, Path rootDirectory, EnvironmentClassLoader loader, Lifecycle lifecycle)
          Creates the webApp with its environment loader.
 
Method Summary
 void add(DispatchRule dispatchRule)
          Adds a rewrite dispatch rule
 void add(RewriteFilter dispatchAction)
          Adds a rewrite dispatch rule
 void addApplication(EarConfig config)
          Adds an enterprise webApp.
 void addDeploy(DeployGenerator<WebAppController> deploy)
          Sets the war-expansion
 void addEarDefault(EarConfig config)
          Adds an ear default
 void addEarDeploy(EarDeployGenerator earDeploy)
          Adds the ear-expansion
 void addErrorPage(ErrorPage errorPage)
          Adds an error page
 void addWarDeploy(WebAppExpandDeployGenerator webAppDeploy)
          Sets the war-expansion
 void addWebApp(WebAppConfig config)
          Adds an webApp.
 void addWebApp(WebAppSingleDeployGenerator deployGenerator)
           
 void addWebAppDefault(WebAppConfig init)
          Adds a web-app default
 void addWebAppDeploy(WebAppExpandDeployGenerator deploy)
          Sets the war-expansion
 void buildDispatchInvocation(Invocation invocation)
          Creates the invocation for a rewrite-dispatch/dispatch.
 void buildErrorInvocation(Invocation invocation)
          Creates the error invocation.
 void buildForwardInvocation(Invocation invocation)
          Creates the invocation.
 void buildIncludeInvocation(Invocation invocation)
          Creates the invocation.
 Invocation buildInvocation(Invocation invocation)
          Creates the invocation.
 void buildLoginInvocation(Invocation invocation)
          Creates the invocation.
 void classLoaderDestroy(DynamicClassLoader loader)
          Handles the case where a class loader is dropped.
 void classLoaderInit(DynamicClassLoader loader)
          Handles the case where a class loader has completed initialization
 void clearCache()
          Clears the cache
 AbstractAccessLog createAccessLog()
          Sets the access log.
 WebAppSingleDeployGenerator createDeployGenerator(WebAppConfig config)
           
 EarDeployGenerator createEarDeploy()
          Sets the ear-expansion
 RewriteDispatch createRewriteDispatch()
          Adds rewrite-dispatch (backward compat).
 WebAppExpandDeployGenerator createWarDeploy()
          Sets the war-expansion
 WebAppExpandDeployGenerator createWebAppDeploy()
          Sets the war-expansion
 void destroy()
          Closes the container.
 void environmentBind(EnvironmentClassLoader loader)
          Handles the environment bind phase
 void environmentConfigure(EnvironmentClassLoader loader)
          Handles the environment config phase
 void environmentStart(EnvironmentClassLoader loader)
          Handles the case where the environment is starting (after init).
 void environmentStop(EnvironmentClassLoader loader)
          Handles the case where the environment is stopping
 void expandEarDeploy(java.lang.String name)
          Updates an ear deploy
 WebAppController findByURI(java.lang.String uri)
          Finds the web-app matching the current entry.
 WebAppController findController(java.lang.String subURI)
          Finds the web-app for the entry, not checking for sub-apps.
 com.caucho.server.webapp.WebAppContainer.WebAppUriMap findEntryByURI(java.lang.String uri)
          Finds the web-app matching the current entry.
 WebApp findSubWebAppByURI(java.lang.String uri)
          Creates the invocation.
 WebApp findWebAppByURI(java.lang.String uri)
          Creates the invocation.
 java.lang.ClassLoader getClassLoader()
          Gets the class loader.
 Path getDocumentDirectory()
          Gets the document directory.
 java.util.ArrayList<EarConfig> getEarDefaultList()
          Returns the list of ear defaults
 DeployContainerApi<EarDeployController> getEarDeployContainer()
           
 EarDeployController[] getEntAppList()
          Returns a list of the webApps.
 ErrorPageManager getErrorPageManager()
          Returns the error page manager
 WebApp getErrorWebApp()
          Returns the error webApp during startup.
 Host getHost()
          Returns the owning host.
 java.lang.String getHostName()
          Returns the host name for the container.
 java.lang.String getId()
          Returns the URL for the container.
 InvocationDecoder getInvocationDecoder()
           
 RequestDispatcher getRequestDispatcher(java.lang.String url)
          Returns a dispatcher for the named servlet.
 Path getRootDirectory()
          Gets the root directory.
protected  Server getServer()
           
 SessionManager getSessionManager()
          Returns the container's session manager.
 java.lang.String getStageTag()
           
 java.lang.String getURL()
          Returns the URL for the container.
 Path getWarDir()
          Gets the war-dir.
 Path getWarExpandDir()
          Gets the war-expand-dir.
protected  WebAppController getWebAppController(Invocation invocation)
          Returns the webApp controller for the current request.
 java.util.ArrayList<WebAppConfig> getWebAppDefaultList()
          Returns the list of web-app defaults
 DeployContainerApi<WebAppController> getWebAppDeployContainer()
           
 DeployContainer<WebAppController> getWebAppGenerator()
          Returns the webApp generator
 WebAppController[] getWebAppList()
          Returns a list of the webApps.
 boolean isActive()
          Returns true if the webApp container is active
 boolean isDestroyed()
          Returns true if the webApp container has been closed.
 boolean isModified()
          Returns true if modified.
 void removeWebApp(WebAppSingleDeployGenerator deployGenerator)
           
 void removeWebAppDeploy(DeployGenerator<WebAppController> deploy)
          Removes a web-app-generator.
 void setAccessLog(AbstractAccessLog log)
          Sets the access log.
 void setConfigException(java.lang.Throwable e)
          Sets a configuration exception.
 void setDocDir(Path path)
          Sets the document directory.
 void setDocumentDirectory(Path path)
          Sets the document directory.
 void setEnvironmentClassLoader(EnvironmentClassLoader loader)
          sets the class loader.
 void setRootDirectory(Path path)
          Sets the root directory.
 void setWarDir(Path warDir)
          Sets the war-dir for backwards compatibility.
 void setWarExpandDir(Path warDir)
          Sets the war-expand-dir.
 void start()
          Starts the container.
 void startEarDeploy(java.lang.String name)
          Start an ear
 boolean stop()
          Closes the container.
 java.lang.String toString()
           
 void updateEarDeploy(java.lang.String name)
          Updates an ear deploy
 void updateWebAppDeploy(java.lang.String name)
          Updates a WebApp deploy
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

WebAppContainer

public WebAppContainer(Server server,
                       Host host,
                       Path rootDirectory,
                       EnvironmentClassLoader loader,
                       Lifecycle lifecycle)
Creates the webApp with its environment loader.

Method Detail

getServer

protected Server getServer()

getInvocationDecoder

public InvocationDecoder getInvocationDecoder()

getClassLoader

public java.lang.ClassLoader getClassLoader()
Gets the class loader.


setEnvironmentClassLoader

public void setEnvironmentClassLoader(EnvironmentClassLoader loader)
sets the class loader.


getHost

public Host getHost()
Returns the owning host.


getStageTag

public java.lang.String getStageTag()

getRootDirectory

public Path getRootDirectory()
Gets the root directory.


setRootDirectory

public void setRootDirectory(Path path)
Sets the root directory.


getDocumentDirectory

public Path getDocumentDirectory()
Gets the document directory.


setDocumentDirectory

public void setDocumentDirectory(Path path)
Sets the document directory.


setDocDir

public void setDocDir(Path path)
Sets the document directory.


createAccessLog

public AbstractAccessLog createAccessLog()
Sets the access log.


setAccessLog

public void setAccessLog(AbstractAccessLog log)
Sets the access log.


addErrorPage

public void addErrorPage(ErrorPage errorPage)
Adds an error page


getErrorPageManager

public ErrorPageManager getErrorPageManager()
Returns the error page manager


setConfigException

public void setConfigException(java.lang.Throwable e)
Sets a configuration exception.


getWebAppGenerator

public DeployContainer<WebAppController> getWebAppGenerator()
Returns the webApp generator


getSessionManager

public SessionManager getSessionManager()
Returns the container's session manager.


add

public void add(DispatchRule dispatchRule)
Adds a rewrite dispatch rule


add

public void add(RewriteFilter dispatchAction)
Adds a rewrite dispatch rule


createRewriteDispatch

public RewriteDispatch createRewriteDispatch()
Adds rewrite-dispatch (backward compat).


isModified

public boolean isModified()
Returns true if modified.


addWebApp

public void addWebApp(WebAppConfig config)
Adds an webApp.


createDeployGenerator

public WebAppSingleDeployGenerator createDeployGenerator(WebAppConfig config)

addWebApp

public void addWebApp(WebAppSingleDeployGenerator deployGenerator)

removeWebApp

public void removeWebApp(WebAppSingleDeployGenerator deployGenerator)

addWebAppDefault

public void addWebAppDefault(WebAppConfig init)
Adds a web-app default


getWebAppDefaultList

public java.util.ArrayList<WebAppConfig> getWebAppDefaultList()
Returns the list of web-app defaults


createWarDeploy

public WebAppExpandDeployGenerator createWarDeploy()
Sets the war-expansion


createWebAppDeploy

public WebAppExpandDeployGenerator createWebAppDeploy()
Sets the war-expansion


addWebAppDeploy

public void addWebAppDeploy(WebAppExpandDeployGenerator deploy)
                     throws ConfigException
Sets the war-expansion

Throws:
ConfigException

addWarDeploy

public void addWarDeploy(WebAppExpandDeployGenerator webAppDeploy)
                  throws ConfigException
Sets the war-expansion

Throws:
ConfigException

addDeploy

public void addDeploy(DeployGenerator<WebAppController> deploy)
               throws ConfigException
Sets the war-expansion

Throws:
ConfigException

removeWebAppDeploy

public void removeWebAppDeploy(DeployGenerator<WebAppController> deploy)
Removes a web-app-generator.


updateWebAppDeploy

public void updateWebAppDeploy(java.lang.String name)
                        throws java.lang.Throwable
Updates a WebApp deploy

Throws:
java.lang.Throwable

addApplication

public void addApplication(EarConfig config)
Adds an enterprise webApp.


updateEarDeploy

public void updateEarDeploy(java.lang.String name)
                     throws java.lang.Throwable
Updates an ear deploy

Throws:
java.lang.Throwable

expandEarDeploy

public void expandEarDeploy(java.lang.String name)
Updates an ear deploy


startEarDeploy

public void startEarDeploy(java.lang.String name)
Start an ear


addEarDefault

public void addEarDefault(EarConfig config)
Adds an ear default


getEarDefaultList

public java.util.ArrayList<EarConfig> getEarDefaultList()
Returns the list of ear defaults


createEarDeploy

public EarDeployGenerator createEarDeploy()
                                   throws java.lang.Exception
Sets the ear-expansion

Throws:
java.lang.Exception

addEarDeploy

public void addEarDeploy(EarDeployGenerator earDeploy)
                  throws java.lang.Exception
Adds the ear-expansion

Throws:
java.lang.Exception

getURL

public java.lang.String getURL()
Returns the URL for the container.


getId

public java.lang.String getId()
Returns the URL for the container.


getHostName

public java.lang.String getHostName()
Returns the host name for the container.


setWarDir

public void setWarDir(Path warDir)
               throws ConfigException
Sets the war-dir for backwards compatibility.

Throws:
ConfigException

getWarDir

public Path getWarDir()
Gets the war-dir.


setWarExpandDir

public void setWarExpandDir(Path warDir)
Sets the war-expand-dir.


getWarExpandDir

public Path getWarExpandDir()
Gets the war-expand-dir.


start

public void start()
Starts the container.


clearCache

public void clearCache()
Clears the cache


buildInvocation

public Invocation buildInvocation(Invocation invocation)
                           throws ConfigException
Creates the invocation.

Specified by:
buildInvocation in interface InvocationBuilder
Throws:
ConfigException

getRequestDispatcher

public RequestDispatcher getRequestDispatcher(java.lang.String url)
Returns a dispatcher for the named servlet.


buildIncludeInvocation

public void buildIncludeInvocation(Invocation invocation)
                            throws ServletException
Creates the invocation.

Throws:
ServletException

buildForwardInvocation

public void buildForwardInvocation(Invocation invocation)
                            throws ServletException
Creates the invocation.

Throws:
ServletException

buildErrorInvocation

public void buildErrorInvocation(Invocation invocation)
                          throws ServletException
Creates the error invocation.

Throws:
ServletException

buildLoginInvocation

public void buildLoginInvocation(Invocation invocation)
                          throws ServletException
Creates the invocation.

Throws:
ServletException

buildDispatchInvocation

public void buildDispatchInvocation(Invocation invocation)
                             throws ServletException
Creates the invocation for a rewrite-dispatch/dispatch.

Throws:
ServletException

getWebAppController

protected WebAppController getWebAppController(Invocation invocation)
Returns the webApp controller for the current request. Side effect of filling in the invocation's context path and context uri.

Parameters:
invocation - the request's invocation
Returns:
the controller or null if none match the url.

findWebAppByURI

public WebApp findWebAppByURI(java.lang.String uri)
Creates the invocation.


findSubWebAppByURI

public WebApp findSubWebAppByURI(java.lang.String uri)
Creates the invocation.


findByURI

public WebAppController findByURI(java.lang.String uri)
Finds the web-app matching the current entry.


findEntryByURI

public com.caucho.server.webapp.WebAppContainer.WebAppUriMap findEntryByURI(java.lang.String uri)
Finds the web-app matching the current entry.


getWebAppDeployContainer

public DeployContainerApi<WebAppController> getWebAppDeployContainer()

findController

public WebAppController findController(java.lang.String subURI)
Finds the web-app for the entry, not checking for sub-apps. (used by LocalDeployServlet)


getWebAppList

public WebAppController[] getWebAppList()
Returns a list of the webApps.


getEarDeployContainer

public DeployContainerApi<EarDeployController> getEarDeployContainer()

getEntAppList

public EarDeployController[] getEntAppList()
Returns a list of the webApps.


isDestroyed

public final boolean isDestroyed()
Returns true if the webApp container has been closed.


isActive

public final boolean isActive()
Returns true if the webApp container is active


stop

public boolean stop()
Closes the container.


destroy

public void destroy()
Closes the container.


getErrorWebApp

public WebApp getErrorWebApp()
Returns the error webApp during startup.


classLoaderInit

public void classLoaderInit(DynamicClassLoader loader)
Handles the case where a class loader has completed initialization

Specified by:
classLoaderInit in interface ClassLoaderListener

classLoaderDestroy

public void classLoaderDestroy(DynamicClassLoader loader)
Handles the case where a class loader is dropped.

Specified by:
classLoaderDestroy in interface ClassLoaderListener

environmentConfigure

public void environmentConfigure(EnvironmentClassLoader loader)
Handles the environment config phase

Specified by:
environmentConfigure in interface EnvironmentListener

environmentBind

public void environmentBind(EnvironmentClassLoader loader)
Handles the environment bind phase

Specified by:
environmentBind in interface EnvironmentListener

environmentStart

public void environmentStart(EnvironmentClassLoader loader)
Handles the case where the environment is starting (after init).

Specified by:
environmentStart in interface EnvironmentListener

environmentStop

public void environmentStop(EnvironmentClassLoader loader)
Handles the case where the environment is stopping

Specified by:
environmentStop in interface EnvironmentListener

toString

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