com.ibm.workflow.servlet.sample
Class CommandHandlerAdapter

java.lang.Object
  |
  +--com.ibm.workflow.servlet.sample.CommandHandlerAdapter
All Implemented Interfaces:
CommandHandler

public class CommandHandlerAdapter
extends java.lang.Object
implements CommandHandler

CommandHandlerAdapter acts as a CommandHandler which aggregates other CommandHandlers. This will be useful if multiple CommandHandlers should be used together in a single MQWF Web Client servlet.

This sample also demonstrates how to use the Config class to read custom settings from WebClient.properties.

For details on how to run this sample, see the Samples section.


Constructor Summary
CommandHandlerAdapter()
           
 
Method Summary
 void destroy()
          This method is called by the Web Client in its servlet's destroy() method.
 ResponsePage execute(java.lang.String command, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          This method is called every time a custom command is to be executed.
 byte[] getCredentials(javax.servlet.http.HttpServletRequest request)
          This method is called by the BuiltinHandler as a pre-logon hook to enable third party authentication.
 java.lang.String getHandlerInfo()
          Returns information about the handler, such as author, version, and copyright.
 java.lang.String getTriggerTagFor(int list, RequestContext context)
          This method can be called by Viewers to obtain a HTML tag that triggers user-defined commands.
 void init(Config cfg)
          This method is called by the Web Client in its servlet's init() method.
 void onLogoff(SessionContext context)
          This method is called whenever a user has logged off.
 void onLogon(RequestContext context)
          This method is called whenever a new user has logged on.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CommandHandlerAdapter

public CommandHandlerAdapter()
Method Detail

getHandlerInfo

public final java.lang.String getHandlerInfo()
Returns information about the handler, such as author, version, and copyright.
Specified by:
getHandlerInfo in interface CommandHandler
Returns:
a String containing handler information

getTriggerTagFor

public final java.lang.String getTriggerTagFor(int list,
                                               RequestContext context)
This method can be called by Viewers to obtain a HTML tag that triggers user-defined commands.
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:
A string containing HTML tags for the icons to be displayed on list.

init

public final void init(Config cfg)
This method is called by the Web Client in its servlet's init() method. Here the [CommandHandlerAdapter] section of the WebClient.properties file is read and the CommandHandlers registered there are created.
Specified by:
init in interface CommandHandler
Parameters:
config - The servlet's configuration and initialization parameters

destroy

public final void destroy()
This method is called by the Web Client in its servlet's destroy() method. This call just is dispatched to the registered command handlers.
Specified by:
destroy in interface CommandHandler

onLogon

public final void onLogon(RequestContext context)
This method is called whenever a new user has logged on. This call just is dispatched to the registered command handlers.
Specified by:
onLogon in interface CommandHandler
Parameters:
context - The RequestContext for the newly added session.

onLogoff

public final void onLogoff(SessionContext context)
This method is called whenever a user has logged off. This call just is dispatched to the registered command handlers.
Specified by:
onLogoff in interface CommandHandler
Parameters:
context - The SessionContext for the session that will be removed.

getCredentials

public final byte[] getCredentials(javax.servlet.http.HttpServletRequest request)
                            throws ClientException
This method is called by the BuiltinHandler as a pre-logon hook to enable third party authentication.
Specified by:
getCredentials in interface CommandHandler
Parameters:
request - The logon request sent by the client
Returns:
null if normal logon processing is required or the credentials extracted from the request that should be used to log on to Workflow.
Throws:
ClientException - If an error occurred.

execute

public final ResponsePage execute(java.lang.String command,
                                  javax.servlet.http.HttpServletRequest request,
                                  javax.servlet.http.HttpServletResponse response)
                           throws ClientException
This method is called every time a custom command is to be executed. It returns the ResponsePage representing the results of command or null if the command was not recognized.
Specified by:
execute in interface CommandHandler
Parameters:
command - The name of the command (the value of the command request parameter)
request - The request the client has made of the servlet
response - The response the servlet sends to the client
Returns:
The page representing the results of command
Throws:
ClientException - If an error occurred.


© Copyright IBM Corporation 1999, 2007. All Rights Reserved.