org.apache.beehive.netui.pageflow
Class FlowControllerFactory

Object
  extended by Factory
      extended by FlowControllerFactory
All Implemented Interfaces:
Serializable

public class FlowControllerFactory
extends Factory

Factory for creating FlowControllers - user PageFlowControllers and SharedFlowControllers.

When we create a FlowController object, if the object has any @Control annotations, the ControlContainerContext will be created. See ControlContainerContext for more information. If there are no annotations, the ControlContainerContext may not be created. If the FlowController is going to instantiate controls programmatically, you need to make sure that the ControlContainerContext is created. See the PageFlowControlContainerFactory and PageFlowControlContainer for more information.

See Also:
Serialized Form

Constructor Summary
protected FlowControllerFactory()
           
 
Method Summary
 PageFlowController createPageFlow(RequestContext context, Class pageFlowClass)
          Create a PageFlowController of the given type.
 PageFlowController createPageFlow(RequestContext context, String pageFlowClassName)
          Create a PageFlowController 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.
 FlowController getFlowControllerInstance(Class flowControllerClass)
          Get a FlowController instance, given 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 getSharedFlowsForPath(RequestContext context, String path)
          Get the map of shared flows for the given path.
 Map getSharedFlowsForRequest(RequestContext context)
          Get the map of shared flows for the given request.
static void init(ServletContext servletContext)
          Initialize an instance of this class in the ServletContext.
protected  void onCreate()
          Called after this factory has been created and initialized.
protected  void reinit(ServletContext servletContext)
          Called to reinitialize this instance, most importantly after it has been serialized/deserialized.
 
Methods inherited from class Factory
getConfig, getServletContext
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FlowControllerFactory

protected FlowControllerFactory()
Method Detail

onCreate

protected void onCreate()
Description copied from class: Factory
Called after this factory has been created and initialized.

Overrides:
onCreate in class Factory

init

public static void init(ServletContext servletContext)
Initialize an instance of this class in the ServletContext. This is a framework-invoked method and should not normally be called directly.


reinit

protected void reinit(ServletContext servletContext)
Called to reinitialize this instance, most importantly after it has been serialized/deserialized.

Overrides:
reinit in class Factory
Parameters:
servletContext - the current ServletContext.

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 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.
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 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 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.

getFlowControllerInstance

public FlowController getFlowControllerInstance(Class flowControllerClass)
                                         throws InstantiationException,
                                                IllegalAccessException
Get a FlowController instance, given a FlowController class.

Parameters:
flowControllerClass - the Class, which must be assignable to FlowController.
Returns:
a new FlowController instance.
Throws:
InstantiationException
IllegalAccessException

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.