Your Browser is not longer supported

Please use Google Chrome, Mozilla Firefox or Microsoft Edge to view the page correctly
Loading...

{{viewport.spaceProperty.prod}}

Program framework for Common Client Interface (CCI)

When deploying a managed connection factory in BeanConnect you specify the EIS partner to be addressed via this managed connection factory. You use the lookup() method to search for the connection factory and obtain a connectivity object by calling the getCon nection() method.

You can request an interaction object via the CCI connection which you obtain from the CCI connection factory. This interaction object implements an execute() method for initiating an interaction. The execute() method also knows a BCCciInteractionSpec object in addition to the input record and output record. In this BCCciInteractionSpec you define an interactionVerb (SYNC_SEND, SYNC_SEND_RECEIVE or SYNC_RECEIVE) and, at the same time, the name of the EIS application. This enables you to control an interaction by providing suitable data instead of calling methods. The default value of the interactionVerb is SYNC_SEND_RECEIVE.
For details, see the JavaDoc of BeanConnect.

Program framework for dialog communication (CCI)

For dialog communication with your server application over the CCI Interface in BeanConnect, proceed as follows:

  1. Set up the initial context:

    javax.naming.InitialContext ic = new InitialContext();

  2. Reference a connection factory:

    javax.resource.cci.ConnectionFactory cf = (ConnectionFactory)ic.lookup("java:comp/env/eis/myEIS");

    A dialog service is assigned as the default service to the connection factory referenced by eis/myEIS.

  3. Set up the connection

    javax.resource.cci.Connection con = (Connection)cf.getConnection();

    Alternatively, an EJB may pass security-related information (user ID/password) to BeanConnect in a BCCciConnectionSpec object. In this case you specify:

    net.fsc.jca.communication.cci.BCCciConnectionSpec;
    cred = new BCCciConnectionSpec("myuser", "mypass");
    javax.resource.cci.Connection con = (Connection)cf.getConnection(cred);
    
  4. Create an Interaction object and an InteractionSpec object:

    Interaction ix = (Interaction)con.createInteraction();
    BCCciInteractionSpec is = new BCCciInteractionSpec(InteractionSpec.SYNC_SEND_RECEIVE);
    

    Whereas an Interaction object is created from the Connection object on which it is to be used, the InteractionSpec object is created using a constructor of the implementation class.

    An Interaction object enables an EJB to communicate with an EIS application. 
    An InteractionSpec object holds properties for driving an interaction with this EIS application. It is used by an interaction to execute the specified function in the EIS application.

  5. Create a BCRecord object that serves as a container for the message to the EIS and another BCRecord object that serves as a container for the reply message. This is done by means of a BCRecordFactory object:

    net.fsc.jca.communication.cci.BCRecordFactory rf =
       (BCRecordFactory)cf.getRecordFactory();
    net.fsc.jca.communication.cci.BCRecord reqrec = (BCRecord) rf.createB-
    CRecord("request");
    net.fsc.jca.communication.cci.BCRecord replrec = (BCRecord) rf.createB-
    CRecord("reply");
    

    After creation, a BCRecord object contains an empty OltpMessage object, which can be retrieved from the BCRecord object. Subsequently, the BCRecord object can be populated with OltpMessageRecord or OltpMessagePart objects.

  6. Populate the OltpMessage object of the message which is destined for the EIS with data (here: with two OltpMessagePart objects):

    net.fsc.jca.communication.OltpMessage request = reqrec.getOltpMessage();
    request.addMessagePart("request - message part1");
    request.addMessagePart("request - message part2"); 
    
  7. Execute the interaction:

    ix.execute(is, reqrec, replrec);

    The BCRecord object returned from this call again holds an OltpMessage object, which in turn contains the reply sent by the EISapplication in an OltpMessageRecord or OltpMessagePart object.

  8. Receive the reply message:

    net.fsc.jca.communication.OltpMessage reply = 
    replrec.getOltpMessage();
    java.util.Iterator<net.fsc.jca.communication.OltpMessagePart> it = 
    reply.getMessageParts();
    
    net.fsc.jca.communication.OltpMessagePart msgPart;
    String msgText="";
    
    while (it.hasNext()) {
       msgPart = (OltpMessagePart) it.next();
       msgText += msgPart.getText();
    } 
    
  9. Close the connection:

    con.close();

Further information on how to program the CCI interfaces is provided in the JavaDoc of the CCI.

You will find a code sample in Example 14 on Code samples for outbound communication .

Program framework for asynchronous communication (CCI)

For asynchronous communication with your server application over the CCI Interface in BeanConnect, proceed as follows:

  1. Set up the initial context:

    javax.naming.Context ic = new InitialContext();

  2. Reference a ConnectionFactory:

    javax.resource.cci.ConnectionFactory cf = (ConnectionFactory)ic.lookup("java:comp/env/eis/myAsyncEIS");

  3. Set up the connection:

    javax.resource.cci.Connection con = (Connection)cf.getConnection();

    Alternatively, an EJB may pass security-related information (user ID/password) to BeanConnect in a BCCciConnectionSpec object. In this case you specify:

    net.fsc.jca.communication.cci.BCCciConnectionSpec cred = new BCCciConnectionSpec("myuser", "mypass");
    javax.resource.cci.Connection con = (Connection)cf.getConnection(cred);
    
  4. Create an Interaction object and an InteractionSpec object:

    An Interaction object enables an EJB to communicate with a partner application. An InteractionSpec object holds properties for driving an interaction with a partner application. It is used by an interaction to execute the specified function in the EIS application.

    Whereas an Interaction object is created from the connection object on which it is to be used, the InteractionSpec is created using a constructor of the implementation class:

    Interaction ix = (Interaction)con.createInteraction();
    net.fsc.jca.communication.cci.BCCciInteractionSpec is = new 
       BCCciInteractionSpec(InteractionSpec.SYNC_SEND,
                                                    "ASYNTAC");
    

    The assignment of the asynchronous service ASYNTAC specifies that communication will be asynchronous.

    Here, the SYNC_SEND has the same effect as a flush() call when using the BeanConnect-specific interfaces.

  5. Create a BCRecord object that serves as a container for the request message. This is done by means of a recordFactory:

    net.fsc.jca.communication.cci.BCRecordFactory rf=
       (BCRecordFactory)cf.getRecordFactory();
    net.fsc.jca.communication.cci.BCRecord reqrec = 
       rf.createBCRecord("request");
    

    After creation, a BCRecord object contains an empty OltpMessage object, which can be retrieved from the BCRecord object and then can be assigned with OltpMessageRecord and/or OltpMessagePart objects.

  6. Populate the OltpMessage object of the request record with data (here: with two OltpMessagePart objects):

    net.fsc.jca.communication.OltpMessage request = reqrec.getOltpMessage();
    request.addMessagePart("request - message part1");
    request.addMessagePart("request - message part2"); 
    
  7. Execute the interaction:

    ix.execute(is, reqrec);

  8. Close the connection:

    con.close();