我有两个jade代理,我想从一个代理向另一个代理发送一个对象,我使用了setContentObject()
和getContentObject()
方法,第二个代理收到对象时工作正常,但我可以似乎找不到获取对象变量的方法,例如:
public class Person implements Serializable{
private String firstName;
private String lastName;
public String getFirstName(){
return firstName;
}
public void setFirstName(String fName){
this.firstName=fName;
}
public String getLastName(){
return lastName;
}
public void setFirstName(String lName){
this.lastName=lName;
}
}
剂1:
public class Agent1 extends Agent{
@Override
protected void setup() {
addBehaviour(new OneShotBehaviour(this) {
@Override
public void action(){
ACLMessage aclmsg = new ACLMessage(ACLMessage.REQUEST);
aclmsg.addReceiver(new AID("Agent2", AID.ISLOCALNAME));
aclmsg.setContentObject(Person);
send(aclmsg);
});
}
}
}
Agent2
public class Agent2 extends Agent{
@Override
protected void setup() {
addBehaviour(new CyclicBehaviour(this) {
@Override
public void action(){
ACLMessage msg = receive();
if(msg!=null){
//Here i want to get the first name of the object Person
}
});
}
}
}
所以我的问题是如何检索发送对象Person的firstName?