com.sri.common.controller
Class AbstractComponentController

java.lang.Object
  extended by org.apache.struts.action.Action
      extended by com.jcorporate.expresso.core.controller.Controller
          extended by com.jcorporate.expresso.core.controller.DBController
              extended by com.sri.common.controller.AbstractDBController
                  extended by com.sri.common.controller.AbstractComponentController
All Implemented Interfaces:
ComponentServiceLocator, Serializable
Direct Known Subclasses:
CompletionEditor, CreationEditor, NodeController, NodeTagController, WizardController, WizardGatewayController

public abstract class AbstractComponentController
extends AbstractDBController
implements ComponentServiceLocator

The component controller provides the home for two lightweight containers and a link to a third. They are shown here in the diagram: Container Hierarchy Diagram

The lowest level, the request container is build during the prePerform and postPerform states. The Request/Response objects are dumped in this particular container.

The next level up, the ControllerContainer contains all the step handlers and other appropriate classes for the controller component. This may include Monitor objects, etc.

The Controller-level container is first instantiated upon construction of the controller

The final level container is contained in the Schema and may be used as a factory for DataObjects, Controllers, and the like.

The Schema container is created at the startup of the servlet context

Version:
1.0
Author:
Michael Rimov
See Also:
Serialized Form

Field Summary
static String REQUEST_CONTAINER
          The mutable pico container is stored here.
 
Fields inherited from class com.sri.common.controller.AbstractDBController
COLUMN, COMMON_FOOTER_HANDLER, COMMON_HEADER_HANDLER, DELIMIT, EDIT_GROUP_DISPLAY, EMBEDDED_MODE, FOOTER, MAX_CHARS_OUTPUT, MAX_TEXTAREA_LENGTH, MULTIPLE_TEXTAREA_NUM_LINES, ROW, ROW_BLOCK, SESSION_CONTAINER, SINGLE_TEXTAREA_NUM_LINES, TEXTAREA_NUM_COLS, WARNING_LIST
 
Fields inherited from class com.jcorporate.expresso.core.controller.DBController
CACHE_NAME
 
Fields inherited from class com.jcorporate.expresso.core.controller.Controller
CONTROLLER_PARAM_KEY, CTL_SUCC_CTL, CTL_SUCC_STATE, CTL_SUCC_TRAN, mLog, NEWSTATE_EXCEPTION_KEY, ORIGINAL_URL_KEY, REQUEST_KEY, RESPONSE_KEY, RETURN_TO_SENDER_TRAN, STATE_ERR_CTL, STATE_ERR_STATE, STATE_ERR_TRAN, STATE_PARAM_KEY, STATE_SUCC_CTL, STATE_SUCC_STATE, STATE_SUCC_TRAN
 
Fields inherited from class org.apache.struts.action.Action
defaultLocale, servlet
 
Constructor Summary
AbstractComponentController(Class mySchemaClass)
          Constructor that takes a concrete schema instance as its parameter.
 
Method Summary
protected  State addStateHandler(String stateName, String stateDescription, Class stateHandler)
          Allows adding a state handler by combining adding a state and registering the component instance in the container instance.
protected  void initializeControllerContainer(org.picocontainer.MutablePicoContainer container)
          Template method that allows sub-controllers to register any particular objects they wish.
 Object locate(Object serviceKey)
          Retrieves the desired service defined by the key.
protected  ComponentServiceLocator locator()
          Retrieve the application locator.
 ExpressoResponse newExpressoState(String newState, ExpressoRequest myRequest)
          This is the method where all of the real work of the controller is done.
protected  void postPerform(State nextState, ExpressoRequest request, ExpressoResponse response)
          Template Method, allowing a subclass to into actions after the invocation of any state in this controller.
protected  void prePerform(State nextState, ExpressoRequest request, ExpressoResponse response)
          Template Method, allowing a subclass to do an action after any state in this controller is performed.
 
Methods inherited from class com.sri.common.controller.AbstractDBController
addEmbeddedParameter, addWarning, addWarningList, getActionForwarding, getCheckbox, getPermsTrans, getPrettyXML, getTextArea, getTextArea, getWarningList, isEmbeddedMode, isValidAndPopulated, outputXML, populateDBObject, stateAllowed, str, strTrunc, trimAllTextFields
 
Methods inherited from class com.jcorporate.expresso.core.controller.DBController
getString, isAllowed
 
Methods inherited from class com.jcorporate.expresso.core.controller.Controller
addFinalState, addPromptTransitions, addRegDomainParamtoSession, addRequestedURLtoSession, addState, addStatePairing, endTimer, execute, findControllerForm, generateToken, getActionForward, getControllerChainingTransition, getControllerSecurityTransition, getFinalState, getInitialState, getLogger, getParamValues, getRequestURL, getSchema, getSchemaHierarchy, getSchemaInstance, getSchemaStack, getState, getStates, getString, getString, getTitle, handleException, instantiate, isFinalState, isHandleState, isPromptState, isTokenValid, loadStateForm, newState, nextHandleState, nextPromptState, populateStateForm, postPerform, prePerform, previousPromptState, processRequestTransitions, processTransitions, redirectRequest, redirectRequest, remapFromExtension, resetToken, saveToken, setControllerChainingTransition, setControllerSecurityTransition, setCurrentState, setInitialState, setSchema, setSchema, setupDefaultValues, setupReturnToSender, setupSubclassLog, transition, transition, transition, unloadStateForm
 
Methods inherited from class org.apache.struts.action.Action
addErrors, addMessages, execute, generateToken, getDataSource, getDataSource, getErrors, getLocale, getMessages, getResources, getResources, getServlet, isCancelled, isTokenValid, isTokenValid, resetToken, saveErrors, saveErrors, saveMessages, saveMessages, saveToken, setLocale, setServlet
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

REQUEST_CONTAINER

public static final String REQUEST_CONTAINER
The mutable pico container is stored here. In your own derived classes, if you wish to modify the request-level container, override prePerform, first call super.prePerform(...), then grab the REQUEST_CONTAINER from the request context.

Constructor Detail

AbstractComponentController

public AbstractComponentController(Class mySchemaClass)
Constructor that takes a concrete schema instance as its parameter. Use SchemaFactory to create the instance of the component.

Parameters:
mySchemaClass - ComponentSchema
Method Detail

initializeControllerContainer

protected void initializeControllerContainer(org.picocontainer.MutablePicoContainer container)
Template method that allows sub-controllers to register any particular objects they wish.

Parameters:
container - MutablePicoContainer the mutable pico container instance.

addStateHandler

protected State addStateHandler(String stateName,
                                String stateDescription,
                                Class stateHandler)
Allows adding a state handler by combining adding a state and registering the component instance in the container instance.

Parameters:
stateName - String the name of the state.
stateDescription - String the name of the instance.
stateHandler - Class the handler instance.
Returns:
State

postPerform

protected void postPerform(State nextState,
                           ExpressoRequest request,
                           ExpressoResponse response)
                    throws ControllerException
Template Method, allowing a subclass to into actions after the invocation of any state in this controller.

Overrides:
postPerform in class AbstractDBController
Parameters:
nextState - the state to be performed
request - the request object
response - the response object
Throws:
ControllerException - upon error.

prePerform

protected void prePerform(State nextState,
                          ExpressoRequest request,
                          ExpressoResponse response)
                   throws ControllerException
Template Method, allowing a subclass to do an action after any state in this controller is performed.

Overrides:
prePerform in class AbstractDBController
Parameters:
nextState - the state to be performed
request - the request object
response - the response object
Throws:
ControllerException - upon error.

newExpressoState

public ExpressoResponse newExpressoState(String newState,
                                         ExpressoRequest myRequest)
                                  throws ControllerException
This is the method where all of the real work of the controller is done.

Overrides:
newExpressoState in class Controller
Parameters:
newState - The new state to transition to
myRequest - The calling controllerRequest object.
Returns:
a newly instantiated ControllerResponse for this state.
Throws:
ControllerException - on Error

locator

protected ComponentServiceLocator locator()
Retrieve the application locator. Example Usage in a subclass statehandler.

this.locator().locate(Cache.class);

Returns:
ComponentServiceLocator instance.
Throws:
IllegalStateException - if the attached schema does not implement the ComponentServiceLocator interface.

locate

public Object locate(Object serviceKey)
              throws NoSuchServiceException,
                     IllegalArgumentException
Retrieves the desired service defined by the key. Due to API issues, this retrieves the Controller-Level services, rather than the request level services.

Specified by:
locate in interface ComponentServiceLocator
Parameters:
serviceKey - Object usually the service interface class, but may be other object.
Returns:
Object.
Throws:
NoSuchServiceException - if unable to locate the service.
IllegalArgumentException - if service key is null.


Copyright © 2004-2006 Codeguild, Inc.. All Rights Reserved.