Extending the ODA base class

To create an ODA, you extend the ODA base class, ODKAgentBase2, to create your own ODA class. The ODKAgentBase2 class includes methods for initialization, setup, and termination of the ODA. To implement your own ODA, you must extend this ODA base class to create your ODA class.

To derive an ODA class, follow these steps:

  1. Create an ODA class that extends the ODKAgentBase2 class. A suggested name for this ODA class is:
        ODAname.java
    

    where ODAname uniquely identifies the ODA and has the format of the ODA's source data with the ODA extension (srcDataNameODA). For information about source-data names, see Naming the ODA. For example, to create an ODA for HTML objects, you create an ODA-class file called HTMLODA.java.

  2. In the ODA-class file, define a package name to contain your ODA. By convention, an ODA package name has the following format:

    com.ibm.oda.srcDataName.ODAname
    

    In the format above, ODAname is the same as defined in step 1 and srcDataName is the same as in step 1 except that it is in lowercase letters. For example, the package name of an ODA for HTML objects could be defined in the ODA class as follows:

    package com.ibm.oda.html.HTMLODA;
    
  3. Ensure that the ODA-class file imports the classes of the com.crossworlds.ODK package:
        import com.crossworlds.ODK.*;
    

    To access the methods of the ODK API, the ODA class must import the ODK package, which is contained in the CwODK.jar file in the lib subdirectory of the product directory. If you create several files to hold the ODA-class code, you must import the classes of the ODK package into every source file.

  4. Define the ODA class and include in the definition any content-generation interfaces that the ODA uses. An ODA must implement the IGeneratesBoDefs content-generation interface to generate business-object-definition content. Optionally, it can also implement the IGeneratesBinFiles content-generation interface to generate binary-file content.

    For example, suppose that the ODA for HTML implements only the required the IGeneratesBoDefs interface. Its definition would be as follows:

    public class HTMLODA extends ODKAgentBase2 implements IGeneratesBoDefs {
    

    For more information about content-generation interfaces, see Determining the ODA generated content.

  5. Implement the abstract methods of the ODKAgentBase2 class for your ODA class. Table 28 provides an overview of these methods, listing them in the order in which Business Object Wizard calls them. For more information on how to implement these abstract methods, see Table 28.

    Table 28. Extending abstract methods of the ODKAgentBase2 class

    Abstract ODKAgentBase2 method Description For more information
    getAgentProperties()

    This method performs the following tasks:

    • Define the configuration properties needed to initialize the ODA, including information the ODA needs to connect to the data source.
    • Send the configuration properties in an array to Business Object Wizard.

    Obtaining configuration properties
    getMetaData() Instantiate the AgentMetaData object that contains the ODA's metadata, including its ability to generate content. Initializing ODA metadata
    init() Initialize the ODA, including allocation of resources and connection to the data source. Initializing the ODA start
    terminate() Perform cleanup, including disconnecting from the data source and releasing any resources that the ODA uses. Shutting down the ODA
  6. Implement the methods of the appropriate content-generation interface (or interfaces) in your ODA class. Table 28 lists the methods of the content-generation interfaces and indicates where to find more information on how to create these methods.

    Table 29. Defining methods of the content-generation interface

    Content-generation interface Description For more information
    IGeneratesBoDefs getContentProtocol() Determining the ODA generated content

    getTreeNodes()
    generateBoDefs()
    getBoDefs()
    Generating business object definitions as content
    IGeneratesBinFiles getContentProtocol() Determining the ODA generated content

    generateBinFiles()
    getBinFile()
    Generating binary files as content

Copyright IBM Corp. 1997, 2004