Skip navigation.

Developing Adapters

  Previous Next vertical dots separating previous/next from contents/index/pdf Contents Index View as PDF   Get Adobe Reader

Learning to Develop Adapters Using the DBMS Sample Adapters

This section contains information about the following subjects:

 


Introduction to the DBMS Sample Adapters

The DBMS sample adapters are J2EE-compliant adapters that includes a JSP-based GUI. They provides concrete examples of how an adapter can be constructed by using the WebLogic Integration ADK. A relational database is used as the adapters' EIS to allow adapter providers to focus on details of the adapters and the ADK, instead of investing time to learn about a particular proprietary EIS.

Two DBMS sample adapters are provided:

The DBMS Sample Adapters are intended to help you understand the tasks required to design and develop your own adapter. They are not intended for use in a production environment, nor are they supported in such an environment. Because the adapters are intended as examples, rather than production-ready adapters, they do not include a full set of features and have the following limitations: the adapters are unable to execute complex queries or stored procedures.

Whether you are a developer or a business analyst, the DBMS sample adapters can help you understand the possibilities at your disposal when you use the ADK to build adapters. If you are a business analyst, you might find it useful to run through the interface to get a better understanding of an application view, service, and event, as described in How the DBMS Sample Adapters Work.

If you are an adapter developer, we suggest you start by learning how you can extend and use the ADK classes to build a J2EE-compliant adapter. To do so, review the following:

The DBMS sample adapters satisfy the following requirements:

 


Connection Parameters for DBMS Sample Adapters

When setting connection parameters for these adapters, specify a JDBC Driver and URL. The sample DBMS adapters do not support the specification of a DataSource. Existing service connections which use a DataSource operate as before, but the Application Integration Design Console does not allow you to specify a DataSource for a new adapter.

If you configure a domain using an XA driver, create an additional connection pool for whatever DataSource you create for the event connection.

Do not create two Tx Data Sources that point to the same connection pool. If a transaction uses two different Tx Data Sources which are both pointed to the same connection pool, you will get an XA_PROTO error when you try to access the second connection.

For more information on JDBC DataSources and WebLogic Server, see "JDBC DataSources" in Administration Console Online Help at the following location:

http://download.oracle.com/docs/cd/E13222_01/wls/docs81/ConsoleHelp/jdbc_datasources.html

When using the DBMS sample adapter with a Microsoft SQL Server or Sybase database, use the WebLogic Server Administration Console to enable the TestReservedConnection parameter for the connection pool used for application integration. If the parameter is not enabled, the auto resume or manual resume features do not work and a SQLException similar to the following is thrown:

java.sql.SQLException: [BEA][SQLServer JDBC Driver]No more data
available to read

 


How the DBMS Sample Adapters Work

This section shows how the DBMS sample adapter works. If you are a business analyst, you might enjoy running through the interface to get a feel for how the adapter works. The example in this section shows how to create a service that inserts a customer in the underlying database, and how an event is generated to notify others that this action has taken place.

This section contains information about the following subjects:

Before You Begin

Before you try to access the DBMS sample adapter, make sure you complete the following tasks:

Accessing the DBMS Sample Adapter

To access the DBMS sample adapter:

  1. Open a new browser window.
  2. Enter the URL for your system's Application Integration Design Console:
  3. http://HOSTNAME:7001/wlai

    The Application Integration Design Console Logon page is displayed as shown in Figure E-1.

Warning: You should only have one instance of the Application Integration Design Console running on a single client machine. Running multiple consoles on a single machine may interfere with proper navigation between screens in your web browser.

Tour of the DBMS Sample Adapter

This section provides a short tour through the DBMS sample adapter. To begin, open the Application Integration Design Console Logon page for the DBMS sample adapter in your browser. For instructions, see Accessing the DBMS Sample Adapter.

Figure E-1 Application Integration Design Console - Logon

Application Integration Design Console - Logon


 


 
  1. To log on to the Application Integration Design Console, enter your WebLogic Server username and password, and click Login. The Select Application page is displayed.
  2. Application Integration Design Console - Logon


     
  3. To create a repository for a new application, specify an application name and the root directory for the application. Click OK. The Application View Design Console page is displayed.
  4. Figure E-2 Application View Management Console

    Application View Management Console


     
  5. Click Add Application View. The Define New Application View page is displayed. When you create an application view, you should provide a description that associates that application view with the DBMS sample adapter.
  6. For detailed information about application views and how to define them, see Defining an Application View in Using the Application Integration Design Console.

    Figure E-3 Define New Application View Page

    Define New Application View Page


     
  7. To define an application view:
    1. In the Application View Name field, enter AppViewTest.
    2. The name should describe the set of functions performed by this application. The name of each application view must be unique to its adapter. All characters are valid except the following: period (.), hash mark (#), backslash (\), plus sign (+), ampersand (&), comma (,), apostrophe (`), double quotes ("), and a space.

    3. In the Description field, enter a brief description of the application view.
    4. From the Associated Adapters list, select a DBMS sample adapter to use to create your application view.
    5. Click Create New Connection. The Create New Browsing Connection page is displayed.
    6. Alternatively, to reuse an existing connection, click on Reuse Existing Connection and select a browsing connection.

      Define New Application View Page


       
  8. To create a new connection:
    1. In the Connection Name field, enter a unique suffix for to the default connection name prefix or use the default suffix provided.
    2. In the Description field, enter a description for the new connection.
    3. Edit the connection pool and log parameters as required.
    4. Click Define to define the connection parameters for the browsing connection. The Configure Connection Parameters page is displayed.
    5. Figure E-4 Configure Connection Parameters Page

      Configure Connection Parameters Page


       
  9. On the Configure Connection Parameters page, enter the network-related information that enables the application view to interact with the target EIS. It is not necessary for you to enter this information more than once per application view:
    1. Enter the database username and password.
    2. In the JDBC Driver and JDBC URL fields, enter the driver specification and the JDBC URL. Depending on the database type, you can also specify additional properties. Note the supported database types and their respective URL formats the bottom of the page.
    3. Click Continue in the Configure Connection Parameters page to return to the Create New Browsing Connection page.
    4. Click OK. The Application View Administration page is displayed.
    5. The Application View Administration page summarizes the connection criteria. After events and services are defined, you can view schemas and summaries and delete an event or service from this page.

    You have finished creating an application view; you can now add a service to it.

    Figure E-5 Application View Administration Page for AppViewTest

    Application View Administration Page for AppViewTest


     
  10. To add a service to your new application view, you must supply a name for the service, a description of it, and an SQL statement.
  11. Use the browse link to browse the DBMS sample adapter database schemas and tables and to specify the database table CUSTOMER_TABLE.

    To add a service:

    1. On the Application View Administration page, click Add in the Services group. The Add Service page is displayed.
    2. Figure E-6 Add Service Page

      Add Service Page


       
    3. In the Unique Service Name field, enter InsertCustomer.
    4. In the Description field, enter a description of the service.
    5. Click Browse DBMS to view the table and column structure of the database. If you are writing a complex query, you may want to leave the Browse window open so you can later cut and paste table or column names into your query.
    6. Figure E-7 Browse DBMS Page

      Browse DBMS Page


       
    7. On the DBMS Schemas for Catalog page, click WEBLOGIC.
    8. Figure E-8 Browse DBMS Table Types Page

      Browse DBMS Table Types Page


       
    9. On the DBMS Table Types page, click TABLE.
    10. Figure E-9 DBMS Browse Tables Page

      DBMS Browse Tables Page


       
    11. On the Tables list for WEBLOGIC page, click CUSTOMER_TABLE. The Browse window now displays the names and types of the columns.
    12. Figure E-10 Browse DBMS for Table Page

      Browse DBMS for Table Page


       
    13. Click Close Window to close the window and return to the Add Service Page.
    14. This window is included in the tour to introduce you to available functionality; you are not required to select any text for this exercise.

    15. On the Service Page, add the following information to the SQL Statement field:
    16. Insert into WEBLOGIC.CUSTOMER_TABLE (FIRSTNAME, LASTNAME, DOB) VALUES ([FIRSTNAME VARCHAR], [LASTNAME VARCHAR], [DOB DATE])

    17. Click Add. The Application View Administration page is displayed.
    18. For additional information about adding services, see Defining an Application View in Using the Application Integration Design Console.

  12. Add an event to your application view. To do so, you must provide a unique name and a description of the event. Then you must specify the database table to which a trigger should be added for the event. You must also specify whether the event is an insert, update, or delete event.
  13. You can use the Browse DBMS link to browse the DBMS database schemas and tables and to specify the database table. Then you can click the Fill table name with selected table button to populate the field automatically with the specified table name.

    To add an event:

    1. On the Application View Administration page, click Add in the Events field. The Add Event page is displayed.
    2. Figure E-11 Add Event Page

      Add Event Page


       
    3. In the Unique Event Name field, enter CustomerInserted.
    4. In the Description field, enter a description of the event.
    5. Click the Browse DBMS link to view the table and column structure of the database.
    6. Figure E-12 Browse DBMS Tables Page

      Browse DBMS Tables Page


       
    7. Select the CUSTOMER TABLE option. Then click the Fill table name with selected table button.
    8. Figure E-13 Add Event Page

      Add Event Page


       
    9. Select the Insert Event option.
    10. Click Add. The Application View Administration page is displayed.
    11. Figure E-14 Application View Administration Page for AppViewTest

      Application View Administration Page for AppViewTest


       
  14. Click Save to save the current application view information. You must create or select connections for services and events before testing and publishing the application view.
  15. Click Select/Edit. The Connection Information page is displayed. The Connection Information page is organized by connection type: service invocation, event delivery, and design-time browsing connections.
  16. Application View Administration Page for AppViewTest


     
  17. For the purposes of this tour, use an existing service connection. Click on the Select Existing link for service connections and select an existing connection.
  18. Click Event to configure the connection properties and log level of your event connection. The Edit Event Connection page is displayed.
  19. Application View Administration Page for AppViewTest


     

    The Edit Event Connection page allows you to define event parameters and configure what information will be logged for the connection factory. Select one of the following settings for the log:

    Locate Connection Parameters and click Define to set the event delivery parameters. The Configure Event Delivery Parameters page is displayed.

    The event delivery parameters you enter on this page enable connection to an EIS instance and are used when generating events. The properties are specific to the associated adapter and are defined in the wli-ra.xml file within the base adapter.

  20. After you have set the event delivery parameters, click on Continue to return to the Edit Event Connection page and then click OK to return to the Connection Information page.
  21. Click Back to return to the Application View Administration page.
  22. In the Application View Administration page, click Test. The Summary for Application View page is displayed. Note that the Status is Testing and a Stop Testing link is displayed.
  23. Figure E-15 Summary for Application View Page

    Summary for Application View Page


     
  24. Test an event. To ensure that the application view is working correctly, you can test the events and services shown in it. You can test an event by invoking a service or by manually creating the event. The user can also specify how long the application should wait to receive the event.
    1. In the Events group, on the CustomerInserted line, click Test. The Test Event page is displayed.
    2. Figure E-16 Test Event Page

      Test Event Page


       
    3. On the Test Event page select the Service option and, from the Service menu, InsertCustomer.
    4. In the How long should we wait to receive the event? field, enter 6000.
    5. Click Test. The Test Service page is displayed.
    6. Figure E-17 Test Service Page

      Test Service Page


       
    7. In the FIRSTNAME field, enter a first name.
    8. In the LASTNAME field, enter a last name.
    9. In the DOB field, enter a date of birth. The correct format is specified to the right of the DOB field.
    10. Click Test. The Test Result page is displayed. It shows the contents of the XML documents representing the event you generated and the response generated by the application view.
    11. Figure E-18 Test Result PageTest Service Page

After successfully testing events and services, you can return to the Summary page and publish the application view. This generates an EJB within the application directory, publishes schema files to the WebLogic Workshop application for use in the XML Mapper, and makes the application view visible within WebLogic Workshop.

For more information on publishing application views, see Defining an Application View in Using the Application Integration Design Console.

 


How the DBMS Sample Adapters Were Developed

This section describes each interface used to develop the DBMS sample adapters. The ADK provides many of the necessary implementations required by a Java Connector Architecture-compliant adapter, but some interfaces cannot be implemented fully until the EIS and its environment are defined. For this reason the DBMS sample adapters were created as a concrete implementation of the abstract classes provided by the ADK.

The procedure for creating the DBMS sample adapters includes the following steps:

Step 1: Learn About the DBMS Sample Adapters

To learn how the implementations provided by the ADK are leveraged in the DBMS sample adapters, we recommend that you review the Javadoc and code for the methods defined in this section.

Note: WLI_HOME is the drive or directory in which BEA WebLogic Integration is installed.

Step 2: Define Your Environment

To help you identify and collect critical information about the adapter you are developing before you begin coding, see the Adapter Setup Worksheet. For the DBMS sample adapter BEA_WLS_DBMS_ADK, the worksheet questions are answered as follows:

Note: Questions preceded by an asterisk (*) are required to use the GenerateAdapterTemplate utility.

  1. *What is the name of the EIS for which you are developing an adapter?
  2. PointBase or Oracle databases.

  3. *What version of the EIS are you using?
  4. PointBase 4.4, Oracle 8.1.7., or Oracle 91 Release 2

  5. *Which type of EIS (such as DBMS or ERP) are you using?
  6. DBMS

  7. *What is the name of the vendor for this adapter?
  8. BEA

  9. *What is the version number of this adapter?
  10. None - Sample Only

  11. *What is the logical name of the adapter?
  12. BEA_WLS_DBMS_ADK

  13. Does the adapter need to invoke functionality within the EIS?
  14. Yes

    If so, then your adapter must support services.

    Yes

  15. What mechanism or API is provided by the EIS to allow an external program to invoke EIS functionality?
  16. JDBC

  17. What information is needed to create a session or connection to the EIS for this mechanism?
  18. Database URL, driver class, user name, password

  19. What information is needed to determine which function(s) will be invoked in the EIS for a given service?
  20. Function name, executeUpdate, executeQuery

  21. Does the EIS allow you to query it for input and output requirements for a given function?
  22. Yes, you can browse data structures.

    If so, what information is needed to determine the input requirements for the service?

    SQL

  23. Which of the input requirements are static across all requests? Your adapter should encode static information in an InteractionSpec object.
  24. SQL

  25. Which of the input requirements are dynamic per request? Your adapter should provide an XML schema that describes the input parameters required by this service per request.
  26. The input requirements would change depending on the SQL expression for the service.

  27. What information is needed to determine the output requirements for the service?
  28. N/A

  29. Does the EIS provide a mechanism to browse a catalog of functions that can be invoked by your adapter? If so, your adapter should support the browsing of services.
  30. Yes

  31. Does the adapter need to receive notifications of changes that occur inside the EIS? If so, then your adapter must support events.
  32. Yes

  33. What mechanism or API is provided by the EIS to allow an external program to receive notification of events in the EIS? The answer to this question will help you determine whether a pull mechanism or a push mechanism is developed.
  34. None. The DBMS sample adapter was built on the BEA WebLogic Integration event generator using a pull mechanism.

  35. Does the EIS provide a way to determine which events can be supported by your adapter?
  36. Yes

  37. Does the EIS provide a way to query for metadata for a given event?
  38. Yes

  39. What locales (defined by language and country) does your adapter need to support?
  40. Multiple

Step 3: Implement the Server Provider Interface Package

To implement the DBMS sample adapter Server Provider Interface (SPI) and meet the J2EE-compliant SPI requirements, the classes in the ADK were extended to create the following concrete classes:

Table E-1 SPI Class Extensions

This concrete class...

Extends this ADK class...

ManagedConnectionFactoryImpl

AbstractManagedConnectionFactory

ManagedConnectionImpl

AbstractManagedConnection

ConnectionMetaDataImpl

AbstractConnectionMetaData

LocalTransactionImpl

AbstractLocalTransaction


 

These classes provide connectivity to an EIS and establish a framework for event listening and request transmission, establish transaction demarcation, and allow management of a selected EIS.

ManagedConnectionFactoryImpl

The first step in implementing an SPI for the DBMS sample adapter was to implement the ManagedConnectionFactory interface. A ManagedConnectionFactory supports connection pooling by providing methods for matching and creating a ManagedConnection instance.

Basic Implementation

The ADK provides com.bea.adapter.spi.AbstractManagedConnection Factory, an implementation of the Java Connector Architecture interface javax.resource.spi.ManagedConnectionFactory. The DBMS sample adapter extends this class in com.bea.adapter.dbms.spi.ManagedConnectionFactoryImpl. Listing E-1 shows the derivation tree for ManagedConnectionFactoryImpl.

Listing E-1 com.bea.adapter.dbms.spi.ManagedConnectionFactoryImpl

javax.resource.spi.ManagedConnectionFactory
|
|-->com.bea.adapter.spi.AbstractManagedConnectionFactory
|
|-->com.bea.adapter.dbms.spi.ManagedConnectionFactoryImpl

Developers' Comments

The ManagedConnectionFactory is the central class of the Java Connector Architecture SPI package. The ADK's AbstractManagedConnectionFactory provides much of the required implementation for the methods declared in Sun MicroSystems' interface. To extend the ADK's AbstractManagedConnectionFactory for the DBMS sample adapter, the key createConnectionFactory() and createManagedConnection() methods were implemented. Overrides for equals(), hashcode(), checkState() were also written to provide specific behaviors for the databases supported by the DBMS sample adapter.

There are private attributes about which the superclass has no knowledge. When creating your adapters, you must provide setter/getter methods for these attributes. The abstract createConnectionFactory() method is implemented to provide an EIS-specific ConnectionFactory using the input parameters.

Additionally, createManagedConnection() is the main factory method of the class. It checks to see if the adapter is configured properly before doing anything else. It then implements methods of the superclass to get a connection and a password credential object. It then attempts to open a physical database connection; if this succeeds, it instantiates and returns a ManagedConnectionImpl (the DBMS sample adapter implementation of ManagedConnection), which is given the physical connection.

Other methods are getter/setter methods for member attributes.

ManagedConnectionImpl

A ManagedConnection instance represents a physical connection to the underlying EIS in a managed environment. ManagedConnection objects are pooled by the application server. For more information, read about how the ADK implements the AbstractManagedConnection instance in ManagedConnection.

Basic Implementation

The ADK provides com.bea.adapter.spi.AbstractManagedConnection, an implementation of the J2EE interface javax.resource.spi.ManagedConnection. The DBMS sample adapter extends this class in com.bea.adapter.dbms. spi.ManagedConnectionImpl. Listing E-2 shows the derivation tree for ManagedConnectionImpl.

Listing E-2 com.bea.adapter.dbms.spi.ManagedConnectionImpl

javax.resource.spi.ManagedConnection
|
|-->com.bea.adapter.spi.AbstractManagedConnection
|
|-->com.bea.adapter.dbms.spi.ManagedConnectionImpl

Developers' Comments

This class is thoroughly documented in the Javadoc comments because the ManagedConnection is a crucial part of the Java Connector Architecture SPI specification. You should focus on our implementation of the following methods:

The ping() method is used to check whether a physical database connection (not our cci.Connection) is still valid. If an exception occurs, ping() is specific about checking the type so that a connection is not needlessly destroyed.

Other methods are EIS-specific or are simply required setters or getters.

ConnectionMetaDataImpl

The ManagedConnectionMetaData interface provides information about the underlying EIS instance associated with a ManagedConnection instance. An application server uses this information to get run-time information about a connected EIS instance. For more information, read about how the ADK implements the AbstractConnectionMetaData instance in ManagedConnection.

Basic Implementation

The ADK provides com.bea.adapter.spi.AbstractConnectionMetaData, an implementation of the J2EE interface javax.resource.spi.ManagedConnection MetaData. The DBMS sample adapter extends this class in com.bea. adapter.dbms.spi.ConnectionMetaDataImpl. Listing E-3 shows the derivation tree for ConnectionMetaDataImpl.

Listing E-3 com.bea.adapter.dbms.spi.ConnectionMetaDataImpl

javax.resource.spi.ManagedConnectionMetaData
|
|-->com.bea.adapter.spi.AbstractConnectionMetaData
|
|-->com.bea.adapter.dbms.spi.ConnectionMetaDataImpl

Developers' Comments

The ADK's AbstractConnectionMetaData class implements the following:

This implementation of the ConnectionMetaData class uses a DatabaseMetaData object. Because the ADK's abstract implementation was used, you must provide EIS-specific knowledge when implementing the abstract methods in this class.

LocalTransactionImpl

The LocalTransaction interface provides support for transactions that are managed within an EIS resource manager (that is, transactions that do not require an external transaction manager). For more information, read about how the ADK implements the AbstractLocalTransaction instance in LocalTransaction.

Basic Implementation

The ADK provides com.bea.adapter.spi.AbstractLocalTransaction, an implementation of the J2EE interface javax.resource.spi.LocalTransaction. The DBMS sample adapter extends this class in com.bea.adapter.dbms. spi.LocalTransactionImpl. Listing E-4 shows the derivation tree for LocalTransactionImpl.

Listing E-4 com.bea.adapter.dbms.spi.LocalTransactionImpl

javax.resource.spi.LocalTransaction
|
|-->com.bea.adapter.spi.AbstractLocalTransaction
|
|-->com.bea.adapter.dbms.spi.LocalTransactionImpl

Developers' Comments

This class utilizes the ADK's abstract superclass which provides logging and event notification. The superclass implements both the CCI and SPI LocalTransaction interfaces provided by Sun. The DBMS sample adapter's concrete class implements the three abstract methods of the superclass:

Step 4: Implement the Common Client Interface Package

To implement the DBMS sample adapter Common Client Interface (CCI) and meet the J2EE-compliant CCI requirements, several classes in the ADK were extended to create the following concrete classes.

Table E-2 CCI Class Extensions

This concrete class . . .

Extends this ADK class . . .

ConnectionImpl

AbstractConnection

InteractionImpl

AbstractInteraction

InteractionSpecImpl

InteractionSpecImpl


 

These classes provide access back-end systems. The client interface specifies the format of both the request and response records for a given interaction with the EIS.

Note: Although implementation of the CCI is optional in the Java Connector Architecture 1.0 specification, it is likely to be required in the future. For your reference, the DBMS sample adapter provides a complete implementation.

ConnectionImpl

A Connection represents an application-level handle that is used by a client to access an underlying physical connection. The actual physical connection associated with a Connection instance is represented by a ManagedConnection instance. For more information, read about how the ADK implements the AbstractConnection instance in Connection.

Basic Implementation

The ADK provides com.bea.adapter.cci.AbstractConnection, an implementation of the J2EE interface javax.resource.cci.Connection. The DBMS sample adapter extends this class in com.bea.adapter.dbms.cci.ConnectionImpl. Listing E-5 shows the derivation tree for ConnectionImpl.

Listing E-5 com.bea.adapter.dbms.cci.ConnectionImpl

javax.resource.cci.Connection
|
|-->com.bea.adapter.cci.AbstractConnection
|
|-->com.bea.adapter.dbms.cci.ConnectionImpl

Developers' Comments

The ConnectionImpl class is the DBMS sample adapter's concrete implementation of the javax.resource.cci.Connection interface. It extends the ADK's AbstractConnection class. The actual physical connection associated with a connection instance is represented by a ManagedConnection instance.

A client gets a connection instance by using the getConnection() method on a ConnectionFactory instance. A connection can be associated with zero or more interaction instances. The simplicity of this concrete class is a testament to the power of extending the ADK's base classes.

InteractionImpl

The Interaction instance enables a component to execute EIS functions. An interaction instance is created from a connection and is required to maintain its association with the Connection instance. For more information, read about how the ADK implements the AbstractInteraction instance in Interaction.

Basic Implementation

The ADK provides com.bea.adapter.cci.AbstractInteraction, an implementation of the J2EE interface javax.resource.cci.Interaction. The DBMS sample adapter extends this class in com.bea.adapter.dbms.cci. InteractionImpl. Listing E-6 shows the derivation tree for InteractionImpl.

Listing E-6 com.bea.adapter.dbms.cci.InteractionImpl

javax.resource.cci.Interaction
|
|-->com.bea.adapter.cci.AbstractInteraction
|
|-->com.bea.adapter.dbms.cci.InteractionImpl

Developers' Comments

The InteractionImpl class is the concrete implementation of the ADK's Interaction object. The methods are EIS-specific implementations of methods required by the Java Connector Architecture and the ADK.

Both versions of the Java Connector Architecture's javax.resource.cci.InteractionExecute()method (the central method of this class) were implemented for the DBMS sample adapter. The main logic for the execute() method includes the following signature:

public Record execute(InteractionSpec ispec, Record input)

Because this method returns the actual output record from the interaction, it is called more often than other methods.

The second implementation is provided as a convenience method. This form of execute() includes the following signature: public boolean execute(InteractionSpec ispec, Record input, Record output). The second implementation's logic returns a boolean, which indicates only the success or failure of the interaction.

InteractionSpecImpl

An InteractionSpecImpl holds properties for driving an interaction with an EIS instance. An InteractionSpec is used by an interaction to execute the specified function on an underlying EIS.

The CCI specification defines a set of standard properties for an InteractionSpec, but an InteractionSpec implementation is not required to support a standard property if that property does not apply to its underlying EIS.

The InteractionSpec implementation class must provide getter and setter methods for each of its supported properties. The convention followed in the getter and setter methods should be based on the Java Beans design pattern. For more information, read about how the ADK implements the InteractionSpecImpl instance in InteractionSpec.

Basic Implementation

The ADK provides com.bea.adapter.cci.InteractionSpecImpl, an implementation of the J2EE interface javax.resource.cci.InteractionSpec. The DBMS sample adapter extends this class in com.bea.adapter.dbms. cci.InteractionSpecImpl. Listing E-7 shows the derivation tree for InteractionSpecImpl.

Listing E-7 com.bea.adapter.dbms.cci.InteractionSpecImpl

javax.resource.cci.InteractionSpec
|
|-->com.bea.adapter.cci.InteractionSpecImpl
|
|-->com.bea.adapter.dbms.cci.InteractionSpecImpl

Developers' Comments

An implementation class for the InteractionSpec interface is required to implement the java.io.Serializable interface. InteractionSpec extends the ADK InteractionSpec in order to add setter and getter methods for the String attribute m_sql. The getter and setter methods should be based on the Java Beans design pattern, as specified in the Java Connector Architecture 1.0 specification.

Step 5: Implement the Event Package

This package contains only one class: the DBMS sample adapter EventGeneratorWorker. It does the work for the event generator for the DBMS sample adapter.

EventGenerator

The EventGenerator class implements the following interfaces:

Basic Implementation

The DBMS sample adapter event generator extends the ADK's AbstractPullEventGenerator because a database cannot push information to the event generator; you therefore need to pull or poll the database for changes about which you want to be notified. Listing E-8 shows the derivation tree for EventGenerator.

Listing E-8 EventGenerator

com.bea.adapter.event.AbstractEventGenerator
|
|-->com.bea.adapter.event.AbstractPullEventGenerator
|
|-->com.bea.adapter.dbms.event.DbmsEventGeneratorWorker

Developers' Comments

This concrete implementation of the ADK's AbstractPullEventGenerator implements the following abstract methods:

It also overrides the following methods:

These methods are EIS-specific: they are used to identify an event within the context of the EIS while interacting with the database to create and remove event definitions and events. Additionally, these methods can be used to create and remove triggers on the database that are activated when an event occurs.

The key method of the class is postEvents(). It creates the IEvent objects of the data taken from rows in the EVENT table of the database. This method takes an IEventRouter as an argument. After creating an IEvent using the IEventDefinition object's createDefaultEvent() method, the postEvents() method populates the event data propagates the event to the router by calling router.postEvent(event). Once the event is sent to the router, the method deletes the relevant rows of event data from the database.

The method setupNewTypes()creates new event definitions, making sure that the appropriate triggers are created for the database. For each event definition, the method creates a trigger information object that describes the catalog, schema, table, triggerType, and trigger key represented by the event definition. A map of trigger keys is maintained so that triggers are not redundantly added to the database. If the map does not contain the new key, trigger text for the database is generated.

The method removeDeadTypes() also creates a trigger information object, but this object also searches for one or more matching event types. All event definitions that match this trigger are removed from the map, and then the trigger itself is removed from the database.

Step 6: Deploy the DBMS Sample Adapter

After implementing the SPI, CCI, and event interfaces, deploy the adapter by completing the following steps:

Step 6a: Set Up Your Environment

Before deploying the adapter in a BEA WebLogic Integration environment, determine the location of the adapter on your computer. The adapter resides in WLI_HOME/adapters/dbms. You must replace WLI_HOME with the pathname for the directory in which BEA WebLogic Integration is installed. We refer to this location as ADAPTER_ROOT.

Step 6b: Update the ra.xml File

The DBMS sample adapter provides the ra.xml file in the adapter's RAR file (META-INF/ra.xml). Because the DBMS sample adapter extends the AbstactManagedConnectionFactory class, the following properties are provided in the ra.xml file:

The DBMS sample adapter also requires the declarations listed in the following table.

Table E-3 ra.xml Properties

Property

Example

UserName

Username for DBMS sample adapter login

Password

Password for username

DataSourceName

Name of the JDBC connection pool


 

You can view the complete ra.xml file for the DBMS sample adapter in:

WLI_HOME/adapters/dbms/src/rar/META-INF/

Step 6c: Create the RAR File

Class files, logging configuration information, and message bundle(s) should be collected in a JAR file, which should then be bundled, along with META-INF/ra.xml, into a RAR file. The Ant build.xml file demonstrates how to construct this RAR file properly.

Step 6d: Build the JAR and EAR Files

To build the JAR and EAR files, complete the following procedure:

  1. In a text editor, open either antEnv.cmd (Windows) or antEnv.sh (UNIX) in WLI_HOME/adapters/utils. Assign valid pathnames to the following variables:
  2. Execute antEnv from the command line so the new values of the required environment variables take effect.
  3. Go to WLI_HOME/adapters/dbms/project.
  4. Execute ant.cmd release (Windows) or ant.sh release (UNIX) from the WLI_HOME/adapters/dbms/project directory to build the adapter.

Step 6e: Create and Deploy the EAR File

The DBMS sample adapter is displayed by creating and deploying an EAR file. To do so, complete the following procedure:

  1. Declare the adapter's EAR file in your domain's config.xml file, as shown in the following listing.

Listing E-9 Declaring the DBMS Sample Adapter's EAR File

<!-- This deploys the EAR file -->
<Application Deployed="true" Name="BEA_WLS_DBMS_ADK" Path="WLI_HOME/adapters/dbms/lib/BEA_WLS_DBMS_ADK.ear">
     <ConnectorComponent Name="BEA_WLS_DBMS_ADK" Targets="myserver"
URI="BEA_WLS_DBMS_ADK.rar"/>
    <WebAppComponent Name="DbmsEventRouter" Targets="myserver"
URI="BEA_WLS_DBMS_ADK_EventRouter.war"/>
    <WebAppComponent Name="BEA_WLS_DBMS_ADK_Web" Targets="myserver"
URI="BEA_WLS_DBMS_ADK_Web.war"/>
</Application>

Note: Replace WLI_HOME with the pathname of the BEA WebLogic Integration installation directory for your environment.

  1. Open the WebLogic Server Administration Console by entering:
  2. http://host:port/console

    In this URL host is the name of your server and port is the port at which your server listens. For example:

    http://localhost:7001/console

  3. In the WebLogic Server Administration Console:
    1. Add the adapter group to the default WebLogic Server security realm.
    2. Add a user to the adapter group.
    3. Save your changes.
  4. To configure and deploy application views, go to:
  5. http://host:port/wlai

    In this URL host is the name of your server and port is the port at which your server listens. For example:

    http://localhost:7001/wlai

    The Application Integration Design Console Logon page is displayed.

    Test Result Page<img src= " title="Test Result PageTest Service Page " width="456" height="269" align="middle" border="0" hspace="0" vspace="0">


     
  6. Log on to BEA WebLogic Integration by entering your username and password in the appropriate fields.
  7. Configure and publish your application views by completing the procedures described in Defining Application Views in Using Application Integration.

 


Database-Specific Error Messages

When using the DBMS sample adapter, you may see database-specific error messages written to the log file. The section identifies some of the more common database-specific error messages.

From time to time, when using Sybase or MSSQL databases, warnings are issued stating that the active database and/or language has been changed. These warnings come from the Sybase and MSSQL databases when the active database or language is changed on a connection. Since the catalog is changed at various points in the DBMS sample adapter, users of the sample adapter will inevitably see these messages. These warnings are harmless and can be ignored.

When an adapter instance in an MSSQL XA environment is automatically suspended and resumed, error messages similar to the following are thrown.

<Oct 15, 2003 4:40:30 PM PDT> <Error> <JDBC> <BEA-001112>
<Test "SELECT COUNT(*) FROM sysobjects" set up for pool "wlaiPool" failed with
exception: "javax.transaction.xa.XAException: [BEA][SQLServer JDBC Driver]
No more data available to read.".>

This is a JDBC-level error, generated as the JDBC container cleans up existing/dead connections to the restarted DBMS instance. This type of exception is normal in this case; the EIS is available, the adapter instance is resumed successfully, and the JDBC container recovers.

When using the DBMS sample adapter with a Microsoft SQL Server database, use the WebLogic Server Administration Console to enable the TestReservedConnection parameter for the connection pool used for application integration. If the parameter is not enabled, the auto resume or manual resume features do not work and a SQLException similar to the following is thrown:

java.sql.SQLException: [BEA][SQLServer JDBC Driver]No more data
available to read

 


How the DBMS Sample Adapter Design-Time GUI Was Developed

The design-time GUI is an interface that allows a user to create application views, add services and events, and deploy an adapter that is hosted in a BEA WebLogic Integration environment. This section explains how the design-time GUI for the DBMS sample adapter was developed:

Step 1: Identify Requirements

Before development of the design-time GUI for the DBMS was begun, values for the following parameters needed to be determined:

Step 2: Identify Required Java Server Pages

The DBMS sample adapter uses the Java Server Pages (JSPs) delivered with the ADK for a design-time GUI. Additional JSPs have been added, however, to provide adapter-specific functionality. The additional JSPs are described in the following table.

Table E-4 Additional ADK JSPs 

Filename

Description

addevent.jsp

The Add Event page allows a user to add a new event to the application view.

addservice.jsp

The Add Service page allows the user to add a new service to the application view.

browse.jsp

The Browse page handles the logic flow and display for the Browse window of the DBMS sample adapter. Although this functionality was developed specifically for this adapter, it illustrates a fairly common interaction between a design-time interface and an underlying adapter.

The Browse page calls the DesignTimeRequestHandler (handler) of the DBMS sample adapter, which extends the ADK's AbstractDesignTimeRequestHandler. The best way to understand the browse functionality of the DBMS sample adapter is to deploy the adapter and use your Web browser to access the design-time framework.

confconn.jsp

The Confirm Connection page provides a form on which a user can specify connection parameters for the EIS.

testform.jsp

The Testform page is included (<jsp:include page='testform.jsp'/>) in the ADK's testsrvc.jsp page. It accesses the InteractionSpec for this interaction and displays the SQL for the service. It then creates a form for gathering the user input required to test a service.

To create a form, Testform gets the RequestDocumentDefinition from the handler's application view and then passes it, with the .jsp Writer, to a utility class called com.bea.adapter.dbms.utils.TestFormBuilder. This class creates the form.


 

Step 3: Create the Message Bundle

To support the internationalization of all text labels, messages, and exceptions, the DBMS sample adapter uses a message bundle based on a text property file. The property file includes both name-value pairs copied from the BEA_WLS_SAMPLE_ADK property file, and new entries, added for properties specific to the DBMS sample adapter.

The message bundle for the DBMS sample adapter resides in the WLI_HOME/adapters/dbms/src directory, which was installed with the ADK. For details, see the BEA_WLS_DBMS_ADK.properties file in the same directory.

For additional instructions on creating a message bundle, see the JavaSoft tutorial on internationalization at:

http://java.sun.com/docs/books/tutorial/i18n/index.html

Step 4: Implement the Design-Time GUI

To implement the design-time GUI, you need to create a DesignTimeRequestHandler class. This class accepts user input from a form and provides methods to perform a design-time action. For more information about the DesignTimeRequestHandler, see Step 4: Implement the Design-Time GUI.

The DBMS sample adapter public class DesignTimeRequestHandler extends AbstractDesignTimeRequestHandler, and it provides the methods shown in the following table.

Table E-5 Methods for the DBMS Sample Adapter Design-Time GUI 

Method

Description

browse(java.lang.String dbtype, com.bea.connector.DocumentRecord input)

Handles the back-end behavior for the Browse functionality of the addevent.jsp and addservc.jsp pages.

getAdapterLogicalName()

Returns the adapter's logical name and helps the parent class when entities such as application views are deployed.

getManagedConnectionFactoryClass()

Returns the adapter's SPI ManagedConnectionFactory implementation class, which is then used by a parent class to get a CCI connection to the EIS.

supportsServiceTest()

Indicates that this adapter supports the testing of services at design time.

initServiceDescriptor(ActionResult result, IServiceDescriptor sd, HttpServletRequest request)

Initializes a service descriptor, which involves creating the request and response schemas for a service. A typical approach is to execute an Interaction against the EIS to retrieve metadata and then transform that metadata into an XML schema.

Consequently, the CCI interface provided by the adapter was used. This method is called from the addsrvc method of the AbstractDesignTimeRequestHandler.

initEventDescriptor(ActionResult result, IEventDescriptor ed, HttpServletRequest request)

Initializes an event descriptor. The event descriptor provides information about an event on an application view. Subclasses must supply an implementation of this method.

If events are not supported, then the implementation should throw an UnsupportedOperationException. This method is not called (by the AbstractDesignTimeRequestHandler) until the name and definition of the event have been validated and it is confirmed that the event does not already exist for the application view.

GetDatabaseType()

Used to determine the type of database management system being used. BEA WebLogic Integration supports PointBase and Oracle.


 

Step 5: Write Java Server Pages

Consider incorporating the following practices into your development process:

Use Custom JSP Tags

Because the Java Server Pages (JSPs) are displayed on the display.jsp page, display.jsp is the first .jsp file that needs to be written. The ADK provides a library of custom JSP tags, which are used extensively throughout the Java server pages of the ADK and DBMS sample adapter. These tags support numerous features, such as the ability to add validation and to save a value entered in a field when the user clicks a button.

Save an Object's State

While writing the JSPs, with the ADK, for your adapter, you may need to save an object's state. You can do so in any of a number of ways. The AbstractDesignTimeRequestHandler maintains an ApplicationViewDescriptor of the application view being edited. This [file?] is often the best place in which to save state; calls to the handler from this file are fast and efficient.

As an alternative, you can request a Manager Bean from the AbstractDesignTimeRequestHandler, using its convenience methods (getApplicationViewManager(), getSchemaManager(), and getNamespaceManager()) to retrieve information from the repository about an application view. This method is more time-consuming but, occasionally, it may be necessary. Because it is a JSP, you can also use the session object, although everything put in the session must explicitly implement the java.io.serializable interface.

Write the WEB-INF/web.xml Deployment Descriptor

Write the WEB-INF/web.xml deployment descriptor. In most cases, you should use the adapter's web.xml file as a starting point and modify components as necessary. To see the web.xml file for this adapter, go to:

WLI_HOME/adapters/dbms/src/war/WEB-INF/web.xml

For detailed information, see the BEA WebLogic Server product documentation at:

http://www.oracle.com/technology/documentation/index.html

 


Run-Time Considerations

You can manage your application integration run-time environment using the WebLogic Integration Administration Console. For more information, see Application Integration in Managing WebLogic Integration Solutions at the following URL:

http://download.oracle.com/docs/cd/E13214_01/wli/docs81/manage/ai.html

The following sections describe administration issues specific to the DBMS sample adapter.

Changing Event Connections

Please consider the following when modifying the EventSchema parameter of the event connection for DBMS sample adapter instances:

Note: You may need to redeploy servers if there is a change in the database instance used by the JDBC connection pool for the application integration event.

The schema name/table owner associated with an event trigger retains the information provided at design time. When you edit the event connection from the WebLogic Integration Administration Console, you point to a new connection setting for the event tables; any event metadata is associated with the new connection after the application is redeployed from the WebLogic Integration Administration Console. The event trigger still points to the old schema name.

When changing event connections to a new database, you must ensure that the new database has a schema and a table with the same name as the previous settings. The new table is used for triggering events.

You can point the event trigger to the new schema/table name using environment variables. Note that the old trigger is not deleted and that the adapter instance must be redeployed. To delete the old trigger, redeploy the application from the WebLogic Server Administration Console. The environment variable for the schema name is capable of changing the schema name/table owner where the trigger polls.

It is good practice to limit events to one per table in the database. This avoids multiple event pollers attempting to access one table.

Administering a DBMS Sample Adapter Instance Used by Multiple Application Views

Please consider the following when setting up DBMS sample adapter instances used by multiple application views. Only one adapter instance should be used for all application views needing an event for a given table/trigger type. If you have two application views that each depend on CUSTOMER_TABLE inserts, make sure they both use the same adapter instance. This is because the event generator for the adapter instance deletes the insert trigger from CUSTOMER_TABLE when all its event subscriptions are undeployed. If AppView1 uses adapter_instance_1 and is undeployed, adapter_instance_1 deletes the insert trigger for CUSTOMER_TABLE. If AppView2, which also needs CUSTOMER_TABLE inserts, uses adapter_instance_2, it will be starved of events because adapter_instance_1 previously deleted the trigger. If AppView2 uses adapter_instance_1, adapter_instance_1 knows that AppView2 still needs the CUSTOMER_TABLE insert event and does not delete the trigger even if AppView1 is undeployed.

Multiple Event Generators Using the Same DBMS Instance

You can distribute event generators among nodes in a WebLogic Integration cluster. This improves load balancing and fault tolerance of event generation. For an example of multiple event generators using the same DBMS instance, see Example: DBMS Sample Adapter.

You must set event generator targets when in a clustered environment. A blank target ("") does not trigger events on any node in the cluster. (In a single node environment, no entry is needed; a blank event generator target value kicks off events for the one server.)

 

Back to Top Previous Next