net.officefloor.plugin.servlet.container.source
Class HttpServletTask

java.lang.Object
  extended by net.officefloor.frame.util.AbstractSingleTask<HttpServletTask,HttpServletTask.DependencyKeys,None>
      extended by net.officefloor.plugin.servlet.container.source.HttpServletTask
All Implemented Interfaces:
OfficeAwareWorkFactory<HttpServletTask>, TaskFactory<HttpServletTask,HttpServletTask.DependencyKeys,None>, WorkFactory<HttpServletTask>, Task<HttpServletTask,HttpServletTask.DependencyKeys,None>, Work, HttpServletServicer

public class HttpServletTask
extends AbstractSingleTask<HttpServletTask,HttpServletTask.DependencyKeys,None>
implements OfficeAwareWorkFactory<HttpServletTask>, HttpServletServicer

Task for a HttpServlet to service a HttpRequest.

Author:
Daniel Sagenschneider

Nested Class Summary
static class HttpServletTask.DependencyKeys
          Keys for the dependencies.
 
Field Summary
static String PROPERTY_PREFIX_INIT_PARAMETER
          Prefix of property for an initialisation parameter.
static String PROPERTY_SERVLET_MAPPINGS
          Name of property to obtain mappings to the HttpServlet.
static String TASK_NAME
          Name of the servicing Task for the Servlet.
 
Constructor Summary
HttpServletTask(String servletName, javax.servlet.http.HttpServlet servlet, Map<String,String> initParameters, String... servletMappings)
          Initiate.
 
Method Summary
 Object doTask(TaskContext<HttpServletTask,HttpServletTask.DependencyKeys,None> context)
           
 String[] getServletMappings()
           Obtains the mappings that are handled by this HttpServletServicer.
 String getServletName()
           Obtains the name of this HttpServletServicer.
 void include(OfficeServletContext context, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          Includes the content from this HttpServlet.
 void setOffice(Office office)
           
static void sourceWork(WorkTypeBuilder<HttpServletTask> workTypeBuilder, WorkSourceContext context, String servletName, javax.servlet.http.HttpServlet servlet, String... servletMappings)
          Sources the Work for a HttpServletTask.
 
Methods inherited from class net.officefloor.frame.util.AbstractSingleTask
createTask, createWork, getRecycleManagedObjectParameter, registerAsRecycleTask, registerTask, registerTask, registerTask, registerWork
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface net.officefloor.frame.api.build.WorkFactory
createWork
 

Field Detail

PROPERTY_PREFIX_INIT_PARAMETER

public static final String PROPERTY_PREFIX_INIT_PARAMETER
Prefix of property for an initialisation parameter.

See Also:
Constant Field Values

PROPERTY_SERVLET_MAPPINGS

public static final String PROPERTY_SERVLET_MAPPINGS
Name of property to obtain mappings to the HttpServlet. Mappings are comma (,) separated.

See Also:
Constant Field Values

TASK_NAME

public static final String TASK_NAME
Name of the servicing Task for the Servlet.

See Also:
Constant Field Values
Constructor Detail

HttpServletTask

public HttpServletTask(String servletName,
                       javax.servlet.http.HttpServlet servlet,
                       Map<String,String> initParameters,
                       String... servletMappings)
Initiate.

Parameters:
servletName - Name of the HttpServlet.
servlet - HttpServlet to service the HttpRequest.
initParameters - Initialisation parameters.
servletMappings - Mappings to the HttpServlet.
Method Detail

sourceWork

public static void sourceWork(WorkTypeBuilder<HttpServletTask> workTypeBuilder,
                              WorkSourceContext context,
                              String servletName,
                              javax.servlet.http.HttpServlet servlet,
                              String... servletMappings)
Sources the Work for a HttpServletTask.

Parameters:
workTypeBuilder - WorkTypeBuilder.
context - WorkSourceContext.
servletName - Servlet name.
servlet - HttpServlet.
servletMappings - Mappings to the HttpServlet.

setOffice

public void setOffice(Office office)
               throws Exception
Specified by:
setOffice in interface OfficeAwareWorkFactory<HttpServletTask>
Throws:
Exception

doTask

public Object doTask(TaskContext<HttpServletTask,HttpServletTask.DependencyKeys,None> context)
              throws javax.servlet.ServletException,
                     IOException
Specified by:
doTask in interface Task<HttpServletTask,HttpServletTask.DependencyKeys,None>
Throws:
javax.servlet.ServletException
IOException

getServletName

public String getServletName()
Description copied from interface: HttpServletServicer

Obtains the name of this HttpServletServicer.

This will be used to find this HttpServletServicer by name.

Specified by:
getServletName in interface HttpServletServicer
Returns:
HttpServletServicer name.

getServletMappings

public String[] getServletMappings()
Description copied from interface: HttpServletServicer

Obtains the mappings that are handled by this HttpServletServicer.

The mappings are of the form:

  1. /some/path.extension: for exact mapping (extension is optional)
  2. /wild/card/*: for path wild card mapping
  3. *.extension: for extension mapping

This follows the Servlet specification in regards to mappings.

Specified by:
getServletMappings in interface HttpServletServicer
Returns:
Mappings that are handled by this HttpServletServicer.
See Also:
ServicerMapper

include

public void include(OfficeServletContext context,
                    javax.servlet.http.HttpServletRequest request,
                    javax.servlet.http.HttpServletResponse response)
             throws javax.servlet.ServletException,
                    IOException
Description copied from interface: HttpServletServicer
Includes the content from this HttpServlet.

Specified by:
include in interface HttpServletServicer
Parameters:
context - OfficeServletContext.
request - HttpServletRequest.
response - HttpServletResponse.
Throws:
javax.servlet.ServletException - As per RequestDispatcher.
IOException - As per RequestDispatcher.


Copyright © 2005-2011. All Rights Reserved.