This sample shows the use of ATI (automatic transaction initiation). To use this sample, the CICS® program EP03 must be installed on the CICS server. This sample also uses the client and server compression classes.
java com.ibm.ctg.samples.epi.HighEpiI1 [GatewayUrl] [Port]
The Gateway address and port can be provided as command line parameters. If no URL is provided the sample programs default to local: mode.
A list of available servers is displayed. When a server has been selected, the application creates an extended, sign-on incapable terminal, and makes a synchronous connection to it. The user is prompted for a transaction ID; this transaction must be located on the CICS server and it must be able to return the terminal to the idle state with the PF3 key. Note that it is program EP03 (see COBOL/C/Map samples) that demonstrates the use of an ATI.
Because the design of the client application requires the reply to the start transaction to be asynchronous, the sample program must instantiate an object that implements the Session interface. The sample program contains an inner class named ReplyHandler that does this. Therefore before the transaction is sent, the ReplyHandler is instantiated and passed as a parameter to either setSession() or send().
When the sample program sends the transaction, its thread enters a loop that tests to see if a reply has been received. A different application could take this opportunity to do other tasks, but all that is necessary in the sample program is to monitor whether a reply has been received. When the reply is sent, the method handleReply() is run on the ReplyHandler object in its own thread.
This method sets a Boolean value in the sample program thread to indicate that a reply has been received. Upon receipt of the reply, the state of the terminal is interrogated. If it is in server state the client application continues to wait for a reply, otherwise the application continues, depending on the derived state (see the comments in the source for further details). The sample program terminates when the terminal has been returned to the idle state and disconnected.