use of org.cristalise.kernel.lookup.LookupManager in project kernel by cristal-ise.
the class Bootstrap method checkAgent.
/**
* Checks for the existence of a agents so it can be used
*
* @param name
* @param pass
* @param rolePath
* @param uuid
* @return the Proxy representing the Agent
* @throws Exception
*/
private static AgentProxy checkAgent(String name, String pass, RolePath rolePath, String uuid) throws Exception {
Logger.msg(1, "Bootstrap.checkAgent() - Checking for existence of '" + name + "' agent.");
LookupManager lookup = Gateway.getLookupManager();
try {
AgentProxy agentProxy = Gateway.getProxyManager().getAgentProxy(lookup.getAgentPath(name));
systemAgents.put(name, agentProxy);
Logger.msg(3, "Bootstrap.checkAgent() - Agent '" + name + "' found.");
return agentProxy;
} catch (ObjectNotFoundException ex) {
}
Logger.msg("Bootstrap.checkAgent() - Agent '" + name + "' not found. Creating.");
try {
AgentPath agentPath = new AgentPath(new ItemPath(uuid), name);
Gateway.getCorbaServer().createAgent(agentPath);
lookup.add(agentPath);
if (StringUtils.isNotBlank(pass))
lookup.setAgentPassword(agentPath, pass);
// assign admin role
Logger.msg("Bootstrap.checkAgent() - Assigning role '" + rolePath.getName() + "'");
Gateway.getLookupManager().addRole(agentPath, rolePath);
Gateway.getStorage().put(agentPath, new Property(NAME, name, true), null);
Gateway.getStorage().put(agentPath, new Property(TYPE, "Agent", false), null);
AgentProxy agentProxy = Gateway.getProxyManager().getAgentProxy(agentPath);
// TODO: properly init agent here with wf, props and colls
// agentProxy.initialise(agentId, itemProps, workflow, colls);
systemAgents.put(name, agentProxy);
return agentProxy;
} catch (Exception ex) {
Logger.error("Unable to create '" + name + "' Agent.");
throw ex;
}
}
Aggregations