use of org.cristalise.kernel.lookup.LookupManager in project kernel by cristal-ise.
the class Bootstrap method verifyPathAndModuleProperty.
/**
* Verify module property and location
*
* @param ns
* @param itemType
* @param itemName
* @param itemPath
* @param modDomPath
* @param path
* @return the ItemProxy either create or initialised for existing
* @throws Exception
*/
private static ItemProxy verifyPathAndModuleProperty(String ns, String itemType, String itemName, ItemPath itemPath, DomainPath modDomPath, DomainPath path) throws Exception {
LookupManager lookupManager = Gateway.getLookupManager();
ItemProxy thisProxy = Gateway.getProxyManager().getProxy(path);
if (itemPath != null && !path.getItemPath().equals(itemPath)) {
Logger.warning("Resource " + itemType + "/" + itemName + " should have path " + itemPath + " but was found with path " + path.getItemPath());
itemPath = path.getItemPath();
}
if (itemPath == null)
itemPath = path.getItemPath();
String moduleName = (ns == null ? "kernel" : ns);
String itemModule;
try {
itemModule = thisProxy.getProperty("Module");
if (itemModule != null && !itemModule.equals("") && !itemModule.equals("null") && !moduleName.equals(itemModule)) {
String error = "Module clash! Resource '" + itemName + "' included in module " + moduleName + " but is assigned to '" + itemModule + "'.";
Logger.error(error);
throw new InvalidDataException(error);
}
} catch (ObjectNotFoundException ex) {
itemModule = "";
}
if (!modDomPath.equals(path)) {
// move item to module subtree
Logger.msg("Module item " + itemName + " found with path " + path.toString() + ". Moving to " + modDomPath.toString());
modDomPath.setItemPath(itemPath);
if (!modDomPath.exists())
lookupManager.add(modDomPath);
lookupManager.delete(path);
}
return thisProxy;
}
use of org.cristalise.kernel.lookup.LookupManager in project kernel by cristal-ise.
the class Bootstrap method createResourceItem.
/**
* @param impHandler
* @param itemName
* @param ns
* @param itemPath
* @return the ItemProxy representing the newly create Item
* @throws Exception
*/
private static ItemProxy createResourceItem(ResourceImportHandler impHandler, String itemName, String ns, ItemPath itemPath) throws Exception {
// create props
PropertyDescriptionList pdList = impHandler.getPropDesc();
PropertyArrayList props = new PropertyArrayList();
LookupManager lookupManager = Gateway.getLookupManager();
for (int i = 0; i < pdList.list.size(); i++) {
PropertyDescription pd = pdList.list.get(i);
String propName = pd.getName();
String propVal = pd.getDefaultValue();
if (propName.equals(NAME.toString()))
propVal = itemName;
else if (propName.equals(MODULE.toString()))
propVal = (ns == null) ? "kernel" : ns;
props.list.add(new Property(propName, propVal, pd.getIsMutable()));
}
CompositeActivity ca = new CompositeActivity();
try {
ca = (CompositeActivity) ((CompositeActivityDef) LocalObjectLoader.getActDef(impHandler.getWorkflowName(), 0)).instantiate();
} catch (ObjectNotFoundException ex) {
Logger.error(ex);
Logger.error("Module resource workflow " + impHandler.getWorkflowName() + " not found. Using empty.");
}
Gateway.getCorbaServer().createItem(itemPath);
lookupManager.add(itemPath);
DomainPath newDomPath = impHandler.getPath(itemName, ns);
newDomPath.setItemPath(itemPath);
lookupManager.add(newDomPath);
ItemProxy newItemProxy = Gateway.getProxyManager().getProxy(itemPath);
newItemProxy.initialise(systemAgents.get("system").getPath(), props, ca, null);
return newItemProxy;
}
use of org.cristalise.kernel.lookup.LookupManager 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.lookup.LookupManager in project kernel by cristal-ise.
the class RemoveRole method runActivityLogic.
@Override
protected String runActivityLogic(AgentPath agent, ItemPath item, int transitionID, String requestData, Object locker) throws InvalidDataException, CannotManageException, ObjectNotFoundException, ObjectCannotBeUpdated {
String[] params = getDataList(requestData);
Logger.msg(3, "RemoveRole: called by " + agent + " on " + item + " with parameters " + Arrays.toString(params));
if (params.length != 1)
throw new InvalidDataException("RemoveRole must have one paramater:" + Arrays.toString(params));
LookupManager lookup = Gateway.getLookupManager();
RolePath thisRole = lookup.getRolePath(params[0]);
AgentPath[] agents = Gateway.getLookup().getAgents(thisRole);
if (agents.length > 0)
throw new ObjectCannotBeUpdated("Cannot remove role as " + agents.length + " other agents still hold it.");
lookup.delete(thisRole);
return requestData;
}
use of org.cristalise.kernel.lookup.LookupManager in project kernel by cristal-ise.
the class Bootstrap method createServerItem.
public static void createServerItem() throws Exception {
LookupManager lookupManager = Gateway.getLookupManager();
String serverName = Gateway.getProperties().getString("ItemServer.name", InetAddress.getLocalHost().getHostName());
thisServerPath = new DomainPath("/servers/" + serverName);
ItemPath serverItem;
try {
serverItem = thisServerPath.getItemPath();
} catch (ObjectNotFoundException ex) {
Logger.msg("Creating server item " + thisServerPath);
serverItem = new ItemPath();
Gateway.getCorbaServer().createItem(serverItem);
lookupManager.add(serverItem);
thisServerPath.setItemPath(serverItem);
lookupManager.add(thisServerPath);
}
int proxyPort = Gateway.getProperties().getInt("ItemServer.Proxy.port", 1553);
Gateway.getStorage().put(serverItem, new Property(NAME, serverName, false), null);
Gateway.getStorage().put(serverItem, new Property(TYPE, "Server", false), null);
Gateway.getStorage().put(serverItem, new Property(KERNEL_VERSION, Gateway.getKernelVersion(), true), null);
Gateway.getStorage().put(serverItem, new Property("ProxyPort", String.valueOf(proxyPort), false), null);
Gateway.getStorage().put(serverItem, new Property("ConsolePort", String.valueOf(Logger.getConsolePort()), true), null);
Gateway.getProxyManager().connectToProxyServer(serverName, proxyPort);
}
Aggregations