Installing Upgrading Designing Configuring Deploying Monitoring Administering Troubleshooting Reference JBI Components
Close Print View
Designing: Outbound JCA Resource Adapter Client Code
 

Classic Java CAPS

Developing Java CAPS Projects

Using SOAP Message Handlers

Creating a Runtime Environment

Designing Business Processes in the Sun Business Process Manager

Working with TCP/IP HL7 Collaborations

Developing Sun Master Indexes (Repository)

Developing Sun Master Patient Indexes

Developing OTDs for Application Adapters

Developing OTDs for Communication Adapters

Developing OTDs for Database Adapters

Developing OTDs for Web Server Adapters

Designing with Application Adapters

Designing with Communication Adapters

Designing with Web Server Adapters

SWIFT Integration Projects

Java EE Based Components

Designing with Sun JCA Adapters

Technical Overview for Sun JCA Adapters

Inbound JCA Resource Adapter Client Code

Outbound JCA Resource Adapter Client Code

Object Type Definition Wizards

Installation of Netbeans Modules

Installing the Modules Pack

Installation of Base Components for Sun JCA Adapters

To Install Base Components

Configuring Runtime Components in an EJB/JCA Application

Configuring Connector Pools for File Adapter

Configuring Connector Pools for Oracle Adapter

Deployment of Sun JCA Adapters

To Deploy JCA Adapters via Command Line

To Deploy JCA Adapters via the Admin Console

Using the Oracle Wizard and JCA Adapter Tooling with an EJB Project

To implement the Oracle JCA Adapter with an EJB Project

Using the Oracle Applications Wizard and JCA Adapter Tooling with an EJB Project

To implement the Oracle Applications JCA Adapter with an EJB Project

Using the Oracle Applications Object Type Definition

About the TCP/IP JCA Adapter

Defining Constants and Variables

Using Database Operations

Developing Sun Master Indexes

Using the JMS JCA Wizard

Using the JAXB Wizard and Code-Seeder Pallete

Outbound JCA Resource Adapter Client Code

JCA Adapters that support outbound connection to an external application are utilized via the client interface supported by the adapter. The client interface supported by Sun JCA Adapters are based on a simple Application Client Interface. The client interface involves establishment of an application connection via JNDI. The application connection is a container managed connection obtained from a connection pool. The application connection is used along with the OTD objects provided with the JCA adapter to perform operations on the external application.

The tooling for creating code, based on the outbound JCA's client interface is provided via the adapter in the form of specific objects from the Palette draggable onto the code editor. The Palette is made visible by selecting Palette from the Window top-level drop-down menu.

Upon dragging an item from the Palette to the code editor, the JCA wizard is started. In the JCA wizard, a method name must be specified. The method will be added to the code being edited. Depending on the type of external dragged from the Palette, the choice of OTD to be used may need to be specified. The JCA client interface code, required to obtain a JCA connector resource from JNDI, establishes then closes the JCA connection. It then instantiates the associated OTD object, which is also added. The method specified in the JCA wizard is created to simplify development of application logic as the method implementation can simply use OTD objects passed in.

For example, dragging the File object from the Palette to the onContents method of the File MDB and specifying a method name "send" in the JCA wizard adds the following code in the onContents method implementation:

public void onContents(byte[] data, String encoding) throws FaultException,

InboundException {

try {

_invoke_send(data, encoding);

} catch (java.lang.Throwable t) {

ectx.setRollbackOnly();

java.util.logging.Logger.getLogger(this.getClass().getName(

)).log(java.util.logging.Level.WARNING, "Failed to invoke _invoke_send: " + t, t);

}

}

The user application logic can be implemented in the send method which works directly with the OTD objects passed in.

private void send(byte[] data, String encoding, com.stc.connector.fileadapter.appconn.FileClientApplication fileOTD) throws java.lang.Exception {

}

The additional code shown below are also added providing the connection establishment and OTD instantiation.

// <editor - fold defaultstate= collapsed desc="Connection setup and takedown.

Click on the + sign on the left to edit the code.">

private void _invoke_send(byte[] data, String encoding) throws java.lang.Exception {

com.stc.connector.appconn.common.ApplicationConnection fileConnection = null;

try {

if (fileConnection != null) {

fileConnection.close();

}

} catch (Exception e) {

}

}

} // </editor-fold>

// <editor-fold defaultstate="collapsed" desc="file resource declaration. Click on the + sign on the left to edit the code.">

// comments for inserted variable

@javax.annotation.Resource(name = "jca/file", description = "", shareable = false)

private com.stc.connector.appconn.common.ApplicationConnectionFactory file; // </editor-fold>

// <editor-fold defaultstate="collapsed" desc="EJBContext declaration. Click on the + sign on the left to edit the code.">

@javax.annotation.Resource

private javax.ejb.EJBContext ectx; // <editor-fold>