if (functionName.equals(NodeLevelOperations.CREATE_NODE)) {
command = new TwineBallCreateCommand();
} else if (functionName.equals(NodeLevelOperations.DELETE_NODE)) {
command = new TwineBallDeleteCommand();
} else if (functionName.equals(NodeLevelOperations.UPDATE_NODE)) {
command = new TwineBallUpdateCommand();
} else if (functionName.equals(NodeLevelOperations.RETRIEVE_STRUCTURE)) {
command = new TwineBallRetrieveCommand();
} else if (functionName.equals(NodeLevelOperations.RETRIEVE_ALL)) {
command = new TwineBallRetrieveAllCommand();
} else {
command = new TwineBallBaseCommand();
}
command.setObjectSerializer(objectSerializer);
command.setObjectNaming(objectNaming);
command.setMaxRecords(maxRecords);
command.setMetadata(metadata);
if (functionName == NodeLevelOperations.DELETE_NODE) {
command.setExecutionOrder(CommandForCursor.BEFORE_PARENT);
} else {
command.setExecutionOrder(CommandForCursor.AFTER_PARENT);
}
}catch (Exception e) {
throw new ResourceException(e);
}
return command;
}
Implementing Interaction.execute():
Toenable the command pattern capability, you implement a class from the
InteractionSpec with a call to the Command Manager. The InteractionSpec is part
of the JCA CCI interface.
The interaction class is part of the JCA CCI interface and processes recordsas
input and output. This is the API that is exposed for manipulating data in
outbound operations:
public Record execute(InteractionSpec ispec, Record inRecord)
throws ResourceException;
Youwant to call the Command Manager to produce the command structure, then
the interpreter to execute each command in the structure. Asimplified version of
the resulting interaction code will resemble the following:
public Record execute(InteractionSpec ispec, Record inRecord) throws ResourceException {
WBIStructuredRecord wbiRecord = (WBIStructuredRecord) inRecord;
String functionName = ((WBIInteractionSpec) ispec).getFunctionName();
CommandForCursor topLevelCommand = commandManagerForCursor.produceCommands(wbiRecord, functionName);
interpreter.execute(topLevelCommand);
WBIStructuredRecord outRecord = new WBIStructuredRecord();
outRecord.setOperationName(functionName);
outRecord.setTwineBallConnection(connection.getEISConnection());
outRecord.setEISRepresentation(topLevelCommand.getEisRepresentation());
return outRecord;
}
Notice that you need not walkthe incoming object structure, or the command
structure– the command manager and interpreter perform this function.
114 WebSphereAdapters: WebSphereAdapter Toolkit User Guide