org.jlf.httpRequest
Class AbstractProcessor

java.lang.Object
  |
  +--javax.servlet.GenericServlet
        |
        +--javax.servlet.http.HttpServlet
              |
              +--org.jlf.httpRequest.AbstractProcessor
All Implemented Interfaces:
java.io.Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig
Direct Known Subclasses:
Processor

public abstract class AbstractProcessor
extends javax.servlet.http.HttpServlet

This class is an abstract servlet used to automate the processing of HTTP Get/Post requests by mapping input data from forms into data mapped objects. It is subclassed by another servlet, dynamically loaded in the classpath in WebLogic, in a different package to solve class loader problems. The servlet does its work by finding a workflow name and optional workflow step in the HTTP request, looks up mapping properties in a property file, and maps the HTTP input data to objects via those properties. Most mapping properties are contained in the WorkflowProperties If you keep the workflow properties in the main property file, the following does not apply. It is better to place them in other files though, with a simple pointer to the property file in the main property file (more than one workflow can be contained in the same exterior property file):

 org.jlf.httpRequest.workflow.{workflowAlias}.propertyFile={propertyFileName}
 
For example, take two workflows (processOrder and maintainCustomer) in the same exterior property file:

 org.jlf.httpRequest.workflow.processOrder.propertyFile=productWorkflows
 org.jlf.httpRequest.workflow.maintainCustomer.propertyFile=productWorkflows
 
Then see the WorkflowProperties file for examples of what should be in the productWorkflows.properties file to map the two workflows.

See Also:
Workflow, WorkflowProperties, Processor, Serialized Form

Field Summary
protected  java.io.PrintWriter out
          Holds the output stream of the servlet.
protected  javax.servlet.http.HttpServletRequest request
          Holds the HTTP Request object.
protected  javax.servlet.http.HttpServletResponse response
          Holds the HTTP Response object.
protected static java.lang.String WORKFLOW_ALIAS_KEY
          This is the HTTP request variable stating the workflow alias to be mapped/executed.
protected static java.lang.String WORKFLOW_KEY_PROPERTY_FILE_PREFIX
          Constant for the property file prefix to see where to get workflow information from.
protected static java.lang.String WORKFLOW_KEY_PROPERTY_FILE_SUFFIX
          Constant for the property file suffix to see where to get workflow information from.
protected  java.lang.String workflowAlias
          Lazy initialized string for the workflow alias.
protected  WorkflowProperties workflowProperties
          Lazy initialized set of workflow properties specific to this http request.
protected static java.util.Hashtable workflowPropertyTable
          Holds a cache of workflow property information.
 
Constructor Summary
AbstractProcessor()
           
 
Method Summary
protected static WorkflowProperties basicGetWorkflowProperties(java.lang.String workflowName)
          Retrieves a set of workflow properties for the given workflow alias from property files, does NOT access the cache.
 void cleanUpAfterRequestProcessed()
          Hook method for cleaning up resources after the request is processed.
protected  void executeWorkflowStep()
          Forwards the current request to a workflow/step method, if one found.
protected  void forwardOutputPage()
          Helper method to find an output JSP, servlet, or any other HTML URL for final output processing, if any required for the request.
protected  void forwardToPage(java.lang.String pageURL)
          Helper method to forward the request to a particular URL.
 java.io.PrintWriter getOutputStream()
          Returns the output stream of the servlet, lazy-initialized so that we don't open the stream until we know we need it.
 javax.servlet.http.HttpServletRequest getRequest()
          Returns the HTTP Request object.
 javax.servlet.http.HttpServletResponse getResponse()
          Returns the HTTP Response object.
 javax.servlet.http.HttpSession getSession()
          Returns the HTTP Session.
protected  java.lang.String getWorkflowAlias()
          Helper method to retrieve the workflow alias from the HTTP request.
protected  WorkflowProperties getWorkflowProperties()
          Retrieves the workflow properties of this request.
static WorkflowProperties getWorkflowProperties(java.lang.String workflowAlias)
          Retrieves a set of workflow properties for the given workflow alias, from the cache of workflow properties.
protected  void mapAndDispatchRequestToWorkflow()
          Prepares a request for workflow/step processing.
protected  void mapObjects()
          Helper method to map any HTTP request form text to data mapped objects and place them in either the request or session object stores before a workflow step or output page kicks in.
 void service(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          Examines the HTTP servlet request and dispatches it to a workflow or workflow step.
 
Methods inherited from class javax.servlet.http.HttpServlet
doDelete, doGet, doHead, doOptions, doPost, doPut, doTrace, getLastModified, service
 
Methods inherited from class javax.servlet.GenericServlet
destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, init, log, log
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

request

protected javax.servlet.http.HttpServletRequest request
Holds the HTTP Request object.


response

protected javax.servlet.http.HttpServletResponse response
Holds the HTTP Response object.


out

protected java.io.PrintWriter out
Holds the output stream of the servlet.


WORKFLOW_KEY_PROPERTY_FILE_PREFIX

protected static final java.lang.String WORKFLOW_KEY_PROPERTY_FILE_PREFIX
Constant for the property file prefix to see where to get workflow information from.

See Also:
Constant Field Values

WORKFLOW_KEY_PROPERTY_FILE_SUFFIX

protected static final java.lang.String WORKFLOW_KEY_PROPERTY_FILE_SUFFIX
Constant for the property file suffix to see where to get workflow information from.

See Also:
Constant Field Values

workflowPropertyTable

protected static java.util.Hashtable workflowPropertyTable
Holds a cache of workflow property information.


WORKFLOW_ALIAS_KEY

protected static final java.lang.String WORKFLOW_ALIAS_KEY
This is the HTTP request variable stating the workflow alias to be mapped/executed. Set to "Workflow" by default.

See Also:
Constant Field Values

workflowAlias

protected java.lang.String workflowAlias
Lazy initialized string for the workflow alias.


workflowProperties

protected WorkflowProperties workflowProperties
Lazy initialized set of workflow properties specific to this http request.

Constructor Detail

AbstractProcessor

public AbstractProcessor()
Method Detail

getRequest

public javax.servlet.http.HttpServletRequest getRequest()
Returns the HTTP Request object.


getResponse

public javax.servlet.http.HttpServletResponse getResponse()
Returns the HTTP Response object.


getSession

public javax.servlet.http.HttpSession getSession()
Returns the HTTP Session.


getOutputStream

public java.io.PrintWriter getOutputStream()
Returns the output stream of the servlet, lazy-initialized so that we don't open the stream until we know we need it.


cleanUpAfterRequestProcessed

public void cleanUpAfterRequestProcessed()
Hook method for cleaning up resources after the request is processed.


basicGetWorkflowProperties

protected static WorkflowProperties basicGetWorkflowProperties(java.lang.String workflowName)
Retrieves a set of workflow properties for the given workflow alias from property files, does NOT access the cache.

Throws:
HttpRequestProcessorError

getWorkflowProperties

public static WorkflowProperties getWorkflowProperties(java.lang.String workflowAlias)
Retrieves a set of workflow properties for the given workflow alias, from the cache of workflow properties.

If not in the cache, tries to populate the cache and return it. Note that a workflow step can be embedded in the workflow alias, it will be stripped off (example, "MaintainOrder:displayOneOrder" will strip off ":displayOneOrder").


getWorkflowAlias

protected java.lang.String getWorkflowAlias()
Helper method to retrieve the workflow alias from the HTTP request. Uses standard lazy initialization.

Throws:
HttpRequestProcessorError - if a workflow not specified on the HTTP request.

getWorkflowProperties

protected WorkflowProperties getWorkflowProperties()
Retrieves the workflow properties of this request. Uses standard lazy initialization.


mapObjects

protected void mapObjects()
Helper method to map any HTTP request form text to data mapped objects and place them in either the request or session object stores before a workflow step or output page kicks in.


executeWorkflowStep

protected void executeWorkflowStep()
Forwards the current request to a workflow/step method, if one found.


forwardToPage

protected void forwardToPage(java.lang.String pageURL)
Helper method to forward the request to a particular URL.


forwardOutputPage

protected void forwardOutputPage()
                          throws java.io.IOException
Helper method to find an output JSP, servlet, or any other HTML URL for final output processing, if any required for the request. This is optional, as the workflow may output its own text right to the servlet's output stream.

java.io.IOException

mapAndDispatchRequestToWorkflow

protected void mapAndDispatchRequestToWorkflow()
                                        throws java.io.IOException
Prepares a request for workflow/step processing. Retrieves the workflow alias, maps data, and sends the request to a concrete Workflow subclass for processing.

java.io.IOException

service

public void service(javax.servlet.http.HttpServletRequest request,
                    javax.servlet.http.HttpServletResponse response)
             throws java.io.IOException
Examines the HTTP servlet request and dispatches it to a workflow or workflow step.

Overrides:
service in class javax.servlet.http.HttpServlet
java.io.IOException