|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectksu.cis.mom.MomObject
ksu.cis.mom.Agent
The Agent class is an abstract class that defines the minimum requirements
for an agent to use agentMom package. This class inherits from
MomObject class. It must be runnable as a separate thread,
which requires a run method. It also has two required parameters that must
be set for each agent, the name of the agent and the port number on which
its message handler will listen for incoming messages.
Also, this class is associated with the
MessageHandler, MulticastHandler,
BroadcastHandler, SecureUnicastHandler and
SecureMulticastHandler class.
An agent needs to start the correct handler to be able to receive the start of conversation from other agents. Furthermore, each agent must implement/override receive message method for each type of conversation. For unicast conversation, the agent must implement the receiveMessage method. For the other conversation, the agent must override the receive method corresponding to each conversation. The receive method will be called by the corresponding message handler when the agent has received a connection starting a new conversation. For example, the corresponding handler of receiveMulticastConversation method is MulticastHandler class, and the corresponding handler of receiveMessage method MessageHandler class.
History:
4 October 1999 - Creation Date
3 May 2001 - extended to allow conversations to work with either agents or
conversations as their parents
Summer 2003 - Modify and Add more comments suitable for JavaDoc.
Fall 2003 - Add receiveMulticast, receiveBroadcast, receiveSecureUnicast
receiveSecureMulticast method.
MomObject,
MessageHandler,
MulticastHandler,
BroadcastHandler,
SecureUnicastHandler,
SecureMulticastHandler,
Serialized Form| Field Summary | |
Vector |
broadcast_queue
Message queue for broadcast conversation. |
Vector |
multicast_queue
Message queue for multicast conversation. |
Vector |
secure_multicast_queue
Message queue for secured multicast conversation. |
| Fields inherited from class ksu.cis.mom.MomObject |
broadcast_address, broadcast_port, group, multicast_port, name, parent, port, secure_multicast_port, secure_unicast_port |
| Constructor Summary | |
protected |
Agent()
Default constructor. |
|
Agent(String name,
int port)
Constructor for using only unicast conversation. |
|
Agent(String name,
int unicast_port,
int[] multicast_port,
int broadcast_port,
int secure_unicast_port,
int[] secure_multicast_port)
Constructor for using any or all of five different conversations. |
| Method Summary | |
void |
receiveBroadcastConversation(DatagramSocket bSocket,
Message m,
Vector broadcast_queue)
Receive message method for the broadcast conversation. |
abstract void |
receiveMessage(Socket server,
ObjectInputStream input,
ObjectOutputStream output)
Receive message method for the unicast conversation. |
void |
receiveMulticastConversation(MulticastSocket mSocket,
Message m,
Vector multicast_queue)
Receive message method for the multicast conversation. |
void |
receiveMulticastJoin(Message m)
Receive multicast join message method for the multicast conversation. |
void |
receiveMulticastLeave(Message m)
Receive multicast leave message method for the multicast conversation. |
void |
receiveSecureMulticastConversation(MulticastSocket mSocket,
Message m,
Vector multicast_queue,
Key k,
String algorithm)
Receive message method for the secured multicast conversation. |
void |
receiveSecureUnicastConversation(SSLSocket server,
ObjectInputStream input,
ObjectOutputStream output)
Receive message method for the secured unicast conversation. |
abstract void |
run()
An agent must be runnable as a separate thread, and each agent must implement this method. |
void |
sendInternal(Message m)
Method for sending message between components within an agent. |
void |
write(String s)
Method for printout a String information on terminal screen. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
public Vector broadcast_queue
public Vector multicast_queue
public Vector secure_multicast_queue
| Constructor Detail |
protected Agent()
public Agent(String name,
int port)
name - - String name of the agentport - - Integer port of unicast
public Agent(String name,
int unicast_port,
int[] multicast_port,
int broadcast_port,
int secure_unicast_port,
int[] secure_multicast_port)
Constructor for using any or all of five different conversations. It
takes six argument, String of agent name, integer of port used in each
conversation. If any port is assigned to be less than one, then it indicates
the conversation is not going to be used.
Note that the arguments multicast_port and secure_multicast_port are an
array of integer type. It is because we allows agent to subscribe to
multiple groups. Thus, one port is used for one group. Assigning the first
element less than one indicates that the multicast will not be used.
name - - String name of the agentunicast_port - - Integer port number used for unicast conversationmulticast_port - - Array of integer port number used for multicast
conversationbroadcast_port - - Integer port number used for broadcast conversationsecure_unicast_port - - Integer port number used for secured unicast
conversationsecure_multicast_port - - Array of integer port number used for
secured multicast conversation| Method Detail |
public abstract void receiveMessage(Socket server,
ObjectInputStream input,
ObjectOutputStream output)
Receive message method for the unicast conversation.
Agent must implement this method and defines all possible of unicast
conversations here.
This method will be called by the MessageHandler when the agent
has received connection starting a new conversation.
server - - Socket for the unicast conversationinput - - ObjectInputStream for the unicast conversationoutput - - ObjectOutputStream for the unicast conversation
public void receiveBroadcastConversation(DatagramSocket bSocket,
Message m,
Vector broadcast_queue)
Receive message method for the broadcast conversation. Agent must
override this method and defines all possible of secured multicast
conversations here.
This is the method that will be called by the BroadcastHandler
when the agent has received connection starting a new broadcast
conversation.
bSocket - - datagram socket for handling broadcast conversationm - - message from other agentsbroadcast_queue - - message queue for broadcast conversation
public void receiveMulticastConversation(MulticastSocket mSocket,
Message m,
Vector multicast_queue)
Receive message method for the multicast conversation.
Agent must override this method and defines all possible of multicast
conversations here.
This is the method that will be called by the MulticastHandler
when the agent has received connection starting a new
multicast conversation.
mSocket - - multicast socket for handling multicast conversationm - - Message from other agentsmulticast_queue - - message queue for multicast conversationpublic void receiveMulticastJoin(Message m)
Receive multicast join message method for the multicast conversation.
Agent can override this method and performs some tasks. For example,
agent can keep track of other agents who join the group after itself.
This is the method that will be called by the MulticastHandler
when the agent has received join message from other agents.
public void receiveMulticastLeave(Message m)
Receive multicast leave message method for the multicast conversation.
Agent can override this method and performs some tasks. For example,
agent can keep track of other agents who leave.
This is the method that will be called by the MulticastHandler
when the agent has received leave message from other agents.
public void receiveSecureMulticastConversation(MulticastSocket mSocket,
Message m,
Vector multicast_queue,
Key k,
String algorithm)
Receive message method for the secured multicast conversation.
Agent must override this method and defines all possible of secured
multicast conversations here.
This is the method that will be called by the SecureMulticastHandler
when the agent has received connection starting a new secured
multicast conversation.
mSocket - - secured multicast socket for handling secured
multicast conversationm - - message from other agentsmulticast_queue - - message queue for secured multicast conversationk - - symmetric private key.algorithm - - symmetric key algorithm name
public void receiveSecureUnicastConversation(SSLSocket server,
ObjectInputStream input,
ObjectOutputStream output)
Receive message method for the secured unicast conversation.
Agent must override this method and defines all possible of secured unicast
conversations here.
This is the method that will be called by the SecureUnicastHandler
when the agent has received connection starting a new
secured unicast conversation.
server - - Secured socket for the secured unicast conversationinput - - ObjectInputStream for the secured unicast conversationoutput - - ObjectOutputStream for the secured unicast conversationpublic abstract void run()
An agent must be runnable as a separate thread, and each agent must implement this method.
run in interface Runnablepublic void sendInternal(Message m)
Method for sending message between components within an agent. This method simply broadcast message to all active components of the agent.
sendInternal in class MomObjectm - - message for internal conversation among the component.public void write(String s)
Method for printout a String information on terminal screen.
s - String to print out on the terminal screen.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||