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 > Implementing outbound support

WBIInteraction

A javax.resource.cci.Interaction instance enables client components to process the EIS-specific operations. WBIInteraction implements an interaction interface to provide implementations for noncritical methods. Subclasses implement the execution interfaces.


Subclass methods to implement

Record doExecute(InteractionSpec ispec, Record inputRecord)

doExecute(InteractionSpec ispec, Record inRecord, Record outRecord)

The inRecord is the input record, and outRecord is the output record.

The difference between the two is that the output record is passed in, so the code in interaction.doExecute updates that output record instead of creating a new record to return.

Processes an EIS operation represented by the InteractionSpec and returns an output Record. The following example makes use of the command patterns to simplify processing.

public class EISSAInteraction extends WBIInteraction {
	static String copyright() {
		 return com.ibm.j2ca.eissa.common.Copyright.IBM_COPYRIGHT_SHORT;
	} 	
	private EISSACommandFactory commandFactory = null;
	private CommandManagerForCursor commandMgr = null;
	private EISSAInterpreter interpreter = null;
	private EISSAManagedConnection mconn = null;


	public EISSAInteraction(WBIConnection connection) throws ResourceException{
		super(connection);
		
		mconn = (EISSAManagedConnection)connection.getManagedConnection();
		logUtils =  mconn.getLogUtils();
		interpreter = new EISSAInterpreter(logUtils);
		commandFactory = new EISSACommandFactory();
		commandMgr = new CommandManagerForCursor(commandFactory,  mconn.getEISConnection(), logUtils);
		commandMgr.setNamespace("");
	} 
	public Record doExecute(InteractionSpec ispec, Record inputRecord)
throws ResourceException {
		
		Record output = null;
		try {
			WBIInteractionSpec wbiSpec = (WBIInteractionSpec) ispec;
			EISSAStructuredRecord recordInput = null;
			if(inputRecord instanceof EISSAStructuredRecord){
				recordInput = (EISSAStructuredRecord)inputRecord;
			}else if(inputRecord instanceof DataObjectRecord){// is SDO1
				DataObjectRecord record = (DataObjectRecord) inputRecord;
				recordInput = new EISSAStructuredRecord();
				DEFactorySDO binding = new DEFactorySDO();
				DataObject object = record.getDataObject();
				//Since it would be a BG get the root property 				commonj.sdo.Property prop = WPSServiceHelper.getRootBusinessObjectProperty
(object.getType());
				//get the corresponding dataObject from BG
				DataObject inputObject = object.getDataObject(prop);
				binding.setBoundObject(inputObject);
				//initialize the record 				Object[] array = {inputObject};
				recordInput.initializeInput(binding, array);
				recordInput.setNamespace(object.getType().getURI());
				recordInput.setRecordName(object.getType().getName());
				//set the verb as operationName for backward compatability
				
				
				recordInput.setIsBG(true);
				recordInput.setBGVerb(object.getString(EISSAConstants.VERB));
				
			}else{//is JavaBean
				recordInput = new EISSAStructuredRecord();
				DEFactoryJavaBean binding = new DEFactoryJavaBean();
				binding.setBoundObject(inputRecord);
				Object[] array = {inputRecord};
				recordInput.initializeInput(binding, array);
			} 			CommandForCursor command = commandMgr.produceCommands(recordInput,  wbiSpec.getFunctionName());
			
			EISSABaseCommand vtaCmd = (EISSABaseCommand)command;
			vtaCmd.setFuncName(wbiSpec.getFunctionName());
			if(recordInput.getIsBG()){
				vtaCmd.setIsBG(true);
				vtaCmd.setBGVerb(recordInput.getBGVerb());
			} 			
			interpreter.execute(command);
			
			EISSAStructuredRecord outputRecord = new EISSAStructuredRecord();
			outputRecord.setEISRepresentation(command.getEisRepresentation());
			outputRecord.setMetadata(recordInput.getMetadata());
			outputRecord.setOperationName(wbiSpec.getFunctionName());
			outputRecord.setLogUtils(logUtils);
			
			output = outputRecord;
			
			if (logUtils.isTraceEnabled(Level.FINE))
				logUtils.traceMethodExit(EISSAConstants.VTAINTERACTION, "execute");
		} catch (CommException ce) {
			throw ce;
		} catch (ResourceException re) {
			throw re;
		} catch (Exception e) {
			throw new ResourceException("The execute call on the EISSAInteraction
 instance has failed.", e);
		}		
		return output;
	}

Implementing outbound support


Related concepts:

WBIManagedConnectionFactory

WBIManagedConnection

WBIConnectionFactory

WBIConnection

javax.resource.cci.ConnectionSpec

WBIInteractionSpec

WBIConnectionRequestInfo

javax.resource.cci.ConnectionMetadata