org.apache.tapestry
Class ApplicationServlet

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

public class ApplicationServlet
extends 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, ServletContext context, 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(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(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(HttpServletRequest request, HttpServletResponse response)
          Invokes doService(HttpServletRequest, HttpServletResponse).
 void doPost(HttpServletRequest request, HttpServletResponse response)
          Invokes doService(HttpServletRequest, HttpServletResponse).
protected  void doService(HttpServletRequest request, HttpServletResponse response)
          Handles the GET and POST requests.
 void init(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(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(HttpServletRequest request,
                  HttpServletResponse response)
           throws IOException,
                  ServletException
Invokes doService(HttpServletRequest, HttpServletResponse).

Overrides:
doGet in class HttpServlet
Throws:
IOException
ServletException
Since:
1.0.6

doService

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

Throws:
IOException
ServletException

show

protected void show(Exception ex)

doPost

public void doPost(HttpServletRequest request,
                   HttpServletResponse response)
            throws IOException,
                   ServletException
Invokes doService(HttpServletRequest, HttpServletResponse).

Overrides:
doPost in class HttpServlet
Throws:
IOException
ServletException

init

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

Specified by:
init in interface Servlet
Overrides:
init in class GenericServlet
Throws:
ServletException
See Also:
constructRegistry(ServletConfig), createClassResolver()

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 DefaultClassResolver, subclasses may provide a different implementation.

Since:
2.3
See Also:
DefaultClassResolver

constructRegistry

protected org.apache.hivemind.Registry constructRegistry(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(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,
                                 ServletContext context,
                                 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).

Specified by:
destroy in interface Servlet
Overrides:
destroy in class GenericServlet
Since:
4.0


Copyright © 2006-2008 Apache Software Foundation. All Rights Reserved.