use of com.cosylab.CDB.DAL in project ACS by ACS-Community.
the class BrowserJNDIContextFactory method getInitialContext.
/**
* An initial context factory (JNDI_ContextFactory) must implement the InitialContextFactory interface, which
* provides a method for creating instances of initial context that implement the Context interface
*/
public Context getInitialContext(Hashtable environment) throws NamingException {
String strIOR = (String) environment.get(Context.PROVIDER_URL);
if (strIOR == null)
throw new NamingException("There is no " + Context.PROVIDER_URL + " property set!");
// try to get the server
// create and initialize the ORB
String[] argv = {};
ORB orb = ORB.init(argv, null);
DAL dal = DALHelper.narrow(orb.string_to_object(strIOR));
BrowserJNDIContext.setOrb(orb);
BrowserJNDIContext.setDal(dal);
String rootElements = dal.list_nodes("");
//Returns the first level of the CDBTree (possible: "alma MACI schema CVS")
try {
//remove 'CVS' and 'schema' from Root
rootElements = rootElements.replaceAll("CVS", "");
rootElements = rootElements.replaceAll("schemas", "");
} catch (PatternSyntaxException e) {
} catch (NullPointerException e) {
}
Logger logger = ClientLogManager.getAcsLogManager().getLoggerForApplication("cdbBrowser", false);
//JNDI_Context implements Context
return new BrowserJNDIContext("", rootElements, logger);
}
use of com.cosylab.CDB.DAL in project ACS by ACS-Community.
the class CDBAccess method queryNSForDALReference.
private DAL queryNSForDALReference() {
try {
org.omg.CORBA.Object objRef = orb.resolve_initial_references("NameService");
NamingContext ncRef = NamingContextHelper.narrow(objRef);
NameComponent[] path = { new NameComponent("CDB", "") };
org.omg.CORBA.Object objectReference = ncRef.resolve(path);
DAL dalRef = DALHelper.narrow(objectReference);
return dalRef;
} catch (Throwable th) {
throw new RuntimeException("Failed to get DAL object from the naming service.", th);
}
}
use of com.cosylab.CDB.DAL in project ACS by ACS-Community.
the class ACSAlarmSystemInterfaceFactory method init.
/**
* Init the static variables of the class
* This method has to be called before executing any other
* method.
*
* @param logger The logger
* @param dal The DAL to init the AS with CERN or ACS implementation
* @throws AcsJContainerServicesEx
*/
public static void init(ContainerServicesBase containerServices) throws AcsJContainerServicesEx {
if (containerServices == null) {
throw new AcsJContainerServicesEx(new Exception("Invalid null ContainerServicesBase"));
}
ACSAlarmSystemInterfaceFactory.containerServices = containerServices;
ACSAlarmSystemInterfaceFactory.logger = containerServices.getLogger();
DAL dal = containerServices.getCDB();
if (logger == null || dal == null) {
throw new IllegalArgumentException("Invalid DAL or Logger from ContainerServicesBase");
}
alarmSourceFactory = new AlarmSourceFactory(containerServices);
useACSAlarmSystem = retrieveImplementationType(dal);
if (logger != null) {
if (useACSAlarmSystem) {
logger.log(AcsLogLevel.DEBUG, "Alarm system type: ACS");
} else {
logger.log(AcsLogLevel.DEBUG, "Alarm system type: CERN");
try {
initCmwMom();
} catch (Throwable t) {
throw new AcsJContainerServicesEx(new Exception("Error initing cmw-mom", t));
}
}
}
}
Aggregations