com.ibm.workflow.portlet.client
Class GenericCommandHandler

java.lang.Object
  |
  +--com.ibm.workflow.portlet.client.GenericCommandHandler
All Implemented Interfaces:
CommandHandler
Direct Known Subclasses:
AdminLogonHandler, AuditTrailHandler, BasicAuthenticationHandler, EmailHandler, HTMLDocHandler, MonitorHandler, ShowConfigHandler, StarterPEAHandler

public abstract class GenericCommandHandler
extends java.lang.Object
implements CommandHandler

This class provides a generic implementation of CommandHandler's execute() method which maps the command name directly to the name of the method to be invoked and allows easy access to the ApplicationContext.


Constructor Summary
GenericCommandHandler()
           
 
Method Summary
 void destroy()
          This convenience method has an empty implementation.
 ResponsePage execute(java.lang.String command, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          This method is called by the BuiltinHandler to invoke user-defined commands.
 Config getConfig()
          This method allows subclasses to access the Web Client's configuration.
 ApplicationContext getContext()
          This method allows subclasses to access the Web Client's context.
 byte[] getCredentials(javax.servlet.http.HttpServletRequest request)
          This method returns null so the normal logon processing takes place.
 java.lang.String getHandlerInfo()
          Returns a String that contains information about the handler such as its author, version, and copyright information.
static SessionContext getSessionContext(javax.servlet.http.HttpServletRequest request)
          This method allows subclasses to extract the SessionContext from an HTTP request object.
 java.lang.String getTriggerTagFor(int list, RequestContext context)
          Returns a String that contains HTML code to trigger a user defined command.
 void init(Config config)
          This method must be called by subclasses in their init() method.
 void onLogoff(SessionContext context)
          This hook has an empty implementation.
 void onLogon(RequestContext context)
          This hook has an empty implementation.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GenericCommandHandler

public GenericCommandHandler()
Method Detail

init

public void init(Config config)
This method must be called by subclasses in their init() method.
Specified by:
init in interface CommandHandler
Parameters:
config - The servlet's configuration and initialization parameters

destroy

public void destroy()
This convenience method has an empty implementation. Overwrite it in your own handler to free any resources.
Specified by:
destroy in interface CommandHandler

getHandlerInfo

public java.lang.String getHandlerInfo()
Returns a String that contains information about the handler such as its author, version, and copyright information. You must override this method before it returns this information. If you do not override this method, it returns the class name.
Specified by:
getHandlerInfo in interface CommandHandler
Returns:
The class name until you override this method

getTriggerTagFor

public java.lang.String getTriggerTagFor(int list,
                                         RequestContext context)
Returns a String that contains HTML code to trigger a user defined command.
Specified by:
getTriggerTagFor in interface CommandHandler
Parameters:
list - Denotes the list for which the trigger tag is queried.
context - The RequestContext which was passed to the Viewer calling this method.
Returns:
An empty String until you override this method.

execute

public ResponsePage execute(java.lang.String command,
                            javax.servlet.http.HttpServletRequest request,
                            javax.servlet.http.HttpServletResponse response)
                     throws java.lang.NoSuchMethodException,
                            ClientException
This method is called by the BuiltinHandler to invoke user-defined commands. It maps any command commandName to an invocation of the public ResponsePage commandName(HttpServletRequest, HttpServletResponse) method, stripping the recommended x- prefix if present.
Specified by:
execute in interface CommandHandler
Parameters:
command - The name of the command
request - The request the client has made of the servlet
response - The response the servlet sends to the client
Returns:
The result page to be sent to the client
Throws:
com.ibm.workflow.servlet.client.ClientException - If an error occurred.

onLogon

public void onLogon(RequestContext context)
This hook has an empty implementation.
Specified by:
onLogon in interface CommandHandler
Parameters:
context - The RequestContext of the newly added session

onLogoff

public void onLogoff(SessionContext context)
This hook has an empty implementation.
Specified by:
onLogoff in interface CommandHandler
Parameters:
context - The SessionContext of the session to be removed

getCredentials

public byte[] getCredentials(javax.servlet.http.HttpServletRequest request)
                      throws ClientException
This method returns null so the normal logon processing takes place.
Specified by:
getCredentials in interface CommandHandler
Parameters:
request - The logon request sent by the client
Returns:
null
Throws:
com.ibm.workflow.servlet.client.ClientException - If an error occurred.

getConfig

public final Config getConfig()
This method allows subclasses to access the Web Client's configuration.
Returns:
The configuration

getContext

public final ApplicationContext getContext()
This method allows subclasses to access the Web Client's context.
Returns:
The ApplicationContext object

getSessionContext

public static SessionContext getSessionContext(javax.servlet.http.HttpServletRequest request)
                                        throws ClientException
This method allows subclasses to extract the SessionContext from an HTTP request object.
Parameters:
request - The request the client has made of the servlet
Returns:
The SessionContext object
Throws:
com.ibm.workflow.servlet.client.ClientException - If no session is associated with the HTTP request.


© Copyright IBM Corporation 2002, 2008. All Rights Reserved.