use of com.cosylab.CDB.DAL in project ACS by ACS-Community.
the class AlarmSystemCorbaServer method getAlarmSystemType.
/**
* Query the CDB to understand which one between ACS and CERN implementation
* has to be used
*
* @return <code>true</code> if ACS implementation must be used
* @throws Exception In case of error
*/
private boolean getAlarmSystemType() throws Exception {
DAL dal = getCDB();
String str = dal.get_DAO("Alarms/Administrative/AlarmSystemConfiguration");
StringReader strReader = new StringReader(str);
AlarmSystemConfiguration configuration;
try {
configuration = AlarmSystemConfiguration.unmarshalAlarmSystemConfiguration(strReader);
} catch (Throwable t) {
m_logger.log(AcsLogLevel.ERROR, "Error parsing alarm configuration: using ACS alarm implementation");
return true;
}
for (int propNum = 0; propNum < configuration.getConfigurationPropertyCount(); propNum++) {
ConfigurationProperty property = configuration.getConfigurationProperty(propNum);
if (property.getName().equalsIgnoreCase("Implementation")) {
if (property.getContent().equalsIgnoreCase("CERN")) {
return false;
}
}
}
return true;
}
use of com.cosylab.CDB.DAL in project ACS by ACS-Community.
the class CharacteristicComponentImpl method initialize.
/**
* @see alma.acs.component.ComponentLifecycle#initialize(alma.acs.container.ContainerServices)
*/
public void initialize(ContainerServices containerServices) throws ComponentLifecycleException {
super.initialize(containerServices);
try {
DAL dal = m_containerServices.getCDB();
// create characteristic model
// TODO think of error handling; why creating model per instance...
characteristicModelImpl = new CharacteristicModelImpl("alma/" + m_instanceName, dal);
} catch (AcsJContainerServicesEx ce) {
throw new ComponentLifecycleException("Failed to create characteristic model.", ce);
}
// create properties list
properties = new HashMap<PropertyOperations, Servant>();
}
use of com.cosylab.CDB.DAL in project ACS by ACS-Community.
the class ComponentClientTestCase method setUp.
/**
* Starts CORBA in the client process and connects to the manager and logger.
* <p>
* <b>Subclasses that override this method must call <code>super.setUp()</code>,
* likely before any other code in that method.</b>
*
* @see junit.framework.TestCase#setUp()
*/
protected void setUp() throws Exception {
m_logger = ClientLogManager.getAcsLogManager().getLoggerForApplication(getFullName(), true);
m_logger.info("-------------------------------");
m_logger.info("ComponentClientTestCase#setUp()");
POA rootPOA = null;
try {
acsCorba = new AcsCorba(m_logger);
rootPOA = acsCorba.initCorbaForClient(false);
connectToManager();
DAL cdb = DALHelper.narrow(m_acsManagerProxy.get_service("CDB", false));
m_threadFactory = new CleaningDaemonThreadFactory(m_namePrefix, m_logger);
m_containerServices = new ContainerServicesImpl(m_acsManagerProxy, cdb, rootPOA, acsCorba, m_logger, m_acsManagerProxy.getManagerHandle(), this.getClass().getName(), null, m_threadFactory) {
public AcsLogger getLogger() {
return m_logger;
}
};
managerClientImpl.setContainerServices(m_containerServices);
initRemoteLogging();
ACSAlarmSystemInterfaceFactory.init(m_containerServices);
} catch (Exception ex1) {
m_logger.log(Level.SEVERE, "failed to initialize the ORB, or connect to the ACS Manager, " + "or to set up the container services.", ex1);
if (acsCorba != null) {
try {
acsCorba.shutdownORB(true, false);
acsCorba.doneCorba();
} catch (Exception ex2) {
// to JUnit we want to forward the original exception ex1,
// not any other exception from cleaning up the orb
// which we would not have done without the first exception.
// Thus we simply print ex2 but let ex1 fly
ex2.printStackTrace();
}
}
throw ex1;
}
}
use of com.cosylab.CDB.DAL in project ACS by ACS-Community.
the class AdvancedComponentClient method createContainerServices.
/**
* Factory method for additional container service instances. This method should only be used by specialized clients
* such as the OMC GUI which needs independent ContainerServices instances for the plug-ins it runs.
* <p>
* Make sure to call {@link #destroyContainerServices(ContainerServices)} when done with the new CS.
*
* @param clientName
* name for {@link ContainerServices#getName()}
* @param csLogger
* logger to be used internally by the new ContainerServices instance (which is different from the Logger
* returned in {@link ContainerServices#getLogger()}).
* Since ACS 8.0 it is recommended to supply an {@link AcsLogger} instead of a plain JDK Logger because a
* plain Logger will have to be wrapped inside this method.
*/
public ContainerServices createContainerServices(String clientName, Logger csLogger) throws AcsJContainerServicesEx {
if (clientName == null) {
throw new IllegalArgumentException("clientName must not be null");
}
if (csLogger == null) {
throw new IllegalArgumentException("csLogger must not be null");
}
try {
// wrap csLogger if necessary
AcsLogger acsLogger = AcsLogger.fromJdkLogger(csLogger, null);
ThreadFactory threadFactory = new CleaningDaemonThreadFactory(clientName, csLogger);
// separately log in to the manager to get a new client handle.
// TODO: if this does not work, then we need a way to get a new handle from manager without logging in separately.
// Note that when activating components, the container receives the new handle directly from the manager.
AcsManagerProxy acsManagerProxy = m_acsManagerProxy.createInstance();
ManagerClient clImpl = new ManagerClient(clientName, acsLogger);
Client managerClient = clImpl._this(acsCorba.getORB());
acsManagerProxy.loginToManager(managerClient, 0);
int clientHandle = acsManagerProxy.getManagerHandle();
DAL cdb = DALHelper.narrow(m_acsManagerProxy.get_service("CDB", false));
ContainerServicesImpl cs = new ContainerServicesImpl(acsManagerProxy, cdb, acsCorba.getRootPOA(), acsCorba, acsLogger, clientHandle, clientName, null, threadFactory);
additionalContainerServices.put(cs, acsManagerProxy);
return cs;
} catch (Throwable thr) {
throw new AcsJContainerServicesEx(thr);
}
}
use of com.cosylab.CDB.DAL in project ACS by ACS-Community.
the class AlarmSystemContainerServices method getCDB.
@Override
public DAL getCDB() throws AcsJContainerServicesEx {
try {
org.omg.CORBA.Object dalObj = alSysCorbaServer.getServiceFromNameServer("CDB");
DAL dal = DALHelper.narrow(dalObj);
return dal;
} catch (Throwable thr) {
String msg = "Unexpectedly failed to get the CDB reference!";
logger.log(Level.FINE, msg, thr);
AcsJContainerServicesEx ex = new AcsJContainerServicesEx(thr);
ex.setContextInfo(msg);
throw ex;
}
}
Aggregations