All Packages Class Hierarchy This Package Previous Next Index
Class BaseLayer.BAgentAction
Abstract.AgentAction
|
+----BaseLayer.BAgentAction
- public abstract class BAgentAction
- extends AgentAction
Implementation of AgentAction. This class use BServThread,
BRecvThread,BSecurity,BMessageBuffer,BConnectionTable,BAddressTable
as its first implementation from the abstract classes.
However this class is still an abstract class for you to fill in
processMessage(String,Object) and Act(Object) methods.
You will need to subclass this class to act according to the
message received. Since JATLite assumes to use MessageBuffer,
the ReceiverThread will receive message and add it to MessageBuffer.
AgentAction will check the received message and retrieve it
whenever available.
- See Also:
- AgentAction
-
BAgentAction()
- Default constructor.
-
BAgentAction(String)
- Constructor with agent name.
-
BAgentAction(String, MessageBuffer, AddressTable, ConnectionTable, Security)
- Constructor
-
BAgentAction(String, MessageBuffer, AddressTable, ConnectionTable, Security, ThreadGroup)
- Constructor.
-
BAgentAction(ThreadGroup, String)
- Constructor with agent name and thread group.
-
Act(Object)
- Actual Action method.
-
broadCast(String)
- Broad cast to all the running connecitons
-
createReceiverThread(String, int)
- Create receiver thread with AgentAction's name.
-
createReceiverThread(String, String, int)
- Create client receiver thread using name of the agent where you want to initiate
Connection.
-
createServerThread(String, int)
- Create BServerThread using name of the agent.
-
endAction()
- Clean up all the living receiver thread.
-
processMessage(String, Object)
- Abstract method to process message given any other objects
This method is a data exchange between threads or between AgentAction and GUI.
-
run()
- Override run() method as you need.
-
sendMessage(String, String)
- Send Message by specifying receiver.
BAgentAction
public BAgentAction()
- Default constructor. You should perform member-wise initialization for all data
members - setAddressTable(AddressTable),setConnectionTable(ConnectionTable),
setDurationTime(int),setEndWith(char), setMessageQueue(MessageBuffer),
setSecurity(Security).
BAgentAction
public BAgentAction(String id)
- Constructor with agent name. You should perform member-wise initialization for all data
members - setAddressTable(AddressTable),setConnectionTable(ConnectionTable),
setDurationTime(int),setEndWith(char), setMessageQueue(MessageBuffer),
setSecurity(Security).
- Parameters:
- id - AgentAction(Thread) name
BAgentAction
public BAgentAction(ThreadGroup tg,
String id)
- Constructor with agent name and thread group. You should perform member-wise initialization for all data
members - setAddressTable(AddressTable),setConnectionTable(ConnectionTable),
setDurationTime(int),setEndWith(char), setMessageQueue(MessageBuffer),
setSecurity(Security).
- Parameters:
- tg - Thread group
- id - AgentAction(Thread) name
BAgentAction
public BAgentAction(String id,
MessageBuffer queue,
AddressTable addresses,
ConnectionTable connections,
Security security)
- Constructor
- Parameters:
- id - agent(my) name
- queue - MessageBuffer
- addresses - AddressTable
- connections - ConnectionTable
- security - Security to be checked and update connection table
BAgentAction
public BAgentAction(String id,
MessageBuffer queue,
AddressTable addresses,
ConnectionTable connections,
Security security,
ThreadGroup tg)
- Constructor. Thread group should passed if you want to access to the ReceiverThread, will
be initiated by this action.
- Parameters:
- id - agent(my) name
- queue - MessageBuffer
- addresses - AddressTable
- connections - ConnectionTable
- security - Security to be checked and update connection table
- tg - Thread group, for the receiver thread, initiated by me.
createServerThread
public ServerThread createServerThread(String id,
int priority)
- Create BServerThread using name of the agent. Endwith character and duration time
will be set to those of the current AgentAction's data values.
Override this method if your connection type is different.
- Parameters:
- id - ServerThread name
- priority - Server thread priority
- Returns:
- ServerThread, generated. Null if exception occurs.
createReceiverThread
public synchronized ReceiverThread createReceiverThread(String serverid,
String myid,
int priority) throws ConnectionException
- Create client receiver thread using name of the agent where you want to initiate
Connection.
Override this method if your connection type is different.
- Parameters:
- serverid - agent name. This name is not my name. The name of the other
agent you want to connect
- myid - My (agent)name
- priority - Receiver thread priority
- Returns:
- ReceiverThread. null if error occurs.
- Throws: ConnectionException
- if security check fails
createReceiverThread
public ReceiverThread createReceiverThread(String serverid,
int priority) throws ConnectionException
- Create receiver thread with AgentAction's name. When you use the method, the
AgentAction's thread name(the same as my name) should be set. If not, the receiver
thread name will be set as system selected.
- Parameters:
- serverid - Agent name to whom I want to connect
- priority - Priority of the ReceiverThread
- Returns:
- ReceiverThread, generated. Null if exception occurs
- Throws: ConnectionException
- if security check fails
sendMessage
public void sendMessage(String receiver,
String msg) throws ConnectionException
- Send Message by specifying receiver. It first check whether the receiver connection
is living. If dead, it try to initiate to the receiver, by retrieving the receiver
address from the AddressTable.
- Parameters:
- receiver - Receiver Agent
- msg - Message to be sent
- Throws: ConnectionException
- If IO error or fail to reconnect, ConectionException will be thrown.
broadCast
public void broadCast(String msg) throws ConnectionException
- Broad cast to all the running connecitons
- Parameters:
- msg - Message to be sent all the living connections
processMessage
public abstract void processMessage(String command,
Object obj)
- Abstract method to process message given any other objects
This method is a data exchange between threads or between AgentAction and GUI.
- Parameters:
- command - Command to be executed
- obj - Reference object
Act
protected abstract boolean Act(Object o)
- Actual Action method. Note that the parameter is object, which should
be instantiated by casting according to the parameter type
- Parameters:
- o - Message object,received from the message queue. You should cast the
message from the object.
run
public void run()
- Override run() method as you need. You can check the MessageBuffer
and invoke Act(object) if the MessageBuffer is not empty
- Overrides:
- run in class AgentAction
endAction
public void endAction()
- Clean up all the living receiver thread. The living thread will send disconnect
message through the connection.
- Overrides:
- endAction in class AgentAction
All Packages Class Hierarchy This Package Previous Next Index