Choosing the ODA content protocol

An ODA can generate a particular content type using either of the content protocols listed in Table 34. The content protocol determines how the ODA interacts with Business Object Wizard to generate the supported content; that is, it determines whether Business Object Wizard can explicitly initiate content generation from the ODA.

Table 34. Content protocols for an ODA

Content protocol Description Content-protocol constant
On request Business Object Wizard explicitly requests the ODA to generate content by calling the content-generation method. Once this method completes, on-request content is ready. Business Object Wizard can retrieve this content at its convenience with a call to the content-retrieval method. CONTENT_PROTOCOL_ONREQUEST
Callback The ODA generates the content in some fashion and notifies Business Object Wizard when its content is ready. Once notified, Business Object Wizard retrieves this content with a call to the content-retrieval method. CONTENT_PROTOCOL_CALLBACK
Note:
An ODA must support the generation of business-object-definition content with the on-request content protocol. Additionally, the ODA can support the generation of file content in either content protocol.

To support content protocols, your ODA must take the following steps:

Indicating the implemented content protocols

Both the IGeneratesBoDefs and IGeneratesBinFiles interfaces are extensions of the IGeneratesContent interface. Therefore, they both inherit the single method that IGeneratesContent defines, getContentProtocol(). As part of the implementation of the ODA's content-generation interface, you must implement the getContentProtocol() method to indicate which of the content protocols your ODA will use for its supported content types.

Note:
An ODA can support one content protocol for a given content type.

The getContentProtocol() method accepts as an argument a ContentType object, which identifies a content type that the ODA supports. The getContentProtocol() method returns the content protocol that the ODA supports for this specified content type. It returns the supported content protocol as one of the content-protocol constants (shown in Table 34). These constants are defined in the ODKConstant interface.

Note:
In this release, an ODA must generate business object definitions on request. Therefore, it must implement the getContentProtocol() method to return the CONTENT_PROTOCOL_ONREQUEST constant for a content type of ContentType.BusinessObject. Additionally, the ODA can support the generation of files in either protocol and return the appropriate content-protocol constant for a content type of ContentType.BinaryFile.

Figure 58 shows an implementation of getContentProtocol() that indicates the ODA supports the callback protocol for the generation of files and the on-request protocol for the generation of business object definitions.

Figure 58. Indicating supported content protocols

public long getContentProtocol(ContentType contentType)
 {
     if (contentType == ContentType.BinaryFile)
       return ODKConstant.CONTENT_PROTOCOL_CALLBACK;
     else
       return ODKConstant.CONTENT_PROTOCOL_ONREQUEST;
 }
 

Implementing the content-generation method

The implementation of the content-generation method depends on the content protocol that the content type supports, as Table 35 shows.

Table 35. Content protocols and the content-generation method

Content protocol How to call the
content-generation method
Implementation of content-generation method
On request Business Object Wizard explicitly calls the content-generation method to initiate content generation ( business object definitions or files). Method must generate content for the source nodes passed in its argument and return the appropriate content metadata to Business Object Wizard.
Callback Business Object Wizard never explicitly calls the content-generation method because content generation ( files only) is initiated by the ODA for this content protocol. Method should throw an exception because it should never be called directly. Actual generation of content is performed external to the content-generation method, in a different method, class, or even process.

Table 36 shows the information that this chapter provides on how to implement the content-generation methods.

Table 36. How to develop a content-generation method

Content-generation method For more information
IGeneratesBoDefs.generateBODefs() Defining the generateBoDefs() method
IGeneratesBinFiles.generateBinFiles() Defining the generateBinFiles() method

Copyright IBM Corp. 1997, 2004