beautypg.com

IBM WebSphere Adapters User Manual

Page 164

background image

Creating services that use technology-style adapters relies on being able to
implement the interfaces in the commonj.connector.metadata.build.* package or
by extending the adapter foundation classes in
com.ibm.j2ca.extension.emd.build.*

package, or a combination thereof.

Building configurable artifacts (data bindings, data handlers, and
function selectors)

Building services using Enterprise Metadata Discovery involves building
configurable artifacts that include data bindings, data handlers and function
selectors.

Implementing a data handler

To implement a data handler, implement the
common.connector.runtime.DataHandler

interface.

This interface contains two methods as follows:

v

Object transform(Object input, Class targetClass, Object options)

v

void transformInto(Object input, Object target, Object options)

The transform method takes an InputStream and produces a data object from it or
takes a data object and produces an InputStream (depending on the processing
mode). The target class indicates the processing to be performed by the data
handler. The options parameter is a map that can include an encoding parameter.
When implementing a data handler, code it to handle both byte array and string
formats, if possible.

Note:

Existing Websphere adapters, as of version 6.1.x and version 6.2, use

InputStream for accessing raw data and data object for the transformed version
exclusively.

Implement the TransformInto method in a data handler to transform a data object
by writing to an output stream, so the input would be a data object, and the target
would be an output stream.

Note:

A data handler should only transform from the raw payload to a data object

and vice-versa; it should not put the data in a record, or an envelope or other
adapter-specific format, as this is the processing responsibility of a data binding.

Implementing a function selector

When provided data and metadata from and adapter, the function selector
generates the native function name. A function selector implements the interface
commonj.connector.runtime.FunctionSelector

. This interface contains the method

String generateEISFunctionName(Object[] args);.

The argument array you get depends on which listener interface you are using. If
you are using InboundListener (passing data only), the first object in the array is
the record. If you are using ExtendedMessageListener (passing data and metadata),
the first object in the array is an InboundNativeDataRecord that contains an
InboundInteraction

spec (for metadata) and the record (for data).

For services using adapters to exchange data with a local file system (like flat files)
and services using adapters to access files on an FTP server, the
InboundInteractionSpec

contains the filename and path to the files being

158

WebSphere Adapters: WebSphere Adapter Toolkit User Guide