Search in sources :

Example 1 with DAL

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;
}
Also used : ConfigurationProperty(alma.alarmsystem.alarmmessage.generated.ConfigurationProperty) StringReader(java.io.StringReader) AlarmSystemConfiguration(alma.alarmsystem.alarmmessage.generated.AlarmSystemConfiguration) DAL(com.cosylab.CDB.DAL)

Example 2 with DAL

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>();
}
Also used : ComponentLifecycleException(alma.acs.component.ComponentLifecycleException) PropertyOperations(alma.ACS.PropertyOperations) AcsJContainerServicesEx(alma.JavaContainerError.wrappers.AcsJContainerServicesEx) Servant(org.omg.PortableServer.Servant) DAL(com.cosylab.CDB.DAL)

Example 3 with DAL

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;
    }
}
Also used : ContainerServicesImpl(alma.acs.container.ContainerServicesImpl) AcsCorba(alma.acs.container.corba.AcsCorba) POA(org.omg.PortableServer.POA) CleaningDaemonThreadFactory(alma.acs.container.CleaningDaemonThreadFactory) DAL(com.cosylab.CDB.DAL) AcsLogger(alma.acs.logging.AcsLogger)

Example 4 with DAL

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);
    }
}
Also used : CleaningDaemonThreadFactory(alma.acs.container.CleaningDaemonThreadFactory) ThreadFactory(java.util.concurrent.ThreadFactory) ContainerServicesImpl(alma.acs.container.ContainerServicesImpl) CleaningDaemonThreadFactory(alma.acs.container.CleaningDaemonThreadFactory) Client(si.ijs.maci.Client) AcsJContainerServicesEx(alma.JavaContainerError.wrappers.AcsJContainerServicesEx) DAL(com.cosylab.CDB.DAL) AcsLogger(alma.acs.logging.AcsLogger) AcsManagerProxy(alma.acs.container.AcsManagerProxy)

Example 5 with DAL

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;
    }
}
Also used : AcsJContainerServicesEx(alma.JavaContainerError.wrappers.AcsJContainerServicesEx) DAL(com.cosylab.CDB.DAL)

Aggregations

DAL (com.cosylab.CDB.DAL)13 AcsJContainerServicesEx (alma.JavaContainerError.wrappers.AcsJContainerServicesEx)5 CleaningDaemonThreadFactory (alma.acs.container.CleaningDaemonThreadFactory)3 ContainerServicesImpl (alma.acs.container.ContainerServicesImpl)3 AcsManagerProxy (alma.acs.container.AcsManagerProxy)2 AcsLogger (alma.acs.logging.AcsLogger)2 Logger (java.util.logging.Logger)2 NamingException (javax.naming.NamingException)2 ORB (org.omg.CORBA.ORB)2 PropertyOperations (alma.ACS.PropertyOperations)1 AlarmSourceFactory (alma.acs.alarmsystem.source.AlarmSourceFactory)1 ComponentLifecycleException (alma.acs.component.ComponentLifecycleException)1 AcsCorba (alma.acs.container.corba.AcsCorba)1 AlarmSystemConfiguration (alma.alarmsystem.alarmmessage.generated.AlarmSystemConfiguration)1 ConfigurationProperty (alma.alarmsystem.alarmmessage.generated.ConfigurationProperty)1 JDAL (com.cosylab.CDB.JDAL)1 WDAL (com.cosylab.CDB.WDAL)1 StringReader (java.io.StringReader)1 ThreadFactory (java.util.concurrent.ThreadFactory)1 PatternSyntaxException (java.util.regex.PatternSyntaxException)1