sergi g
2008-04-25 20:48:14 UTC
I've a problem with the tutorial of Viktor Kelemen. processCommand Method never is invoked.
Javadoc says that execute requires a command object, how i can do it?
I've implemented the same example of the tutorial, but i don't know how use the processCommand method of
MyGatewayAgent (a subclass of GatewayAgent).
My code is
servlet.
JadeGateway.init("gateway.MyGateWayAgent",null);
BlackBoardBean board = new BlackBoardBean();
board.setReceptor("pong");
board.setMissatge("Hello");
try {
JadeGateway.execute(board);
}
catch(Exception e) {
e.printStackTrace();
}
BlackBoard class.
public class BlackBoardBean implements java.io.Serializable {
private String missatge = new String("");
private String receptor = new String("");
public String getMissatge() {
return missatge;
}
public void setMissatge(String str) {
missatge = str;
}
public String getReceptor() {
return receptor;
}
public void setReceptor(String receptor) {
this.receptor = receptor;
}
}
GateWayAgent class. NEVER ENTER IN PROCESSCOMMAND()
public class MyGateWayAgent extends GatewayAgent {
BlackBoardBean board = null;
protected void processCommand(java.lang.Object obj) {
System.out.println("process command");
if (obj instanceof BlackBoardBean) {
System.out.println("send message ACL to PONG");
board = (BlackBoardBean) obj;
ACLMessage msg = new ACLMessage(ACLMessage.REQUEST);
msg.addReceiver(new AID(board.getReceptor(), AID.ISLOCALNAME));
msg.setContent(board.getMissatge());
send(msg);
}
}
public void setup() {
addBehaviour(new CyclicBehaviour(this) {
public void action() {
ACLMessage msg = receive();
if ((msg != null) && (board != null)) {
board.setMissatge(msg.getContent());
releaseCommand(board);
} else
block();
}
});
}
}
Thanks,
Sergi
_________________________________________________________________
Invite your mail contacts to join your friends list with Windows Live Spaces. It's easy!
http://spaces.live.com/spacesapi.aspx?wx_action=create&wx_url=/friends.aspx&mkt=en-us
Javadoc says that execute requires a command object, how i can do it?
I've implemented the same example of the tutorial, but i don't know how use the processCommand method of
MyGatewayAgent (a subclass of GatewayAgent).
My code is
servlet.
JadeGateway.init("gateway.MyGateWayAgent",null);
BlackBoardBean board = new BlackBoardBean();
board.setReceptor("pong");
board.setMissatge("Hello");
try {
JadeGateway.execute(board);
}
catch(Exception e) {
e.printStackTrace();
}
BlackBoard class.
public class BlackBoardBean implements java.io.Serializable {
private String missatge = new String("");
private String receptor = new String("");
public String getMissatge() {
return missatge;
}
public void setMissatge(String str) {
missatge = str;
}
public String getReceptor() {
return receptor;
}
public void setReceptor(String receptor) {
this.receptor = receptor;
}
}
GateWayAgent class. NEVER ENTER IN PROCESSCOMMAND()
public class MyGateWayAgent extends GatewayAgent {
BlackBoardBean board = null;
protected void processCommand(java.lang.Object obj) {
System.out.println("process command");
if (obj instanceof BlackBoardBean) {
System.out.println("send message ACL to PONG");
board = (BlackBoardBean) obj;
ACLMessage msg = new ACLMessage(ACLMessage.REQUEST);
msg.addReceiver(new AID(board.getReceptor(), AID.ISLOCALNAME));
msg.setContent(board.getMissatge());
send(msg);
}
}
public void setup() {
addBehaviour(new CyclicBehaviour(this) {
public void action() {
ACLMessage msg = receive();
if ((msg != null) && (board != null)) {
board.setMissatge(msg.getContent());
releaseCommand(board);
} else
block();
}
});
}
}
Thanks,
Sergi
_________________________________________________________________
Invite your mail contacts to join your friends list with Windows Live Spaces. It's easy!
http://spaces.live.com/spacesapi.aspx?wx_action=create&wx_url=/friends.aspx&mkt=en-us