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
Data binding implementation
Adapters must provide implementations for DataBinding interface in order to work with IBM BPM. The marshalling of data from SDO to CCI record and from CCI record to SDO occurs through DataBinding implementation.
Interfaces
Adapters should implement the following interfaces:
- commonj.connector.runtime
- RecordHolderDataBinding
The following sections describe the methods that need implementation.
setDataObject
public void setDataObject(DataObject arg0) throws DataBindingExceptionThis method builds an instance of adapter record instance and initializes with the metadata that represents input SDO.
public void setDataObject(DataObject arg0) throws DataBindingException { try { record = new EISSAStructuredRecord(); inputBG = arg0; DEFactorySDO binding = new DEFactorySDO(); boolean isBG = WPSServiceHelper.isBusinessGraph(arg0); DataObject dataObject = null; if (isBG) { dataObject = WPSServiceHelper.getRootBusinessObjectInstance(arg0); String verb = arg0.getString(EISSAConstants.VERB); if(verb != null){ record.setOperationName(verb); record.setBGVerb(verb); } record.setIsBG(true); } else dataObject = arg0; binding.setBoundObject(dataObject); Object[] array = new Object[1]; array[0] = dataObject; record.initializeInput(binding, array); record.setNamespace(inputBG.getType().getURI()); record.setRecordName(inputBG.getType().getName()); } catch (Exception e) { throw new DataBindingException("Failed to initialize cursor", e); } }
getDataObject
public DataObject getDataObject() throws DataBindingExceptionThis method builds an instance of SDO with the data that is returned from the backend application.
For example, when an adapter executes a Retrieve operation, the data returned from the backend application is held in the adapter structured record implementation. In this method the adapter reads data from the backend application and builds and SDO instance.
To perform this task the adapter should use DESPI APIs. Initialize the record with initializeOutput(), then call getNext() to build data in SDO.
This method should take care of building an instance of BG is the methods getNamespaceURI()and getBusinessObjectName() return a type BG.
For operations where getNext() should be invoked multiple times like RetrieveAll, the databinding should call getNext() multiple times add the built BusinessObject to the list of BusinessObjects within the Container BO.
getRecord
public Record getRecord() throws DataBindingExceptionThis method should return the instance of record being build in setDataObject() call or passed through setRecord() call.
setRecord
public void setRecord(Record arg0) throws DataBindingExceptionThis method should hold the instance of the record passed to this method as a record instance for the binding implementation. This record instance is used in method getDataObject().
Abstract methods (getNamespaceURI and getBusinessObjectName)
public abstract String getNamespaceURI();public abstract String getBusinessObjectName();DataBinding implementation uses these two methods in getDataObject() call to determine the SDO type that the binding should instantiate.
The generated databinding classes described the section DataBinding generator provide the implementation for the abstract methods.
DataBinding generator
To enable the right business object type being made available to DataBinding implementations adapters should implement DataBindingGenerator interface.
Adapters should implement com.ibm.j2ca.extension.databinding, WBIDataBindingGenerator and implement provide a default constructor implementation.
Call the super class constructor and pass in the name of the adapter and the absolute classname of the base DataBinding implementation.
Sample code:
public EISSADataBindingGenerator() { super(null, "com.ibm.j2ca.eissa.emd.runtime.EISSADataBinding"); }EMD implementations should set the absolute name of the class for DataBindingGenerator as the generator classname in DataDescription instance. Set the DataBinding Classname to null.