|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--elge.agent.Agency
Agency is a class for making the comunication between agents. One possible thing is to give every agent every message that anyone sends. But then the agent themselfs have to realize the type and destination of the message. So an register system is here explaind where every agent can register what he wants to hear, and when that event occures, the agent method will be invoked.
Agency should not exist standalone, so there should always some agent, that has the agency as main agency for comunication.
The idea is, that every agent has it's own agency (if needed) for comunication with his subagents and every agent uses an agency from super agent - the parent agent. The parent agent should for now, not be diferenced from his subagents. So the comunications is only between all subagents and their parent. If needed, the parent can move the comunication to the top or the subagents should move the comunication down.
Field Summary | |
static String |
METHOD_PREFIX
Used to determine, what is the prefix for the methods for comunication. |
protected Hashtable |
ragents
hashtable of registred agents. |
Constructor Summary | |
Agency()
Creates a new instance of Agency. |
Method Summary | |
protected Vector |
getAgentsForMessage(String message)
Internal method. |
Situation |
getAnswer(Agent agent,
Agent callagent,
String message,
Object params)
Like getAnswer but tries to ask a specific agent agent .
|
Situation |
getAnswer(Agent agent,
String message,
Object params)
Method searches agents for registred agents wich message message
and asks one of them for the answer. |
Vector |
getAnswers(Agent agent,
String message,
Object params)
Like simple getAnswer but gets more results. |
void |
register(Agent agent)
This method should scan the agent for getAnswer_ Methods and register it. |
void |
registermethod(Agent agent,
String message)
Register the agent 'agent' for the message 'message' |
void |
unregister(Agent agent)
Unregister the agent for all messages. |
void |
unregister(Agent agent,
String message)
Remove the agent from ragents for comunication message 'message'. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final String METHOD_PREFIX
getAnswer_
followed
with the message ident string.
protected Hashtable ragents
Constructor Detail |
public Agency()
Method Detail |
public Vector getAnswers(Agent agent, String message, Object params)
getAnswer
but gets more results.
agent
- agent which is asking.message
- message ident string.params
- any parameters that the message requires.
Situation
s from agents that could answer the message. It could be empty.getAnswer(elge.agent.Agent, java.lang.String, java.lang.Object)
public Situation getAnswer(Agent agent, String message, Object params)
message
and asks one of them for the answer.
agent
- agent shich is asking.message
- message ident stringparams
- any parameters
public Situation getAnswer(Agent agent, Agent callagent, String message, Object params)
getAnswer
but tries to ask a specific agent agent
.
If he knows the message type, the asnwer should be available.
agent
- agent to ask the message.callagent
- agent which is asking.message
- message ident string.params
- any parameters
agent
or null if the agent does not know the message.public void register(Agent agent)
agent
- The agent we want to register.public void registermethod(Agent agent, String message)
agent
- the agent we want to registermessage
- the name of comunication message we want to register the agent to ragents.public void unregister(Agent agent)
agent
- the agent we want to unregister from ragents.public void unregister(Agent agent, String message)
agent
- The agent we try to unregistermessage
- for what method wi try to unregister the agent.protected Vector getAgentsForMessage(String message)
message
- message ident string.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |