在代理之间发送对象

Send objects between agents

我有两个 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);
          });
        }
    }
}

代理2

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 的名字?

((Person)msg.getContentObject()).getFirstName()

阅读this