Search code examples
javaaclagents-jademulti-agent

Jade content manager calling default constructor upon message content extraction


I am sending a message containing a concept from my ontology, between two agents. The Concept object is encapsulated inside an action, and encoded like so:

SendAction sendObject = new SendAction ("action info", conceptObject);

Action action = new Action();
action.setAction(sendObject);
action.setActor(getAID());

getContentManager().fillContent(message, action);

However, upon decoding the message content in the recipient agent like so:

ContentElement content = getContentManager().extractContent(message);

The concept object's default constructor is called, thus a 'SendAction' containing an empty concept object is extracted rather than the object I encoded.

Interestingly, the 'Send Action' itself is encoded and decoded properly, as the "action info" string remains. Only the conceptObject is default.

Why is this happening, and how can I prevent it?


Solution

  • I have solved the problem, so thought I'd answer it for future users, especially because there isn't much on the subject available online.

    In this case, there were two problems:

    First, the use of a HashMap in the ontology's 'conceptObject'. Apparently Jade's content manager doesn't play well with the serialisation of HashMaps. I know this only from the combined experience of myself, my professors and classmates.

    Second, the setters on my 'conceptObject' were set to private. I wasn't aware at the time, but Jade's content manager requires public setters in order to handle serialisation and deserialisation of content objects.

    Note: It also requires a default constructor.