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

Quick Search    Search Deep

de.danet.an.util.cocoon.action
Class ActionHandler  view ActionHandler download ActionHandler.java

java.lang.Object
  extended byde.danet.an.util.cocoon.action.ActionHandler
All Implemented Interfaces:
PkgConsts, de.danet.an.util.UtilConsts

public class ActionHandler
extends java.lang.Object
implements de.danet.an.util.UtilConsts, PkgConsts

ActionHandler is the base class for web action request handlers used in Cocoon 2. A derived class creates one or more instances of itself (and thus ActionHandler) by calling the constructor with the name of its method that is to be made invokable as an argument.


Field Summary
static java.lang.String ACTION_DISPATCHER_PREFIX
          Prefix used for action dispatcher related session attributes.
static java.lang.String ACTION_IDENTIFIER
          Identifier for Web Action Action in requests.
static java.lang.String ACTION_PREREQUISITE
          Identifier for Web Action Action in requests.
private static org.apache.commons.logging.Log logger
           
private  java.lang.reflect.Method myActionMethod
           
private  java.lang.String myActionName
           
static java.lang.String NEXT_PAGE_PARAM
          Name of parameter to select next page.
static java.lang.String NEXT_PAGE_SITEMAP_PARAMTER
          Parameter set in sitemap to denote selected next page.
static java.lang.String PARAM_NAME_PREFIX
          Prefix for Web Action Parameter identifier in requests.
private  int paramCnt
           
private static org.apache.log4j.Category UILOG
           
private  java.lang.Class[] xtraParams
           
 
Fields inherited from interface de.danet.an.util.UtilConsts
I18N_PROPS_UTIL
 
Constructor Summary
protected ActionHandler(java.lang.String methodName)
          Used by derived classes to construct web action handlers.
protected ActionHandler(java.lang.String methodName, java.lang.String actionName)
          An alternative constructor that may be used to assign an action name (used in the HTTP request) that differs from the method name.
 
Method Summary
(package private)  void addToMap(java.util.Map map, boolean verifyDuplicates)
          Adds this ActionHandler to a map that associates action names with ActionHandlers.
private  java.lang.reflect.Method findMethod(java.lang.String methodName)
          Search method with given name in current (derived) class.
(package private)  void handleRequest(org.apache.cocoon.environment.Request request, SitemapParams sitemapParams)
          Handles the given request.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

private static final org.apache.commons.logging.Log logger

UILOG

private static final org.apache.log4j.Category UILOG

myActionName

private java.lang.String myActionName

myActionMethod

private java.lang.reflect.Method myActionMethod

paramCnt

private int paramCnt

xtraParams

private java.lang.Class[] xtraParams

NEXT_PAGE_PARAM

public static final java.lang.String NEXT_PAGE_PARAM
Name of parameter to select next page.

See Also:
Constant Field Values

NEXT_PAGE_SITEMAP_PARAMTER

public static final java.lang.String NEXT_PAGE_SITEMAP_PARAMTER
Parameter set in sitemap to denote selected next page.

See Also:
Constant Field Values

ACTION_IDENTIFIER

public static final java.lang.String ACTION_IDENTIFIER
Identifier for Web Action Action in requests.

See Also:
Constant Field Values

ACTION_PREREQUISITE

public static final java.lang.String ACTION_PREREQUISITE
Identifier for Web Action Action in requests.

See Also:
Constant Field Values

PARAM_NAME_PREFIX

public static final java.lang.String PARAM_NAME_PREFIX
Prefix for Web Action Parameter identifier in requests.

See Also:
Constant Field Values

ACTION_DISPATCHER_PREFIX

public static final java.lang.String ACTION_DISPATCHER_PREFIX
Prefix used for action dispatcher related session attributes.

See Also:
Constant Field Values
Constructor Detail

ActionHandler

protected ActionHandler(java.lang.String methodName)
Used by derived classes to construct web action handlers. Web action handlers thus constructed are assembled into collections by a static method ActionDispatcher suite() that must be supplied by every class derived from ActionHandler. A derived class thus looks like:
 public class MyActs extends ActionHandler {
     public MyActs(String method) {
         super(method);
     }

     public static ActionDispatcher suite() {
         ActionDispatcher suite = new ActionDispatcher();
         suite.addHandler(new MyActs("addSomething"));
     }

     public void addSomething(String arg1, String arg2) {
         // This function may be invoked with a request
         // ...?AMN=addSomething&MP1=arg1&MP2=arg2
     }
 }
 
The method that handles the action may have parameters of type String>String that correspond to the request parameters MPn. Before the first parameter of type String, additional parameters of the following types may occur:
org.apache.cocoon.environment.Request
For a parameter of that type, the request object is passed to the method.
org.apache.cocoon.environment.Session
For a parameter of that type, the session object is passed to the method.
de.danet.an.util.action.SitemapParams
For a parameter of that type, the sitemap parameter map that will be returned to the sitemap after the method invocation will be passed to the method.

The methods may only throw RemoteExceptions>RemoteExceptions, see handleRequest 55 .


ActionHandler

protected ActionHandler(java.lang.String methodName,
                        java.lang.String actionName)
An alternative constructor that may be used to assign an action name (used in the HTTP request) that differs from the method name.

Method Detail

addToMap

void addToMap(java.util.Map map,
              boolean verifyDuplicates)
Adds this ActionHandler to a map that associates action names with ActionHandlers.


handleRequest

void handleRequest(org.apache.cocoon.environment.Request request,
                   SitemapParams sitemapParams)
Handles the given request. This method is called only if the request's AMN parameter matches this handlers's action name, i.e. this method need not evaluate the AMN parameter.

If the method throws a RemoteException>RemoteException the error message with key error.resourceNotAvailable is added to the error messages with CocoonUtil.logErrorMapped>CocoonUtil.logErrorMapped 55 .


findMethod

private java.lang.reflect.Method findMethod(java.lang.String methodName)
Search method with given name in current (derived) class. The method name has to be unique within the class or otherwise an IllegalArgumentException is thrown.