Using the Sun HL7 JCA Adapter

Designing an EJB Module to Use HL7 JCA Adapter Code

This section provides step-by-step procedures for creating an EJB Module project and populating it with HL7 JCA Adapter code.

ProcedureTo Create an EJB Module Project

  1. In the NetBeans IDE main menu, click File -> New Project.

    The New Project wizard appears.

  2. Select the following category and project type and then click Next:

    • Category: Java EE

    • Project: EJB Module

  3. Provide a project name and location and then click Next.

  4. Keep the default values for Server and Java EE Version, and click Finish.

    The new project is added to the Projects tree.

ProcedureTo Add a HL7 JCA Adapter to an EJB Project

  1. Right-click the EJB Module project and select New -> JCA Message-Driven Bean:

    The New JCA Message-Driven Bean wizard appears.

  2. Provide a package name and then click Next:

    JCA Message-Driven Bean wizard: Provide Name
and Location
  3. For the Choose Inbound JCA step, select HL7 JCA Adapter and then click Next:

    JCA Message-Driven Bean wizard: Choose Inbound
HL7 JCA Adapter
  4. In the final step of the wizard, you can optionally edit the instance properties before clicking Finish.

    JCA Message-Driven Bean wizard: Edit Activation
Configuration

    If you click the ellipsis to the right of the Configuration property (as shown above), you can view or edit configuration settings of the HL7 JCA Adapter:

    JCA Message-Driven Bean wizard: Editing configuration
properties.

    For a complete list and description of configuration properties, see Configuration Settings for the HL7 JCA Adapter.

ProcedureTo Use HL7-Specific Sample Code

  1. In the NetBeans IDE, open the .java file containing the message-driven bean you just created.

  2. From the palette, under JCA, drag the HL7 JCA onto the code canvas and drop it between the curly brackets of the receive as shown in the following illustration:

    Image shows the HL7 JCA dragged  from the JCA
code palette to the curly brackets of the receive.

    When the HL7 JCA is dropped into the Receive method, the JCA Wizard appears.

  3. In the JCA Wizard, provide appropriate values for the HL7 JCA Adapter declaration and then click Finish

    Image shows the JCA Wizard and brows window used
to select the Resource JNDI Name for the adapter declaration.

    Result:HL7 code is added, as shown below. Note that the code in the image below was wrapped for display purposes.

    Image show the sample code added by dragging
HL7 JCA from the JCA palette

    The expanded code appears as follows.


      public void receive(HL7ServerApplication input )
          throws Exception {
           try {
               _invoke_myHL7Method(input);
           } 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_myHL7Method: " + t, t);
           }
             }
    
       private void myHL7Method(HL7ServerApplication input, com.stc.connector.appconn.tcpip.
    hl7.HL7AppMessage hl7AppMsg) throws java.lang.Exception {
       } 
    
       // <editor-fold defaultstate="collapsed" desc="Connection setup and takedown. Click 
    on the + sign on the left to edit the code.">
       private void _invoke_myHL7Method(HL7ServerApplication input) throws java.lang.Exception {
           com.stc.connector.appconn.common.ApplicationConnection hl7Connection = null;
           try { 
               java.util.Properties hl7Props = new java.util.Properties();
               hl7Props.put("conn-props.collaboration.oid", "placeholder");
               hl7Props.put("conn-props.connection.name", "placeholder");
               hl7Connection = hl7.getConnection(hl7Props);
               com.stc.connector.appconn.tcpip.hl7.HL7ClientApplication hl7OTD = (com.stc.
    connector.appconn.tcpip.hl7.HL7ClientApplication) hl7Connection.createApplication("");
               com.stc.connector.appconn.tcpip.hl7.HL7AppMessage hl7AppMsg = hl7OTD.getHL7Message();
               myHL7Method(input, hl7AppMsg); 
           } finally {
               try {
                   if (hl7Connection != null) {
                       hl7Connection.close();
                   }
               } catch (Exception e) {
               }
           } 
       } // </editor-fold>
       // <editor-fold defaultstate="collapsed" desc="hl7 resource declaration. Click on the + 
    sign on the left to edit the code.">
       // comments for inserted variable
       @javax.annotation.Resource(name = "esb/poolHL7", description = "", shareable = false)
       private com.stc.connector.appconn.common.ApplicationConnectionFactory hl7; // </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>
    } 

    Note –

    The above code is wrapped for display purposes.


  4. Expand each block and edit the code as needed for your implementation.