IBM WebSphere Adapters User Manual page 119

Version 6 release 2
Table of Contents

Advertisement

You will need to implement the following:
1. Command implementations for each command type ("Retrieve", "RetrieveAll",
2. A command factory implementation that will create instances of these
3. An implementation of Interaction.execute() that calls the Command Manager.
Command implementations:
You use an execute() method to implement commands. Extending an abstract base
command with operation-specific commands supports the coding benefits of
command patterns.
execute() is the method that implements each command. This method should
perform the appropriate operation for the associated node. If a Create command is
associated with child B1, for example, execute() is the method that calls the EIS
API to create that child.
public void execute(InputCursor obj, Type metadata) throws ResourceException
{EisRepresentation eis = EisAPI.insert(toEisFormat(obj, metadata));
}
Note: Be careful with deleted children. The SDO getContainer() does not return
the original parent in a delta operation. Use the getParentDataObject() method,
available in the command object, to alleviate this problem.
The Retrieve and RetrieveAll commands must create the entire object structure and
return it because the input object is unaware of child objects present in the EIS.
It is a common pattern to have an abstract base command for your EIS, and then
have the operation-specific commands extend that. This way, if all your commands
need similar data, you can reduce your coding effort.
Note: Note: The WebSphere Adapter Toolkit will not generate the execute()
methods for individual commands. You will want to override the base command
execute method to put in the logic you want.
Command factory implementations:
The command factory creates operation-specific command instances and establishes
when the instance is executed.
Given an operation name and metadata, the command factory is responsible for
creating command instances. The command factory must also set the execution
order that specifies when a command should be executed in relation to its parent.
This value can be either BEFORE_PARENT, or AFTER_PARENT.
The interface you must implement is as follows:
public CommandForCursor createCommand(String nodeLevelOperation) throws ResourceException;
The code to implement a command factory will resemble the following (where
TwineBall is the name of the EIS).
public CommandForCursor createCommand(String functionName, Type metadata) throws ResourceException {
TwineBallBaseCommand command = null;
try {
"Create", "Update", "Delete", and "NoOperation").
EIS-specific commands.
WebSphere Adapter development overview
113

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Websphere adapter toolkit

Table of Contents