Installing Upgrading Designing Configuring Deploying Monitoring Administering Troubleshooting Reference JBI Components
Close Print View
Designing: Using the Oracle Wizard and JCA Adapter Tooling with an EJB Project
 

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

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

The following task outlines the steps need to implement a specific EJB project where a directory is polled for input data using a query statement (the statement is executed against an Oracle database), and the results are written to an output file.

To implement the Oracle JCA Adapter with an EJB Project

  1. Create the required connector or connectors in the Application Server. In this particular example, create a connector for the File eWay and another for the Oracle eWay.
  2. Navigate to the Application Server Admin Console at htt://localhost:4848.
  3. Configure the parameters for your connectors under Resources > Connector > Connector Connection Pool and Resources > Connector > Connector Resources.
  4. Launch Netbeans.
  5. From the File menu, select Enterpries > EJB Module.
  6. Create a new EJB project OracleInvokeEJB
    New EJB Project
  7. Launch the Oracle wizard by right—clicking on the OracleInvokeEJB project and selecting New.
    Launch Oracle Wizard
  8. Select Other > SOA > Oracle OTD Wizard.
  9. Click Next.
  10. Enter the Oracle database connection information, and click Next.
    Oracle Connection Information
  11. Add the database objects (tables, stored procedures, and prepared statements) required for the project, and click OK.
    Database Objects
  12. Enter a name for the OTD.
    Enter Name for OTD

    An OTD and a JAR file containing the code corresponding to the above selected database objects are generated. The OTd is generated in the project at the location src/java/otds. The JAR file is added to the project libraries.


    OTD Jar Generation
  13. Create a JCA-driven MDB by navigating to the File menu, and selecting New Project > Enterprise.
    JCA-driven MDB
  14. Select File Inbound RAR as the Inbound JCA.
    Choose File Inbound RAR
  15. Edit the Inbound File JCA configuration parameters in the following two dialogue windows.
    Edit JCA Configuration Parameters First Box
    Edit JCA Configuration Parameters Second Box

    An MDB is created.


    Generated MDB
  16. In the generated MDB, drag Oracle from the palette to invoke Oracle.
  17. Drag and drop the File JCA onto the onContents() of the MDB, and enter the parameters for the File eWay JCA Adapter declarations.
    JCA Adapter Declaration

    The Resource JNDI Name should be the same as that declared in the GlassFish Application Server (for example, Resources > Connector > Connector Resources)

  18. Select the Oracle OTD that is generated and click Finish.
    Select Oracle OTD
  19. Issue a select statement and iterate through the resultset, and write to File.
    File Outbound
  20. The resulting Java template is created.
    Java template
  21. Implement the following Java code:

    The following code is the output:

    public void onContents(byte[] data,
                    String encoding) throws FaultException, InboundException {
           
        try {           
            _invoke_getEmpData(data, encoding);      
        } catch (java.lang.Throwable t) {           
        ectx.setRollbackOnly();           
        java.util.logging.Logger.getLogger(this.getClass().getName()).log(java.util.
            logging.Level.WARNING,
        "exception occurred when invoking method: ", t);
        }       
        
        try {           
            _invoke_writeEmpData(data, encoding);       
        } catch (java.lang.Throwable t) {           
            ectx.setRollbackOnly();           
            java.util.logging.Logger.getLogger(this.getClass().getName()).log(java.util.
                logging.Level.WARNING,
            "exception occurred when invoking method: ", t);
            }
       }
        private String _execute_getEmpData(byte[] data, String encoding,
                otd_emp1.Otd_emp1OTD oraOTD) throws java.lang.Exception {     
        //select all records from EMP table using the method select available
        //on the OTD       
        oraOTD.getEMP().select("");       
        //Iterate thru the resultset and write to File.   
        while(oraOTD.getEMP().next()) {
               enameValues = oraOTD.getEMP().getENAME() + ", " + enameValues;        
        }       
    
    }
    
        private void _execute_writeEmpData(byte[] data, String encoding,
                        com.stc.connector.fileadapter.appconn.FileClientApplication fileOTD)
                            throws java.lang.Exception {
    
           fileOTD.setText(new String(data));
        fileOTD.write();
         }