org.apache.tapestry
Class ApplicationServlet

java.lang.Object
  extended byjavax.servlet.GenericServlet
      extended byjavax.servlet.http.HttpServlet
          extended byorg.apache.tapestry.ApplicationServlet
All Implemented Interfaces:
java.io.Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig

public class ApplicationServlet
extends javax.servlet.http.HttpServlet

Links a servlet container with a Tapestry application. The servlet init parameter org.apache.tapestry.application-specification should be set to the complete resource path (within the classpath) to the application specification, i.e., /com/foo/bar/MyApp.application. As of release 4.0, this servlet will also create a HiveMind Registry and manage it.

Author:
Howard Lewis Ship
See Also:
ApplicationInitializer, ServletRequestServicer, Serialized Form

Constructor Summary
ApplicationServlet()
           
 
Method Summary
protected  void addModuleIfExists(org.apache.hivemind.impl.RegistryBuilder builder, javax.servlet.ServletContext context, java.lang.String path)
          Looks for a file in the servlet context; if it exists, it is expected to be a HiveMind module descriptor, and is added to the builder.
protected  org.apache.hivemind.ErrorHandler constructErrorHandler(javax.servlet.ServletConfig config)
          Invoked by constructRegistry(ServletConfig) to create and return an ErrorHandler instance to be used when constructing the Registry (and then to handle any runtime exceptions).
protected  org.apache.hivemind.Registry constructRegistry(javax.servlet.ServletConfig config)
          Invoked from init(ServletConfig)to construct the Registry to be used by the application.
protected  org.apache.hivemind.ClassResolver createClassResolver()
          Invoked from init(ServletConfig)to create a resource resolver for the servlet (which will utlimately be shared and used through the application).
 void destroy()
          Shuts down the registry (if it exists).
 void doGet(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          Invokes doService(HttpServletRequest, HttpServletResponse).
 void doPost(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          Invokes doService(HttpServletRequest, HttpServletResponse).
protected  void doService(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          Handles the GET and POST requests.
 void init(javax.servlet.ServletConfig config)
          Reads the application specification when the servlet is first initialized.
protected  void initializeApplication()
          Invoked from init(ServletConfig), after the registry has been constructed, to bootstrap the application via the tapestry.MasterApplicationInitializer service.
protected  void show(java.lang.Exception ex)
           
 
Methods inherited from class javax.servlet.http.HttpServlet
doDelete, doHead, doOptions, doPut, doTrace, getLastModified, service, service
 
Methods inherited from class javax.servlet.GenericServlet
getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, log, log
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ApplicationServlet

public ApplicationServlet()
Method Detail

doGet

public void doGet(javax.servlet.http.HttpServletRequest request,
                  javax.servlet.http.HttpServletResponse response)
           throws java.io.IOException,
                  javax.servlet.ServletException
Invokes doService(HttpServletRequest, HttpServletResponse).

Throws:
java.io.IOException
javax.servlet.ServletException
Since:
1.0.6

doService

protected void doService(javax.servlet.http.HttpServletRequest request,
                         javax.servlet.http.HttpServletResponse response)
                  throws java.io.IOException,
                         javax.servlet.ServletException
Handles the GET and POST requests. Performs the following:

Throws:
java.io.IOException
javax.servlet.ServletException

show

protected void show(java.lang.Exception ex)

doPost

public void doPost(javax.servlet.http.HttpServletRequest request,
                   javax.servlet.http.HttpServletResponse response)
            throws java.io.IOException,
                   javax.servlet.ServletException
Invokes doService(HttpServletRequest, HttpServletResponse).

Throws:
java.io.IOException
javax.servlet.ServletException

init

public void init(javax.servlet.ServletConfig config)
          throws javax.servlet.ServletException
Reads the application specification when the servlet is first initialized. All engine instanceswill have access to the specification via the servlet.

Throws:
javax.servlet.ServletException
See Also:
#constructApplicationSpecification(), #createResourceResolver()

createClassResolver

protected org.apache.hivemind.ClassResolver createClassResolver()
Invoked from init(ServletConfig)to create a resource resolver for the servlet (which will utlimately be shared and used through the application).

This implementation constructs a DefaultResourceResolver, subclasses may provide a different implementation.

Since:
2.3
See Also:
#getResourceResolver()

constructRegistry

protected org.apache.hivemind.Registry constructRegistry(javax.servlet.ServletConfig config)
Invoked from init(ServletConfig)to construct the Registry to be used by the application.

This looks in the standard places (on the classpath), but also in the WEB-INF/name and WEB-INF folders (where name is the name of the servlet).

Since:
4.0

constructErrorHandler

protected org.apache.hivemind.ErrorHandler constructErrorHandler(javax.servlet.ServletConfig config)
Invoked by constructRegistry(ServletConfig) to create and return an ErrorHandler instance to be used when constructing the Registry (and then to handle any runtime exceptions). This implementation returns a new instance of StrictErrorHandler.

Since:
4.0

addModuleIfExists

protected void addModuleIfExists(org.apache.hivemind.impl.RegistryBuilder builder,
                                 javax.servlet.ServletContext context,
                                 java.lang.String path)
Looks for a file in the servlet context; if it exists, it is expected to be a HiveMind module descriptor, and is added to the builder.

Since:
4.0

initializeApplication

protected void initializeApplication()
Invoked from init(ServletConfig), after the registry has been constructed, to bootstrap the application via the tapestry.MasterApplicationInitializer service.

Since:
4.0

destroy

public void destroy()
Shuts down the registry (if it exists).

Since:
4.0