darx
Class DarxCommInterface

java.lang.Object
  extended by darx.DarxCommInterface
All Implemented Interfaces:
java.io.Serializable

public class DarxCommInterface
extends java.lang.Object
implements java.io.Serializable

This is the communication interface, specific to an agent, used to send messages to other agents.

In practical terms, the leading DarxTask of a replication group creates an instance of this class in order to communicate with the other leaders via their corresponding RemoteTask.

The DarxCommInterface is responsible for wrapping the contents of the messages in instances of DarxMessage, as well as keeping count of the sequence number of the sent messages and increasing this number for each emission.

NB: It might be a good idea to force this class to be a transient attribute of the DarxTask. Only the leader of a replication group would then be able to send messages.

See Also:
Serialized Form

Constructor Summary
DarxCommInterface(java.lang.String name)
          Constructs a new instance for this class.
 
Method Summary
 void sendAsyncMessage(RemoteTask rem, java.io.Serializable body)
          Sends an asynchronous message to an agent.
 java.lang.Object sendSyncMessage(RemoteTask rem, java.io.Serializable body)
          Sends a synchronous message to an agent.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DarxCommInterface

public DarxCommInterface(java.lang.String name)
Constructs a new instance for this class.

Parameters:
name - the name of the owner of this instance; generally the name of the corresponding task.
Method Detail

sendAsyncMessage

public void sendAsyncMessage(RemoteTask rem,
                             java.io.Serializable body)
Sends an asynchronous message to an agent.

Parameters:
rem - the remote reference to the corresponding replication group.
body - the contents of the emission.
See Also:
RemoteTask.sendAsyncMessage(DarxMessage msg)

sendSyncMessage

public java.lang.Object sendSyncMessage(RemoteTask rem,
                                        java.io.Serializable body)
Sends a synchronous message to an agent.

Parameters:
rem - the remote reference to the corresponding replication group.
body - the contents of the emission.
See Also:
RemoteTask.sendSyncMessage(DarxMessage msg)