Chapter 6. Business object handlers 75
However, such a recursive call assumes that the child business object is set as
follows:
If the verb on a child business object is set, the method should perform the
specified operation.
If the verb on the child business object is not set, the verb method should set
the verb in the child business object to the verb in the top-level business
object before calling another method on the child.
If an attribute has multiple cardinality (cardinality n), the attribute contains an
array of child business objects. In this case, the connector must access the
contents of the array before it can process individual child business objects.
From the array, the doVerbFor() method can access individual business objects:
To access individual business objects, the method can get the number of
child business objects in the array with the getObjectCount() method and
then iterate through the objects.
To get an individual child business object, the method can obtain the
business object at one element of the array.
After the doVerbFor() method has access to a child business object, it can
process the child recursively as needed.
6.8 Custom business object handlers
The Adapter Framework calls the doVerbFor() method in the
CWConnectorBOHandler class (which implements the business object handler)
for all verbs that a particular business object supports. Therefore, all verbs in a
business object are processed in one standard way (although they can initiate
different actions within the application). However, if your connector supports a
business object that requires different processing for some particular verb, you
can create a custom business object handler to handle that verb for the business
object.
Note: A connector should never create arrays for child business objects. An
array is always associated with a business object definition when cardinality is
n.
76 WebSphere Business Integration Adapters
6.8.1 Creating the class for the custom business object handler
To create a custom business object handler, you must create a class that
implements the CWCustomBOHandler interface. The CWCustomBOHandler
interface provides the doVerbForCustom() method, which you must implement to
define a custom business object handler. To create a custom business object
handler class for a Java connector:
1. Create a class that implements the CWCustomBOHandler interface.
2. Implement the doVerbForCustom() method to define the behavior of the
business object handler.
6.8.2 Implementing the doVerbForCustom() method
The doVerbForCustom() method provides the functionality for the custom
business object handler. The Adapter Framework calls the low-level doVerbFor()
method (defined in the BOHandlerBase class) for the appropriate business
object handler when it receives a request business object. This low-level
doVerbFor() method determines which business object handler to call as follows:
If the business object’s verb has the CBOH tag in its application-specific
information, it calls the doVerbForCustom() method.
The CBOH tag specifies the full name (including the package name) of the
custom business object handler class, which implements the
CWCustomBOHandlerInterface interface and its doVerbForCustom() method.
If the CBOH tag exists, the low-level doVerbFor() method tries to create a new
instance of the class that this tag specifies. If this instantiation is successful,
the low-level doVerbFor() method calls the doVerbForCustom() method in this
class.
Otherwise, it calls the doVerbFor() method, which the connector developer
must implement as part of the business object handlers
CWConnectorBOHandler class.
The implementation of the doVerbForCustom() method must handle the verb
processing of the verb for which its class is specified. In this method, you must
customize the behavior of the doVerbForCustom() method to meet the special
processing needs of your business object’s verb.
Note: Unlike the doVerbFor() method, the doVerbForCustom() method is not
invoked directly by the Adapter Framework. Instead, the Adapter Framework
invokes the low-level doVerbFor() method, which in turn, invokes the
doVerbForCustom() method. Therefore, the doVerbForCustom() method
cannot include calls to any methods in the CWConnectorBOHandler class.
Chapter 6. Business object handlers 77
78 WebSphere Business Integration Adapters

Get WebSphere Business Integration Adapters: An Adapter Development and WebSphere Business Integration Solution now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.