String codeContainerName = getClassSite(agent);
myContainer.releaseLocalAgent(agentID);
//Check if the code is in the same container or in a remote one.
AgentManagementService amSrv = (AgentManagementService) myFinder.findService(AgentManagementService.NAME);
CodeLocator codeLocator = amSrv.getCodeLocator();
if (codeContainerName == null) codeContainerName = containerName;
if (containerName.equals(codeContainerName)) {
if (codeLocator.isRegistered(agentID)) {
if(myLogger.isLoggable(Logger.FINE)) {
myLogger.log(Logger.FINE," adding clone " + newName + " to code locator.");
}
codeLocator.cloneAgent(agentID, new AID(newName,AID.ISLOCALNAME));
}
} else {
//Send a CLONE_CODE_LOCATOR_ENTRY command to the container with the agent code.
AgentMobilitySlice codeSlice = (AgentMobilitySlice) getSlice(codeContainerName);
try {