Note that the Communication Block must be initialized through the init method of the ComManager class. This init method invokes the corresponding methods of the classes implementing the communication protocols, currently ComPointTCP, ComPointHTTP and ComPointMail. The invocation of the init method of ComPointMail will result in an actual initialization, only if the three parameters which are used by ComPointMail (see the section on the configuration parameters below) are set in the configuration file. Otherwise, the mail protocol may not be used.
The initiator is the module which sends the first message and the responder is the module receiving it. Here is a sample code for the initiator side:
// Create the address of the responder. ComPointAddress address = new ComPointAddress(protocol, host, port, path); // Open an initiator ComPoint. ComPoint comPoint = ComManager.comPoint(ComPointConstants.COMPOINT_INITIATOR, address); // Send a message. Message message = Message(...); comPoint.write(message); // Receive a response. Response response = (Response)comPoint.read(); // Exchange of more messages and responses. ... ... // Close the initiator ComPoint. comPoint.close();
and here is the corresponding code for the responder side:
// Create the local address. ComPointAddress address = new ComPointAddress(protocol, port); // Open the server ComPoint. serverComPoint = ComManager.comPoint(COMPOINT_SERVER, address); // Accept the connection from the initiator, creating the responder ComPoint. ComPoint comPoint = serverComPoint.accept(); // Receive the message. Message message = (Message)comPoint.read(); // Send the response. Response response = new Response(...); comPoint.write(response); // Exchange of more messages and responses. ... ... // Close the responder ComPoint. comPoint.close(); // Eventually close the server ComPoint. serverComPoint.close();
The only sequence constraint between the initiator and responder code executions is that the server ComPoint must have been opened before the initiator ComPoint. Message and Response are user defined classes implementing Streamable; refer to semper.util.serial.
// Create the address of the responder. ComPointAddress address = new ComPointAddress(protocol, host, port, path); // Open an initiator ComPoint and initiate a channel. ComPoint comPoint = Channel.openInitiatorChannel(address, options, correlator); // Send a message. String message = new Message(...); comPoint.write(message); // Receive a response. String response = (Response)comPoint.read(); // Exchange of more messages and responses. ... ... // Close the ComPoint and channel. comPoint.close();and here is the corresponding code for the responder:
// Create the local address. ComPointAddress address = new ComPointAddress(protocol, port); // Start a service-point thread. ChannelServicePointThread servicePoint = Channel.startServicePointThread(address); // Accept a channel with a specific correlator and open a responder ComPoint. ComPoint comPoint = servicePoint.openResponderChannel(options, correlator); // Receive the message. String message = (Message)comPoint.read(); // Send the response. String response = new Response(...); comPoint.write(response); // Exchange of more messages and responses. ... ... // Close the responder ComPoint. comPoint.close(); // Eventually stop the service-point thread. servicePoint.stop();
The only sequence constraint between the initiator and responder code executions is that the service-point thread must have been started before the initiator opens the channel.
In order to use ComPointMail, a mailcap should be set up such that whenever an e-mail is received from the remote ComPointMail, it is forwarded through ComPointMailReceiver to the local ComPointMail. The e-mails sent by ComPointMail have the mime content-type application/x-semper and are mime-base-64 encoded. For the local mail handler, a mailcap must be setup for this content-type. Whenever an e-mail with content-type application/x-semper, either automatically or by user clicking on an icon, ComPointMailReceiver is invoked on the content of the mail. As an example of what a mailcap which invokes ComPointMailReceiver looks like, for zmail on AIX, it is setup through the following attachment type:
ENCODE application/x-semper None TYPE application/x-semper \ "java semper.comm.ComPointMailReceiver '%s'&" \ None \ "SEMPER Message" BITMAP application/x-semper ~/SEMPER/zmail/SEMPER.xbmAlso note that there should be a _sempconfig file in your home-directory or you have to go to whatever directory your config-file is in before invoking java in mailcap. The reason for this is that ComPointMailReceiver gets the receiverPort parameter from the config-file.
The following are the configuration parameters of the communication block:
The following classes implement the ComPoint API:
The following classes implement the Channel API:
C: i1 = Channel.openInitiatorChannel( Correlator_A); C: i2 = Channel.openInitiatorChannel( Correlator_A); S: r1 = spt.openResponderChannel( Correlator_A); S: r2 = spt.openResponderChannel( Correlator_A);where C denotes a client machine and S a server machine. The requests are served in a FIFO way. J.Brauckmann SRB