now = reply.now;
setStamp(reply.stamp);
// creates all agents
ByteArrayInputStream bis = new ByteArrayInputStream(reply.agents);
ObjectInputStream ois = new ObjectInputStream(bis);
try {
AgentId id = null;
Agent agent = null;
AgentIdStamp.stamp = (AgentIdStamp) ois.readObject();
while (true) {
id = (AgentId) ois.readObject();
agent = (Agent) ois.readObject();
agent.id = id;
agent.deployed = true;
// If there is a bag associated with this agent don't initialize it!
if (agent instanceof BagSerializer) {
((BagSerializer) agent).readBag(ois);
} else {
agent.agentInitialize(false);
}
createAgent(agent);
}
} catch (EOFException exc) {
logmon.log(BasicLevel.WARN,
AgentServer.getName() + " setState()", exc);
} catch (Exception exc) {
logmon.log(BasicLevel.ERROR,
AgentServer.getName() + " setState()", exc);
} finally {
try {
ois.close();
} catch (Exception exc) {}
}
// inserts all pending messages
bis = new ByteArrayInputStream(reply.messages);
ois = new ObjectInputStream(bis);
try {
qinFromExt = (Vector) ois.readObject();
if (logmon.isLoggable(BasicLevel.DEBUG)) {
for (int i=0; i<qinFromExt.size(); i++) {
Message msg = (Message) qinFromExt.elementAt(i);
logmon.log(BasicLevel.DEBUG,
AgentServer.getName() + " setState() -> " + msg);
}
}
postFromExt();
} finally {
try {
ois.close();
} catch (Exception exc) {}
}
}