Device format algorithm

The device format algorithm is used to determine the appropriate JSP to use as the response for a particular request. When a request is received and the message mapper is used to convert the request into a CommandProperty object, the message mapper and adapter used to process the request determine the appropriate device format for generating the content of the response. The ID of the message mapper is added to the device format ID of the adapter to determine the overall device format ID of the response.

The overall device format ID and the VIEWNAME are used to get the appropriate JSP from the Struts configuration file, which generates the content of the response.

Each adapter accepting requests and using the message mapper is given a device format ID. This ID is defined in the WebSphere Commerce configuration file. The default device format ID for each receiving device using the message mapper is in intervals of -10000 as follows.

Program adapter for XML over HTTP
The device format is -10000.
Program adapter for XML over IBM MQ
The device format is -20000.
Program adapter for legacy messages
The device format is -30000.

To determine the appropriate JSP and view command to call the JSP, the message mapper ID (as defined in the topic Message mappers) is added to the adapter's device format ID to determine the device format ID for the response view. For example, a pre-defined XML message over HTTP request comes in through the HTTP, the message uses the message mapper ID of -1 (WCS.INTEGRATION). The message uses the message mapper to invoke a command. If a response is required, the command forwards to an OK view or an ERROR view. Since the base device format ID is -10000 and the messagemapper id is -1, the device format ID required to be defined will be -10001. (That is the device format ID plus the message mapper ID.) The OK view or ERROR view defined in Struts configuration file will have the device format id of -10001. If the view for this device format ID -10001 cannot be found the default device format ID will be used. In this case, an XML over HTTP request, the default device format ID of -10000 will be used. For IBM MQ adapter requests, the default device format ID is -20000.

The interface name and class name are different for each device type. An HTTP response will use the com.ibm.commerce.command.ForwardViewCommand interface with the com.ibm.commerce.command.HttpForwardViewCommandImpl class name. The IBM MQ adapter response will use the com.ibm.commerce.messaging. viewcommands.MessagingViewCommand interface and com.ibm.commerce.messaging. viewcommands.MessagingViewCommandImpl class.

This algorithm allows a maximum of 9999 possible message mappers to be defined with one adapter. The configuration file for each message mapper contains an ID number in intervals of 1. To configure additional adapters that use the message mapper, the message mapper should be given a device format ID that is an interval of 10000. For example, a new request mechanism could be given a device format interval of 40000.

Notes:

  1. If the calculated device format ID cannot be found, the default device format ID of the adapter is used to obtain the result. This number is configurable in the HTTP adapter configuration.
  2. The size of the interval is not important. For example, if only 2 message mappers exist, then the interval can be of size 3. The interval 10000 is used by default.

Examples

  1. An inbound message is handled by a message mapper with an ID of -1 and by the program adapter which has a device format ID of -10000. Following the device format algorithm, the device format ID generated for a response to that inbound message would be -10001. The JSP file defined in the Struts configuration file for the VIEWNAME and the device format ID of -10001 is used for creating the response.
  2. Alternatively, an inbound message is handled by the same message mapper with the ID of -1, but is handled by the IBM MQ adapter, which has a device format ID of -20000. The generated device format ID for the response to that message would be -20001. Thus, the JSP file defined in the Struts configuration file for the VIEWNAME and the device format ID of -20001 is used for creating the response. Note that even though the request can use the same JSP for responding to the request, the class used to call the JSP may differ.