Using the Sun 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.