Search in sources :

Example 11 with DAL

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);
}
Also used : NamingException(javax.naming.NamingException) Logger(java.util.logging.Logger) ORB(org.omg.CORBA.ORB) DAL(com.cosylab.CDB.DAL) PatternSyntaxException(java.util.regex.PatternSyntaxException)

Example 12 with DAL

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);
    }
}
Also used : NameComponent(org.omg.CosNaming.NameComponent) NamingContext(org.omg.CosNaming.NamingContext) DAL(com.cosylab.CDB.DAL)

Example 13 with DAL

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));
            }
        }
    }
}
Also used : AlarmSourceFactory(alma.acs.alarmsystem.source.AlarmSourceFactory) 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