throw new ServiceException("Problem in contacting the IMTP Manager", imtpe);
}
}
public VerticalCommand serve(HorizontalCommand cmd) {
VerticalCommand result = null;
try {
String cmdName = cmd.getName();
Object[] params = cmd.getParams();
if(cmdName.equals(AgentMobilitySlice.H_CREATEAGENT)) {
AID agentID = (AID)params[0];
byte[] serializedInstance = (byte[])params[1];
String classSiteName = (String)params[2];
boolean isCloned = ((Boolean)params[3]).booleanValue();
boolean startIt = ((Boolean)params[4]).booleanValue();
createAgent(agentID, serializedInstance, classSiteName, isCloned, startIt);
}
else if(cmdName.equals(AgentMobilitySlice.H_FETCHCLASSFILE)) {
String className = (String)params[0];
String agentName = (String)params[1];
cmd.setReturnValue(fetchClassFile(className, agentName));
}
else if(cmdName.equals(AgentMobilitySlice.H_MOVEAGENT)) {
GenericCommand gCmd = new GenericCommand(AgentMobilityHelper.REQUEST_MOVE, AgentMobilitySlice.NAME, null);
AID agentID = (AID)params[0];
Location where = (Location)params[1];
gCmd.addParam(agentID);
gCmd.addParam(where);
result = gCmd;
}
else if(cmdName.equals(AgentMobilitySlice.H_COPYAGENT)) {
GenericCommand gCmd = new GenericCommand(AgentMobilityHelper.REQUEST_CLONE, AgentMobilitySlice.NAME, null);
AID agentID = (AID)params[0];
Location where = (Location)params[1];
String newName = (String)params[2];
gCmd.addParam(agentID);
gCmd.addParam(where);
gCmd.addParam(newName);
result = gCmd;
}
else if(cmdName.equals(AgentMobilitySlice.H_PREPARE)) {
cmd.setReturnValue(new Boolean(prepare()));
}
else if(cmdName.equals(AgentMobilitySlice.H_TRANSFERIDENTITY)) {
AID agentID = (AID)params[0];
Location src = (Location)params[1];
Location dest = (Location)params[2];
cmd.setReturnValue(new Boolean(transferIdentity(agentID, src, dest)));
}
else if(cmdName.equals(AgentMobilitySlice.H_HANDLETRANSFERRESULT)) {
AID agentID = (AID)params[0];
boolean transferResult = ((Boolean)params[1]).booleanValue();
List messages = (List)params[2];
handleTransferResult(agentID, transferResult, messages);
}
else if(cmdName.equals(AgentMobilitySlice.H_CLONEDAGENT)) {
GenericCommand gCmd = new GenericCommand(AgentMobilityHelper.INFORM_CLONED, AgentMobilitySlice.NAME, null);
AID agentID = (AID)params[0];
ContainerID cid = (ContainerID)params[1];
Credentials creds = (Credentials)params[2];
gCmd.addParam(agentID);
gCmd.addParam(cid);
gCmd.addParam(creds);
result = gCmd;
}
//#J2ME_EXCLUDE_BEGIN
else if(cmdName.equals(AgentMobilitySlice.H_CLONECODELOCATORENTRY)) {
AID oldAgentID = (AID)params[0];
AID newAgentID = (AID)params[1];
handleCloneCodeLocatorEntry(oldAgentID, newAgentID);
}
else if(cmdName.equals(AgentMobilitySlice.H_REMOVECODELOCATORENTRY)) {
AID agentID = (AID)params[0];
handleRemoveCodeLocatorEntry(agentID);
}
//#J2ME_EXCLUDE_END
}
catch(Throwable t) {
cmd.setReturnValue(t);
if(result != null) {
result.setReturnValue(t);
}
}
return result;
}