Discussion:
[jade-develop] Servlet to JADE: GatewayAgent and processCommand problem
sergi g
2008-04-25 20:48:14 UTC
Permalink
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
sergi g
2008-04-25 21:20:05 UTC
Permalink
I find the solution.

The problem was that i redefined the setup method.

My solution is call the setup method of the superclass in GatewayAgent

...

public void setup() {
super.setup();
// Comportamen que espera per la contesta
addBehaviour(new CyclicBehaviour(this) {
public void action() {
...


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
zibrahim
2014-07-21 16:22:31 UTC
Permalink
Did you manage to solve the problem? I have the same issue and was hoping
someone found a solution. Thank you in advance.



--
View this message in context: http://jade.17737.x6.nabble.com/Servlet-to-JADE-GatewayAgent-and-processCommand-problem-tp4703451p5002652.html
Sent from the JADE - Dev mailing list archive at Nabble.com.
Caire Giovanni
2014-07-24 21:09:18 UTC
Permalink
Hi,

Communicating from a Java program (e.g. a Servlet) to a JADE-based system is very easy:
1) Just once when your program starts, initialize the JadeGateway with the host and port where the Main Container of the JADE-based system is running
Properties pp = new Properties();
pp.setProperty(Profile.HOST, "main container host");
pp.setPort(Profile.PORT, "main container port); // Normally 1099
JadeGateway.init(null, pp);

2) When you need to interact
MyInteractionBehaviour b = new MyInteractionBehaviour();
jadeGateway.execute(b);
// At this point b has been fully executed
// Get information you need from b

Look at the examples\inprocess\JadeGatewayExample class included in the JADE examples distribution for an example.

Bye,

Giovanni


-----Messaggio originale-----
Da: jade-develop [mailto:jade-develop-bounces at avalon.tilab.com] Per conto di zibrahim
Inviato: lunedì 21 luglio 2014 18:23
A: jade-develop at avalon.tilab.com
Oggetto: Re: [jade-develop] Servlet to JADE: GatewayAgent and processCommand problem

Did you manage to solve the problem? I have the same issue and was hoping someone found a solution. Thank you in advance.



--
View this message in context: http://jade.17737.x6.nabble.com/Servlet-to-JADE-GatewayAgent-and-processCommand-problem-tp4703451p5002652.html
Sent from the JADE - Dev mailing list archive at Nabble.com.
_______________________________________________
jade-develop mailing list
jade-develop at avalon.tilab.com
http://jade.tilab.com/mailman/listinfo/jade-develop
UNSUBSCRIBE INSTRUCTIONS AT
http://jade.tilab.com/community-mailinglist.htm

Loading...