org.apache.commons.chain.web.servlet
Class RequestParameterMapper

java.lang.Object
  extended by org.apache.commons.chain.web.servlet.RequestParameterMapper
All Implemented Interfaces:
Command

public class RequestParameterMapper
extends java.lang.Object
implements Command

Command that uses a specified request parameter to select a Command from the appropriate Catalog, and execute it. To use this command, you would typically map an instance of ChainProcessor to a wildcard pattern like "*.execute" and then arrange that this is the default command to be executed. In such an environment, a request for the context-relative path "/foo.execute?command=bar" would cause the "/bar" command to be loaded and executed.

Author:
Craig R. McClanahan

Field Summary
private  java.lang.String catalogKey
           
private  java.lang.String parameter
           
 
Fields inherited from interface org.apache.commons.chain.Command
CONTINUE_PROCESSING, PROCESSING_COMPLETE
 
Constructor Summary
RequestParameterMapper()
           
 
Method Summary
 boolean execute(Context context)
          Look up the specified request paramater for this request, and use it to select an appropriate Command to be executed.
 java.lang.String getCatalogKey()
          Return the context key under which our Catalog has been stored.
 java.lang.String getParameter()
          Return the name of the request parameter to use for selecting the Command to be executed.
 void setCatalogKey(java.lang.String catalogKey)
          Set the context key under which our Catalog has been stored.
 void setParameter(java.lang.String parameter)
          Set the name of the request parameter to use for selecting the Command to be executed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

catalogKey

private java.lang.String catalogKey

parameter

private java.lang.String parameter
Constructor Detail

RequestParameterMapper

public RequestParameterMapper()
Method Detail

getCatalogKey

public java.lang.String getCatalogKey()

Return the context key under which our Catalog has been stored.

Returns:
The context key for the Catalog.

setCatalogKey

public void setCatalogKey(java.lang.String catalogKey)

Set the context key under which our Catalog has been stored.

Parameters:
catalogKey - The new catalog key

getParameter

public java.lang.String getParameter()

Return the name of the request parameter to use for selecting the Command to be executed.

Returns:
The name of the request parameter.

setParameter

public void setParameter(java.lang.String parameter)

Set the name of the request parameter to use for selecting the Command to be executed.

Parameters:
parameter - The new parameter name

execute

public boolean execute(Context context)
                throws java.lang.Exception

Look up the specified request paramater for this request, and use it to select an appropriate Command to be executed.

Specified by:
execute in interface Command
Parameters:
context - Context for the current request
Returns:
The result of executing the Command for the request parameter.
Throws:
java.lang.Exception - if there is a problem executing the Command for the request parameter.