use of org.cristalise.kernel.entity.CorbaServer in project kernel by cristal-ise.
the class Gateway method startServer.
/**
* Makes this process capable of creating and managing server entities. Runs the
* Creates the LookupManager, ProxyServer, initialises the ORB and CORBAServer
*/
public static void startServer() throws InvalidDataException, CannotManageException {
try {
// check top level directory contexts
if (mLookup instanceof LookupManager) {
mLookupManager = (LookupManager) mLookup;
mLookupManager.initializeDirectory();
} else {
throw new CannotManageException("Lookup implementation is not a LookupManager. Cannot write to directory");
}
// start entity proxy server
mProxyServer = new ProxyServer(mC2KProps.getProperty("ItemServer.name"));
// Init ORB - set various config
String serverName = mC2KProps.getProperty("ItemServer.name");
// TODO: externalize this (or replace corba completely)
if (serverName != null)
mC2KProps.put("com.sun.CORBA.ORBServerHost", serverName);
String serverPort = mC2KProps.getProperty("ItemServer.iiop", "1500");
mC2KProps.put("com.sun.CORBA.ORBServerPort", serverPort);
mC2KProps.put("com.sun.CORBA.POA.ORBServerId", "1");
mC2KProps.put("com.sun.CORBA.POA.ORBPersistentServerPort", serverPort);
// need to force UTF-8 in the Sun ORB
mC2KProps.put("com.sun.CORBA.codeset.charsets", "0x05010001, 0x00010109");
mC2KProps.put("com.sun.CORBA.codeset.wcharsets", "0x00010109, 0x05010001");
// Standard initialisation of the ORB
orbDestroyed = false;
mORB = org.omg.CORBA.ORB.init(new String[0], mC2KProps);
Logger.msg("Gateway.startServer() - ORB initialised. ORB class:'" + mORB.getClass().getName() + "'");
// start corba server components
mCorbaServer = new CorbaServer();
Logger.msg("Gateway.startServer() - Server '" + serverName + "' STARTED.");
} catch (Exception ex) {
Logger.error(ex);
Logger.die("Exception starting server components. Shutting down.");
}
}
use of org.cristalise.kernel.entity.CorbaServer in project kernel by cristal-ise.
the class CreateItemFromDescription method runActivityLogic.
/**
* Params:
* <ol>
* <li>Item name</li>
* <li>Domain context</li>
* <li>Description version to use(optional)</li>
* <li>Initial properties to set in the new Agent (optional)</li>
* </ol>
* @throws ObjectNotFoundException
* @throws InvalidDataException The input parameters were incorrect
* @throws ObjectAlreadyExistsException The Agent already exists
* @throws CannotManageException The Agent could not be created
* @throws ObjectCannotBeUpdated The addition of the new entries into the LookupManager failed
* @throws PersistencyException
*/
@Override
protected String runActivityLogic(AgentPath agent, ItemPath descItemPath, int transitionID, String requestData, Object locker) throws InvalidDataException, ObjectNotFoundException, ObjectAlreadyExistsException, CannotManageException, ObjectCannotBeUpdated, PersistencyException {
String[] input = getDataList(requestData);
String newName = input[0];
String domPath = input[1];
String descVer = input.length > 2 ? input[2] : "last";
PropertyArrayList initProps = input.length > 3 ? unmarshallInitProperties(input[3]) : new PropertyArrayList();
Logger.msg(1, "CreateItemFromDescription - name:" + newName);
// check if the path is already taken
DomainPath context = new DomainPath(new DomainPath(domPath), newName);
if (context.exists())
throw new ObjectAlreadyExistsException("The path " + context + " exists already.");
// generate new item path with random uuid
Logger.msg(6, "CreateItemFromDescription - Requesting new item path");
ItemPath newItemPath = new ItemPath();
// create the Item object
Logger.msg(3, "CreateItemFromDescription - Creating Item");
CorbaServer factory = Gateway.getCorbaServer();
if (factory == null)
throw new CannotManageException("This process cannot create new Items");
TraceableEntity newItem = factory.createItem(newItemPath);
Gateway.getLookupManager().add(newItemPath);
initialiseItem(newItem, agent, descItemPath, initProps, newName, descVer, context, newItemPath, locker);
return requestData;
}
use of org.cristalise.kernel.entity.CorbaServer in project kernel by cristal-ise.
the class CreateAgentFromDescription method createAgentAddRoles.
/**
* @param newAgentPath
* @param roles
* @return
* @throws CannotManageException
* @throws ObjectCannotBeUpdated
* @throws ObjectAlreadyExistsException
*/
protected ActiveEntity createAgentAddRoles(AgentPath newAgentPath, String[] roles, String pwd) throws CannotManageException, ObjectCannotBeUpdated, ObjectAlreadyExistsException {
// create the Agent object
Logger.msg(3, "CreateAgentFromDescription.createAgentAddRoles() - Creating Agent");
CorbaServer factory = Gateway.getCorbaServer();
if (factory == null)
throw new CannotManageException("This process cannot create new Items");
ActiveEntity newAgent = factory.createAgent(newAgentPath);
Gateway.getLookupManager().add(newAgentPath);
try {
if (StringUtils.isNotBlank(pwd))
Gateway.getLookupManager().setAgentPassword(newAgentPath, pwd);
for (String roleName : roles) {
RolePath role = Gateway.getLookupManager().getRolePath(roleName);
Gateway.getLookupManager().addRole(newAgentPath, role);
}
} catch (ObjectNotFoundException | NoSuchAlgorithmException e) {
Logger.error(e);
Gateway.getLookupManager().delete(newAgentPath);
}
return newAgent;
}
Aggregations