jodd.madvoc.component
Class MadvocController

java.lang.Object
  extended by jodd.madvoc.component.MadvocController
Direct Known Subclasses:
PetiteMadvocController

public class MadvocController
extends java.lang.Object

Madvoc controller invokes actions for action path and renders action results. It also builds action objects and result paths. It handles intialization of interceptors and results.


Field Summary
protected  ActionPathMapper actionPathMapper
           
protected  ActionPathRewriter actionPathRewriter
           
protected  javax.servlet.ServletContext applicationContext
           
protected  ContextInjector contextInjector
           
protected  InterceptorsManager interceptorsManager
           
protected  MadvocConfig madvocConfig
           
protected  ResultMapper resultMapper
           
protected  ResultsManager resultsManager
           
 
Constructor Summary
MadvocController()
           
 
Method Summary
protected  java.lang.Object createAction(java.lang.Class actionClass)
          Creates new action object from ActionConfig using default contructor.
protected  ActionRequest createActionRequest(ActionConfig actionConfig, java.lang.Object action, javax.servlet.http.HttpServletRequest servletRequest, javax.servlet.http.HttpServletResponse servletResponse)
          Creates new action request.
 javax.servlet.ServletContext getApplicationContext()
          Returns application context set during the initialization.
 void init(javax.servlet.ServletContext servletContext)
          Initializes controller by providing application context.
protected  void initializeActionConfig(ActionConfig cfg)
          Initializes action configuration on first use.
 java.lang.String invoke(java.lang.String actionPath, javax.servlet.http.HttpServletRequest servletRequest, javax.servlet.http.HttpServletResponse servletResponse)
          Invokes action registered to provided action path, Provides action chaining, by invoking the next action request.
protected  void invokeAndRender(ActionRequest request)
          Invokes action request (interceptors and action method) and renders result.
 void render(ActionRequest req, java.lang.Object resultObject)
          Invokes a result after the action invocation.
protected  ActionConfig resolveActionConfig(java.lang.String actionPath, java.lang.String httpMethod)
          Resolves action config from action path and http method.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

madvocConfig

@PetiteInject
protected MadvocConfig madvocConfig

actionPathMapper

@PetiteInject
protected ActionPathMapper actionPathMapper

actionPathRewriter

@PetiteInject
protected ActionPathRewriter actionPathRewriter

interceptorsManager

@PetiteInject
protected InterceptorsManager interceptorsManager

contextInjector

@PetiteInject
protected ContextInjector contextInjector

resultsManager

@PetiteInject
protected ResultsManager resultsManager

resultMapper

@PetiteInject
protected ResultMapper resultMapper

applicationContext

protected javax.servlet.ServletContext applicationContext
Constructor Detail

MadvocController

public MadvocController()
Method Detail

init

public void init(javax.servlet.ServletContext servletContext)
Initializes controller by providing application context.


getApplicationContext

public javax.servlet.ServletContext getApplicationContext()
Returns application context set during the initialization.


invoke

public java.lang.String invoke(java.lang.String actionPath,
                               javax.servlet.http.HttpServletRequest servletRequest,
                               javax.servlet.http.HttpServletResponse servletResponse)
                        throws java.lang.Exception
Invokes action registered to provided action path, Provides action chaining, by invoking the next action request. Returns null if action path is consumed and has been invoked by this controller; otherwise the action path string is returned (it might be different than original one, provided in arguments). On first invoke, initializes the action configuration before further proceeding.

Throws:
java.lang.Exception
See Also:
ActionMethodParser.buildActionPath(String, String, String, String, String)

invokeAndRender

protected void invokeAndRender(ActionRequest request)
                        throws java.lang.Exception
Invokes action request (interceptors and action method) and renders result.

Throws:
java.lang.Exception

render

public void render(ActionRequest req,
                   java.lang.Object resultObject)
            throws java.lang.Exception
Invokes a result after the action invocation.

Result value consist of two parts: type and value. Type is optional and, if exists, it is separated by semi-colon from the value. If type is not specified, the default result type is used. Type defines which ActionResult should be used for rendering the value.

Result value is first checked against aliased values. Then, it is resolved and then passed to the founded ActionResult.

Throws:
java.lang.Exception
See Also:
ActionResult.render(jodd.madvoc.ActionRequest, Object, String, String)

resolveActionConfig

protected ActionConfig resolveActionConfig(java.lang.String actionPath,
                                           java.lang.String httpMethod)
Resolves action config from action path and http method. Returns null if action config not found. Performs initialization of founded action configig, if necessary.


initializeActionConfig

protected void initializeActionConfig(ActionConfig cfg)
Initializes action configuration on first use. Resolves all interceptors and injects context parameters.


createAction

protected java.lang.Object createAction(java.lang.Class actionClass)
Creates new action object from ActionConfig using default contructor.


createActionRequest

protected ActionRequest createActionRequest(ActionConfig actionConfig,
                                            java.lang.Object action,
                                            javax.servlet.http.HttpServletRequest servletRequest,
                                            javax.servlet.http.HttpServletResponse servletResponse)
Creates new action request.

Parameters:
actionConfig - action configuration
action - action object
servletRequest - http request
servletResponse - http response
Returns:
action request


Copyright © 2003-2011 Jodd Team