org.apache.beehive.netui.pageflow
Class FlowControllerFactory

Object
  extended by Factory
      extended by FlowControllerFactory

public class FlowControllerFactory
extends Factory

Factory for creating FlowControllers - user PageFlowControllers and SharedFlowControllers.


Constructor Summary
protected FlowControllerFactory(ServletContext servletContext)
           
 
Method Summary
 PageFlowController createPageFlow(RequestContext context, Class pageFlowClass)
          Create a PageFlowController of the given type.
 PageFlowController createPageFlow(RequestContext context, String pageFlowClassName)
          Create a page flow of the given type.
 SharedFlowController createSharedFlow(RequestContext context, Class sharedFlowClass)
          Create a SharedFlowController of the given type.
 SharedFlowController createSharedFlow(RequestContext context, String sharedFlowClassName)
          Create a SharedFlowController of the given type.
static FlowControllerFactory get(ServletContext servletContext)
          Get a FlowControllerFactory.
 Class getFlowControllerClass(String className)
          Get a FlowController class.
static GlobalApp getGlobalApp(HttpServletRequest request, HttpServletResponse response, ServletContext servletContext)
          Deprecated. Global.app is deprecated; use shared flows and getSharedFlowsForRequest(RequestContext).
static PageFlowController getPageFlow(Class pageFlowClass, HttpServletRequest request, HttpServletResponse response, ServletContext servletContext)
          Deprecated. Use createPageFlow(RequestContext, Class) instead.
static PageFlowController getPageFlow(String pageFlowClassName, HttpServletRequest request, HttpServletResponse response, ServletContext servletContext)
          Deprecated. Use createPageFlow(RequestContext, String) instead.
 PageFlowController getPageFlowForPath(RequestContext context, String path)
          Get the page flow instance that should be associated with the given path.
static PageFlowController getPageFlowForRelativeURI(HttpServletRequest request, HttpServletResponse response, String path, ServletContext servletContext)
          Deprecated. Use getPageFlowForPath(RequestContext, String) instead.
static PageFlowController getPageFlowForRequest(HttpServletRequest request, HttpServletResponse response, ServletContext servletContext)
          Deprecated. Use getPageFlowForRequest(RequestContext) instead.
 PageFlowController getPageFlowForRequest(RequestContext context)
          Get the page flow instance that should be associated with the given request.
static PageFlowController getPageFlowForURI(HttpServletRequest request, HttpServletResponse response, String uri, ServletContext servletContext)
          Deprecated. Use getPageFlowForPath(RequestContext, String) instead. The URI must be stripped of the webapp context path before being passed.
 Map<String,SharedFlowController> getSharedFlowsForPath(RequestContext context, String path)
          Get the map of shared flows for the given path.
 Map<String,SharedFlowController> getSharedFlowsForRequest(RequestContext context)
          Get the map of shared flows for the given request.
 
Methods inherited from class Factory
getServletContext
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FlowControllerFactory

protected FlowControllerFactory(ServletContext servletContext)
Method Detail

get

public static FlowControllerFactory get(ServletContext servletContext)
Get a FlowControllerFactory.

Parameters:
servletContext - the current ServletContext.
Returns:
a FlowControllerFactory for the given ServletContext. It may or may not be a cached instance.

getPageFlowForRequest

public PageFlowController getPageFlowForRequest(RequestContext context)
                                         throws InstantiationException,
                                                IllegalAccessException
Get the page flow instance that should be associated with the given request. If it doesn't exist, create it. If one is created, the page flow stack (for nesting) will be cleared or pushed, and the new instance will be stored as the current page flow.

Parameters:
context - a RequestContext object which contains the current request and response.
Returns:
the PageFlowController for the request, or null if none was found.
Throws:
InstantiationException
IllegalAccessException

getPageFlowForPath

public PageFlowController getPageFlowForPath(RequestContext context,
                                             String path)
                                      throws InstantiationException,
                                             IllegalAccessException
Get the page flow instance that should be associated with the given path. If it doesn't exist, create it. If one is created, the page flow stack (for nesting) will be cleared or pushed, and the new instance will be stored as the current page flow.

Parameters:
context - a RequestContext object which contains the current request and response.
path - a webapp-relative path. The path should not contain the webapp context path.
Returns:
the PageFlowController for the given path, or null if none was found.
Throws:
InstantiationException
IllegalAccessException

createPageFlow

public PageFlowController createPageFlow(RequestContext context,
                                         String pageFlowClassName)
                                  throws ClassNotFoundException,
                                         InstantiationException,
                                         IllegalAccessException
Create a page flow of the given type. The page flow stack (for nesting) will be cleared or pushed, and the new instance will be stored as the current page flow.

Parameters:
context - a RequestContext object which contains the current request and response.
pageFlowClassName - the type name of the desired page flow.
Returns:
the newly-created PageFlowController, or null if none was found.
Throws:
ClassNotFoundException
InstantiationException
IllegalAccessException

createPageFlow

public PageFlowController createPageFlow(RequestContext context,
                                         Class pageFlowClass)
                                  throws InstantiationException,
                                         IllegalAccessException
Create a PageFlowController of the given type. The PageFlowController stack (for nesting) will be cleared or pushed, and the new instance will be stored as the current PageFlowController.

Parameters:
context - a RequestContext object which contains the current request and response.
pageFlowClass - the type of the desired PageFlowController.
Returns:
the newly-created PageFlowController, or null if none was found.
Throws:
InstantiationException
IllegalAccessException

createSharedFlow

public SharedFlowController createSharedFlow(RequestContext context,
                                             String sharedFlowClassName)
                                      throws ClassNotFoundException,
                                             InstantiationException,
                                             IllegalAccessException
Create a SharedFlowController of the given type.

Parameters:
context - a RequestContext object which contains the current request and response.
sharedFlowClassName - the type name of the desired SharedFlowController.
Returns:
the newly-created SharedFlowController, or null if none was found.
Throws:
ClassNotFoundException
InstantiationException
IllegalAccessException

createSharedFlow

public SharedFlowController createSharedFlow(RequestContext context,
                                             Class sharedFlowClass)
                                      throws InstantiationException,
                                             IllegalAccessException
Create a SharedFlowController of the given type.

Parameters:
context - a RequestContext object which contains the current request and response.
sharedFlowClass - the type of the desired SharedFlowController.
Returns:
the newly-created SharedFlowController, or null if none was found.
Throws:
InstantiationException
IllegalAccessException

getSharedFlowsForRequest

public Map<String,SharedFlowController> getSharedFlowsForRequest(RequestContext context)
                                                          throws ClassNotFoundException,
                                                                 InstantiationException,
                                                                 IllegalAccessException
Get the map of shared flows for the given request. The map is derived from the shared flows that are declared (through the sharedFlowRefs attribute of Jpf.Controller) in the page flow for the request.

Parameters:
context - a RequestContext object which contains the current request and response.
Returns:
a Map of shared-flow-name (String) to SharedFlowController.
Throws:
ClassNotFoundException - if a declared shared flow class could not be found.
InstantiationException - if a declared shared flow class could not be instantiated.
IllegalAccessException - if a declared shared flow class was not accessible.

getSharedFlowsForPath

public Map<String,SharedFlowController> getSharedFlowsForPath(RequestContext context,
                                                              String path)
                                                       throws ClassNotFoundException,
                                                              InstantiationException,
                                                              IllegalAccessException
Get the map of shared flows for the given path. The map is derived from the shared flows that are declared (through the sharedFlowRefs attribute of Jpf.Controller) in the page flow for the path.

Parameters:
context - a RequestContext object which contains the current request and response.
path - a webapp-relative path. The path should not contain the webapp context path.
Returns:
a Map of shared-flow-name (String) to SharedFlowController.
Throws:
ClassNotFoundException - if a declared shared flow class could not be found.
InstantiationException - if a declared shared flow class could not be instantiated.
IllegalAccessException - if a declared shared flow class was not accessible.

getFlowControllerClass

public Class getFlowControllerClass(String className)
                             throws ClassNotFoundException
Get a FlowController class. By default, this loads the class using the thread context class loader.

Parameters:
className - the name of the FlowController class to load.
Returns:
the loaded FlowController class.
Throws:
ClassNotFoundException - if the requested class could not be found.

getPageFlowForRequest

public static PageFlowController getPageFlowForRequest(HttpServletRequest request,
                                                       HttpServletResponse response,
                                                       ServletContext servletContext)
Deprecated. Use getPageFlowForRequest(RequestContext) instead.

Get the page flow instance that should be associated with the given request. If it doesn't exist, create it. If one is created, the page flow stack (for nesting) will be cleared or pushed, and the new instance will be stored as the current page flow.

Parameters:
request - the current HttpServletRequest.
response - the current HttpServletResponse.
servletContext - the current ServletContext.
Returns:
the PageFlowController for the request, or null if none was found.

getPageFlowForURI

public static PageFlowController getPageFlowForURI(HttpServletRequest request,
                                                   HttpServletResponse response,
                                                   String uri,
                                                   ServletContext servletContext)
Deprecated. Use getPageFlowForPath(RequestContext, String) instead. The URI must be stripped of the webapp context path before being passed.

Get the page flow instance that should be associated with the given URI. If it doesn't exist, create it. If one is created, the page flow stack (for nesting) will be cleared or pushed, and the new instance will be stored as the current page flow.

Parameters:
request - the current HttpServletRequest.
response - the current HttpServletResponse.
uri - a server-relative URI. The URI should contain the webapp context path.
servletContext - the current ServletContext.
Returns:
the PageFlowController for the given URI, or null if none was found.

getPageFlowForRelativeURI

public static PageFlowController getPageFlowForRelativeURI(HttpServletRequest request,
                                                           HttpServletResponse response,
                                                           String path,
                                                           ServletContext servletContext)
Deprecated. Use getPageFlowForPath(RequestContext, String) instead.

Get the page flow instance that should be associated with the given path. If it doesn't exist, create it. If one is created, the page flow stack (for nesting) will be cleared or pushed, and the new instance will be stored as the current page flow.

Parameters:
request - the current HttpServletRequest.
response - the current HttpServletResponse.
path - a webapp-relative path. The path should not contain the webapp context path.
servletContext - the current ServletContext.
Returns:
the PageFlowController for the given path, or null if none was found.

getPageFlow

public static PageFlowController getPageFlow(String pageFlowClassName,
                                             HttpServletRequest request,
                                             HttpServletResponse response,
                                             ServletContext servletContext)
Deprecated. Use createPageFlow(RequestContext, String) instead.

Create a page flow of the given type. The page flow stack (for nesting) will be cleared or pushed, and the new instance will be stored as the current page flow.

Parameters:
request - the current HttpServletRequest.
response - the current HttpServletResponse.
pageFlowClassName - the type name of the desired page flow.
servletContext - the current ServletContext.
Returns:
the newly-created PageFlowController, or null if none was found.

getGlobalApp

public static GlobalApp getGlobalApp(HttpServletRequest request,
                                     HttpServletResponse response,
                                     ServletContext servletContext)
Deprecated. Global.app is deprecated; use shared flows and getSharedFlowsForRequest(RequestContext).

Get or create the current user session's GlobalApp instance (from the Global.app file).

Parameters:
request - the current HttpServletRequest.
response - the current HttpServletResponse.
Returns:
the current session's GlobalApp instance, or a new one (based on Global.app) if none is found. If Global.app does not exist in the current webapp, null is returned.

getPageFlow

public static PageFlowController getPageFlow(Class pageFlowClass,
                                             HttpServletRequest request,
                                             HttpServletResponse response,
                                             ServletContext servletContext)
Deprecated. Use createPageFlow(RequestContext, Class) instead.

Create a page flow of the given type. The page flow stack (for nesting) will be cleared or pushed, and the new instance will be stored as the current page flow.

Parameters:
request - the current HttpServletRequest.
response - the current HttpServletResponse.
pageFlowClass - the type of the desired page flow.
servletContext - the current ServletContext.
Returns:
the newly-created PageFlowController, or null if none was found.