IBM BPM, V8.0.1, All platforms > Authoring services in Integration Designer > Services and service-related functions > Access external services with adapters > Configure and using adapters > IBM WebSphere Adapters > Adapter Toolkit > Implementing code from the IBM WebSphere Adapter Toolkit > Outbound support > Use command patterns
Command patterns
To enhance uniformity across adapters for outbound processing, support for command patterns is provided by the CommandManager API in the Adapter Foundation Classes.
Adapters are responsible for creating, updating, retrieving, and deleting records in the EIS system based on the structure described by the incoming metadata and the content in the incoming cursor. The command pattern approach is recommended for handling the generic processing of create, retrieve, update, and delete operations for After-Image as well as Delta scenarios.
For example, if an incoming cursor represents an after-image update, the adapter must take steps to update the EIS such that the corresponding object in the EIS matches the structure and contents of the cursor request. To accomplish this, the adapter retrieves the structure in the EIS system, then compares it to the incoming cursor. The adapter then performs the operations necessary to make the EIS system match the input. These operations are typically performed as the comparisons occur. This makes adapter processing potentially quite complex. A command pattern capability abstract this functionality into generic logic, thereby saving adapter developers time and effort.
The command pattern breaks down a hierarchical update into a hierarchy of small sub-commands. These sub-commands are passed to an interpreter, which retrieves and executes the code necessary to perform the sub-command on that particular EIS system. This makes it possible for the adapter developer to deal with operations on single-tier entities without having to walk the structure and compare. This has the potential to simplify adapter construction greatly because the comparison routines can be generic.
Advantages of the command pattern include:
- Code Reuse: The only code that the adapter developer would need to write would be the EIS-specific operations: the comparator and interpreter code would be common components.
- Performance consistency: Because adapters make use of common components, developers can rigorously define the after-image update process, making various adapters work more consistently.
- Adapter "phantom" mode capability: If operations must be performed, the interpreter can easily be turned off, with the contents of the command hierarchy dumped to a file instead.