Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.infohazard.maverick.flow
Class AbstractControllerFactory  view AbstractControllerFactory download AbstractControllerFactory.java

java.lang.Object
  extended byorg.infohazard.maverick.flow.AbstractControllerFactory
All Implemented Interfaces:
ControllerFactory
Direct Known Subclasses:
DefaultControllerFactory

public abstract class AbstractControllerFactory
extends java.lang.Object
implements ControllerFactory

Base class for controller factories. Creates (what appears to be) a singleton controller object appropriate for the type of controller specified in the XML, including single-use controllers. If no controller is specified, a special do-nothing controller is returned. If you want to use a custom controller factory, it is advisable to extend from this class and override either the interface method (createController) or override one or more of the template methods (getControllerClass, getControllerInstance and initializeController).


Nested Class Summary
(package private) static class AbstractControllerFactory.NullController
          Dummy controller class.
 
Field Summary
protected static java.lang.String ATTR_CONTROLLER_CLASS
          xml attribute of controller class.
protected static Controller nullController
          dummy controller.
 
Constructor Summary
AbstractControllerFactory()
           
 
Method Summary
 Controller createController(org.jdom.Element controllerNode)
          Creates (what appears to be) a singleton controller object appropriate for the type of controller specified in the XML, including single-use controllers.
protected  Controller createSingletonController(org.jdom.Element controllerNode, java.lang.Class controllerClass)
          Create a singleton controller instance.
protected  Controller createThrowawayController(org.jdom.Element controllerNode, java.lang.Class controllerClass)
          Create a throwaway controller; this implementation creates an instance of ThrowawayControllerAdapter.
protected  Controller decorateController(org.jdom.Element controllerNode, Controller controller)
          If needed, decorate the controller.
protected  java.lang.Class getControllerClass(org.jdom.Element controllerNode)
          Get the controller class from the configuration.
protected  Controller getControllerInstance(org.jdom.Element controllerNode, java.lang.Class controllerClass)
          Create a controller instance (or a decorator) based on the controller class and the controller node.
protected  Controller getControllerUndecorated(Controller controller)
          Get the 'real' controller instance unwrapped.
 void init(org.jdom.Element factoryNode, javax.servlet.ServletConfig servletCfg)
          Initialize: this method does nothing; override to customize.
protected  void initializeController(org.jdom.Element controllerNode, Controller controller)
          initialize the controller if it needs to be done.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ATTR_CONTROLLER_CLASS

protected static final java.lang.String ATTR_CONTROLLER_CLASS
xml attribute of controller class.

See Also:
Constant Field Values

nullController

protected static final Controller nullController
dummy controller.

Constructor Detail

AbstractControllerFactory

public AbstractControllerFactory()
Method Detail

init

public void init(org.jdom.Element factoryNode,
                 javax.servlet.ServletConfig servletCfg)
          throws ConfigException
Initialize: this method does nothing; override to customize.

Specified by:
init in interface ControllerFactory

createController

public Controller createController(org.jdom.Element controllerNode)
                            throws ConfigException
Creates (what appears to be) a singleton controller object appropriate for the type of controller specified in the XML, including single-use controllers. If no controller is specified, a special do-nothing controller is returned.

Specified by:
createController in interface ControllerFactory

getControllerClass

protected java.lang.Class getControllerClass(org.jdom.Element controllerNode)
                                      throws ConfigException
Get the controller class from the configuration.


getControllerInstance

protected Controller getControllerInstance(org.jdom.Element controllerNode,
                                           java.lang.Class controllerClass)
                                    throws ConfigException
Create a controller instance (or a decorator) based on the controller class and the controller node.


decorateController

protected Controller decorateController(org.jdom.Element controllerNode,
                                        Controller controller)
                                 throws ConfigException
If needed, decorate the controller.


createSingletonController

protected Controller createSingletonController(org.jdom.Element controllerNode,
                                               java.lang.Class controllerClass)
                                        throws ConfigException,
                                               java.lang.InstantiationException,
                                               java.lang.IllegalAccessException
Create a singleton controller instance.


createThrowawayController

protected Controller createThrowawayController(org.jdom.Element controllerNode,
                                               java.lang.Class controllerClass)
                                        throws ConfigException,
                                               java.lang.InstantiationException,
                                               java.lang.IllegalAccessException
Create a throwaway controller; this implementation creates an instance of ThrowawayControllerAdapter.


initializeController

protected void initializeController(org.jdom.Element controllerNode,
                                    Controller controller)
                             throws ConfigException
initialize the controller if it needs to be done. This implementation just looks if the given controller (or embedded controller in case the given controller is a decorator) is of type ControllerSingleton and, if it is, it's init method is called.


getControllerUndecorated

protected Controller getControllerUndecorated(Controller controller)
Get the 'real' controller instance unwrapped.