atg.integrations
Class MapRPCDroplet

java.lang.Object
  extended by atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
      extended by atg.nucleus.GenericService
          extended by atg.nucleus.TimedOperationService
              extended by atg.nucleus.servlet.ServletService
                  extended by atg.nucleus.servlet.HttpServletService
                      extended by atg.servlet.DynamoServlet
                          extended by atg.integrations.MapRPCDroplet
All Implemented Interfaces:
atg.naming.AbsoluteNameable, NameContextBindingListener, NameContextElement, atg.naming.NameContextParentable, NameResolver, AdminableService, atg.nucleus.Configured, ApplicationLogging, atg.nucleus.logging.ApplicationLoggingSender, atg.nucleus.logging.TraceApplicationLogging, VariableArgumentApplicationLogging, ComponentNameResolver, Service, ServiceListener, ParameterServlet, java.util.EventListener, javax.servlet.Servlet

public class MapRPCDroplet
extends DynamoServlet

This Servlet executes the RPC Command and renders its output paramter. Also sets the result parameter with output of the command execution. If an exception is generated by the command execution then an error parameter is rendered setting exception< parameter with the exception thrown.

Input parameters are passed into this droplet in different ways as following.

It is illegal to pass parameters from different locations, ServletException is thrown when this happens. One exception to this is if you want to set some default value for any parameters, you should populate the Map property of this with default values and make an entry for the key from the page context.

A complete description of the parameters to this droplet are:

command
The parameter that defines the Command to execute. This droplet executes this Command passing the Map input parameter. This parameter can also be defined in the properties of this droplet, but it is illegal to pass both of them.
inputParameters
The parameter that defines Map to pass to Command. This contains the name/value pairs of the parameters to pass to the Command. This parameter can also be defined in the properties of this droplet, but it is illegal to pass both of them.
inputParameterNames
This parameter defines comma separated list of parameter names this droplet looks for in the page context. This parameter is useful when you decide the parameters to pass during run time. You set the parameter names in this property delimited with comma, and pass the parameter name/values to the droplet. This is also useful to set default values for some of the properties, and pass the rest of the properties at run time. You set the default parameters in the inputProperties Map property of the droplet, and just pass the parameter names in this parameter. This droplet parses the parameter names in this property and tries to get the value for these parameters from the page. If any of the parameters is not found in the page, this droplet looks for it in the inputProperties Map property and populates the value of this parameter. It is illegal to pass this parameter and inputParameters to the droplet. But it is legal to pass this parameter and setting the inputProperties in the properties of this droplet.
{propertyName}
Page parameter that corresponds to a property name that appears in the inputParameterNames parameter.
output
This parameter is rendered if Command is executed successfully.
error
This parameter is rendered if Command throws an exception while execution.
result
This parameter is set to the result from the Command execution when output parameter is rendered.
exception
This parameter is set to the exception from the Command execution when error parameter is rendered.
The following are the properties of this droplet defined in the Nucleus properties file of this droplet.
command
This property defines the Command to execute. This droplet executes this Command with the Map input passed. This property can also be passed as a input paramter to the droplet, but it is illegal to pass both.
inputParameters
This property defines the Map to pass to Command. This contains name/value pairs of the parameters to pass to Command. This property can also be passed as a page parameter to the droplet, but it is illegal to pass both. But this property can be set in conjunction with inputParameterNames page parameter to set default values to some of the parameters.

The following is the sample code to use this droplet:


 <droplet bean="/atg/integrations/MapRPCDroplet"> 
    <param name="command" value="bean:/atg/integrations/jdbc/QueryForUser"/>
    <param name="inputParameterNames" value="UserId">
    <param name="UserId" value="bean:Profile.Id">

    <java>/* a result DynamicBean put into the result /</java>
    <oparam name="output">
          The users email address is: <valueof param="result.emailAddress"/>
    </oparam>

    <oparam name="error">
        Unable to execute query, the following exceptions occured: <valueof param="exception"/>
    </oparam>
</droplet>


Field Summary
static java.lang.String CLASS_VERSION
           
static ParameterName COMMAND
           
static java.lang.String ERROR
           
static java.lang.String EXCEPTION
           
static ParameterName INPUT_PARAMETERS
           
static ParameterName INPUT_PARAMTER_NAMES
           
static java.lang.String OUTPUT
           
static java.lang.String RESULT
           
 
Fields inherited from class atg.servlet.DynamoServlet
mAllowCleanupRequest, mParameters
 
Fields inherited from class atg.nucleus.servlet.ServletService
SERVLET_INFO_KEY
 
Fields inherited from class atg.nucleus.GenericService
SERVICE_INFO_KEY
 
Fields inherited from interface atg.nucleus.logging.TraceApplicationLogging
DEFAULT_LOG_TRACE_STATUS
 
Fields inherited from interface atg.nucleus.logging.ApplicationLogging
DEFAULT_LOG_DEBUG_STATUS, DEFAULT_LOG_ERROR_STATUS, DEFAULT_LOG_INFO_STATUS, DEFAULT_LOG_WARNING_STATUS
 
Constructor Summary
MapRPCDroplet()
           
 
Method Summary
 CommandResult executeCommand(Command pCommand, java.util.Map pInputMap)
          Executes the command with the inputMap passed.
 Command getCommand()
          This is the Command object the droplet tries to execute with the given input.
protected  java.util.Map getInputParameterMap(DynamoHttpServletRequest pRequest, DynamoHttpServletResponse pResponse)
          Returs the input parameters configured for this droplet.
 java.util.Properties getInputParameters()
          This property indicates the map property to pass as the input to the Command execution.
protected  java.util.Map getInputParameters(Command pCommand, DynamoHttpServletRequest pRequest, DynamoHttpServletResponse pResponse)
          Returns the input parameters Map to pass to Command.
protected  java.lang.Object getParameterValue(java.lang.String pParameterName, DynamoHttpServletRequest pRequest, DynamoHttpServletResponse pResponse)
          Returns the parameter value for the given parameter name.
 void service(DynamoHttpServletRequest pRequest, DynamoHttpServletResponse pResponse)
          Executes the Command with the given input parameters and renders the output paramter, setting result paramter to the CommandResult from Command execution.
 void setCommand(Command pCommand)
          Sets Command to Execute.
 void setInputParameters(java.util.Properties pInputParameters)
          Sets input parameters
 
Methods inherited from class atg.servlet.DynamoServlet
doDelete, doGet, doPost, doPut, getParameter, getParameters, getServletContext, init, service, service, setParameter
 
Methods inherited from class atg.nucleus.servlet.ServletService
destroy, getServletConfig, getServletInfo, setServletInfo
 
Methods inherited from class atg.nucleus.TimedOperationService
getAverageRequestHandlingTime, getHandledRequestCount, getRequestStartTime, getTotalRequestHandlingTime, isKeepingStatistics, notifyHandledRequest, resetStatistics, setKeepingStatistics
 
Methods inherited from class atg.nucleus.GenericService
addLogListener, createAdminServlet, doStartService, doStopService, getAbsoluteName, getAdminServlet, getAdminServletOutputStreamEncoding, getLoggingForVlogging, getLogListenerCount, getLogListeners, getName, getNameContext, getNucleus, getRoot, getServiceConfiguration, getServiceInfo, isAdminServletUseServletOutputStream, isLoggingDebug, isLoggingError, isLoggingInfo, isLoggingTrace, isLoggingWarning, isRunning, logDebug, logDebug, logDebug, logError, logError, logError, logInfo, logInfo, logInfo, logTrace, logTrace, logTrace, logWarning, logWarning, logWarning, nameContextElementBound, nameContextElementUnbound, removeLogListener, reResolveThis, resolveName, resolveName, resolveName, resolveName, sendLogEvent, setAdminServletOutputStreamEncoding, setAdminServletUseServletOutputStream, setLoggingDebug, setLoggingError, setLoggingInfo, setLoggingTrace, setLoggingWarning, setNucleus, setServiceInfo, startService, stopService
 
Methods inherited from class atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
vlogDebug, vlogDebug, vlogDebug, vlogDebug, vlogDebugTrace, vlogError, vlogError, vlogError, vlogError, vlogInfo, vlogInfo, vlogInfo, vlogInfo, vlogTrace, vlogTrace, vlogTrace, vlogTrace, vlogWarning, vlogWarning, vlogWarning, vlogWarning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CLASS_VERSION

public static java.lang.String CLASS_VERSION

INPUT_PARAMTER_NAMES

public static final ParameterName INPUT_PARAMTER_NAMES

INPUT_PARAMETERS

public static final ParameterName INPUT_PARAMETERS

COMMAND

public static final ParameterName COMMAND

OUTPUT

public static final java.lang.String OUTPUT
See Also:
Constant Field Values

RESULT

public static final java.lang.String RESULT
See Also:
Constant Field Values

EXCEPTION

public static final java.lang.String EXCEPTION
See Also:
Constant Field Values

ERROR

public static final java.lang.String ERROR
See Also:
Constant Field Values
Constructor Detail

MapRPCDroplet

public MapRPCDroplet()
Method Detail

getCommand

public Command getCommand()
This is the Command object the droplet tries to execute with the given input. This parameter can be passed from the page context also as command. But it is invalid to pass it using both ways.


setCommand

public void setCommand(Command pCommand)
Sets Command to Execute.

Parameters:
pCommand -

getInputParameters

public java.util.Properties getInputParameters()
This property indicates the map property to pass as the input to the Command execution. This property can also be passed from page context, but it is illegal to pass both.

Returns:
input parameters

setInputParameters

public void setInputParameters(java.util.Properties pInputParameters)
Sets input parameters

Parameters:
pInputParameters -

service

public void service(DynamoHttpServletRequest pRequest,
                    DynamoHttpServletResponse pResponse)
             throws javax.servlet.ServletException,
                    java.io.IOException
Executes the Command with the given input parameters and renders the output paramter, setting result paramter to the CommandResult from Command execution. If command execution throws an exception it renders the error parameter, setting the exception to the exception thrown.

Overrides:
service in class DynamoServlet
Parameters:
pRequest -
pResponse -
Throws:
javax.servlet.ServletException - if input paramters are configured invalidly like, setting the inputParameters in the nucleus propeties file and also passing it from the page context, or passing both inputParameters and inputParameterNames from the page context.
java.io.IOException - an error occurred reading data from the request or writing data to the response.

executeCommand

public CommandResult executeCommand(Command pCommand,
                                    java.util.Map pInputMap)
                             throws CommandInvocationException,
                                    CommandTimeoutException
Executes the command with the inputMap passed. This also keeps track of performance metrics using performance monitor API.

Parameters:
pCommand - the command to execute
pInputMap - the input map to pass to command.
Returns:
the CommandResult from Command execution
Throws:
CommandInvocationException - if Command execution throws any exception.
CommandTimeoutException - if timeout occurs while invoking the command.
InvalidInputException - if input object passed is invalid.

getInputParameters

protected java.util.Map getInputParameters(Command pCommand,
                                           DynamoHttpServletRequest pRequest,
                                           DynamoHttpServletResponse pResponse)
                                    throws javax.servlet.ServletException,
                                           java.io.IOException
Returns the input parameters Map to pass to Command.

Returns:
the input Map to pass to Command.
Throws:
javax.servlet.ServletException - if validity checks fail for input paramters.
java.io.IOException

getInputParameterMap

protected java.util.Map getInputParameterMap(DynamoHttpServletRequest pRequest,
                                             DynamoHttpServletResponse pResponse)
                                      throws javax.servlet.ServletException,
                                             java.io.IOException
Returs the input parameters configured for this droplet. This method performs all the validity checks on the input and raise ServletException if any of them fail.

Throws:
javax.servlet.ServletException - if validity checks fail for input paramters.
java.io.IOException

getParameterValue

protected java.lang.Object getParameterValue(java.lang.String pParameterName,
                                             DynamoHttpServletRequest pRequest,
                                             DynamoHttpServletResponse pResponse)
                                      throws javax.servlet.ServletException,
                                             java.io.IOException
Returns the parameter value for the given parameter name. It retrieves the value from page context, and if it is not found then tries to retrieve it from the inputParameters map.

Parameters:
pParameterName - the parameter name to fetch the value for.
Throws:
javax.servlet.ServletException
java.io.IOException