Search in sources :

Example 21 with NamingContext

use of org.omg.CosNaming.NamingContext 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 22 with NamingContext

use of org.omg.CosNaming.NamingContext in project ACS by ACS-Community.

the class ContainerServicesImpl method getNameService.

private NamingContext getNameService() throws AcsJContainerServicesEx {
    NamingContext nameService = null;
    try {
        org.omg.CORBA.Object nameServiceObj = m_acsManagerProxy.get_service("NameService", false);
        nameService = NamingContextHelper.narrow(nameServiceObj);
    } catch (AcsJmaciErrTypeEx ex) {
        m_logger.log(Level.FINE, "Failed to get the reference to the NameService service", ex);
        throw new AcsJContainerServicesEx(ex);
    } catch (Throwable thr) {
        String msg = "Unexpectedly failed to get the NameService reference!";
        m_logger.log(Level.FINE, msg, thr);
        AcsJContainerServicesEx ex = new AcsJContainerServicesEx(thr);
        ex.setContextInfo(msg);
        throw ex;
    }
    return nameService;
}
Also used : AcsJmaciErrTypeEx(alma.maciErrType.wrappers.AcsJmaciErrTypeEx) NamingContext(org.omg.CosNaming.NamingContext) AcsJContainerServicesEx(alma.JavaContainerError.wrappers.AcsJContainerServicesEx)

Example 23 with NamingContext

use of org.omg.CosNaming.NamingContext in project ACS by ACS-Community.

the class ACSRemoteAccess method initialize.

/**
	 * Initialize the connection.
	 * 
	 * @param theORB The ORB. 
	 *               If it is null then a new CORBA connection is initialized.
	 * @param manager A reference to the Manager
	 *                If it is null a reference is built by reading the properties.
	 */
public void initialize(ORB theORB, Manager manager) {
    isExternalORB = (theORB != null);
    this.orb = theORB;
    if (orb == null) {
        listenersDispatcher.publishReport("Initializing CORBA...");
        // ORB stanza
        java.util.Properties orbprops = java.lang.System.getProperties();
        orb = ORB.init(new String[0], orbprops);
        // POA stanza -- use RootPOA
        POA rootPOA = null;
        try {
            rootPOA = POAHelper.narrow(orb.resolve_initial_references("RootPOA"));
        } catch (org.omg.CORBA.ORBPackage.InvalidName in) {
            throw new IllegalStateException("Cannot resolve RootPOA: " + in);
        }
        POAManager poaManager = rootPOA.the_POAManager();
        try {
            poaManager.activate();
        } catch (Exception e) {
            throw new IllegalStateException("POAManager activation failed." + e);
        }
        // setup ORB profiling
        try {
            if (orb instanceof AcsProfilingORB) {
                AcsORBProfiler profiler = new AcsORBProfilerImplBase(logger);
                ((AcsProfilingORB) orb).registerAcsORBProfiler(profiler);
                logger.finer("Orb profiling set up, using class " + AcsORBProfilerImplBase.class.getName());
            }
        } catch (Throwable th) {
            logger.log(Level.WARNING, "Failed to setup ORB profiling.", th);
        }
        // end of CORBA stanza
        listenersDispatcher.publishReport("CORBA initialized.");
    }
    Manager maciManager = manager;
    if (maciManager == null) {
        maciManager = resolveManagerReference();
        if (maciManager == null) {
            // HSO: Ale, should this not throw an exception?
            return;
        }
    }
    NamingContext namingContext = resolveNamingServiceContext(maciManager);
    if (namingContext == null) {
        return;
    }
    if (!resolveNotifyChannel(LOGGING_XML_CHANNEL, namingContext)) {
        return;
    }
    boolean isConsumerAdminCreated = createConsumerAdmin();
    if (!isConsumerAdminCreated) {
        return;
    }
    isInitialized = createStructuredPushConsumer();
}
Also used : AcsORBProfilerImplBase(alma.acs.profiling.orb.AcsORBProfilerImplBase) POA(org.omg.PortableServer.POA) POAManager(org.omg.PortableServer.POAManager) Manager(si.ijs.maci.Manager) NamingContext(org.omg.CosNaming.NamingContext) AcsORBProfiler(org.jacorb.orb.acs.AcsORBProfiler) POAManager(org.omg.PortableServer.POAManager) AcsProfilingORB(org.jacorb.orb.acs.AcsProfilingORB)

Example 24 with NamingContext

use of org.omg.CosNaming.NamingContext in project ACS by ACS-Community.

the class ManagerContainerServices method createNotificationChannelPublisher.

@Override
public <T> AcsEventPublisher<T> createNotificationChannelPublisher(String channelName, String channelNotifyServiceDomainName, Class<T> eventType) throws AcsJContainerServicesEx {
    AcsEventPublisher<T> publisher = null;
    try {
        // TODO: Matej please help, is there a more elegant way to get the naming service ref?
        org.omg.CORBA.Object objRef = orb.resolve_initial_references("NameService");
        NamingContext ncRef = NamingContextHelper.narrow(objRef);
        Object[] args = new Object[] { channelName, channelNotifyServiceDomainName, this, ncRef };
        //				// TODO: Can we do this without the direct cast? The usual "asSubclass" is not enough 
        // because we don't create a subclass of Class<T> but rather of Class<U<T>>.
        // Also the getGenericInterfaces / ParameterizedType trick does not work because because we don't have a 
        // concrete parameterized type.
        Class<AcsEventPublisher<T>> clazz = (Class<AcsEventPublisher<T>>) Class.forName(CLASSNAME_NC_PUBLISHER);
        Constructor<? extends AcsEventPublisher<T>> constructor = clazz.getConstructor(String.class, String.class, ContainerServicesBase.class, NamingContext.class);
        publisher = constructor.newInstance(args);
    } catch (ClassNotFoundException e) {
        // TODO: maybe we could prevent future NCPublisher creation tries, since the class isn't and will not be loaded
        //       The same applies for the next "catch" block
        logger.log(AcsLogLevel.ERROR, "Cannot create NC publisher because the 'NCPublisher' class is not present in the classpath", e);
        AcsJContainerServicesEx ex = new AcsJContainerServicesEx(e);
        ex.setContextInfo("'" + CLASSNAME_NC_PUBLISHER + "' class not present in the classpath");
        throw ex;
    } catch (ClassCastException e) {
        logger.log(AcsLogLevel.ERROR, "Cannot create NC publisher because loaded class '" + CLASSNAME_NC_PUBLISHER + "' is not of type 'AcsEventPublisher", e);
        AcsJContainerServicesEx ex = new AcsJContainerServicesEx(e);
        ex.setContextInfo("'" + CLASSNAME_NC_PUBLISHER + "' class does not extend 'AcsEventPublisher'");
        throw ex;
    } catch (Throwable e) {
        logger.log(AcsLogLevel.ERROR, "Unexpected error while creating new AcsEventPublisher object", e);
        AcsJContainerServicesEx ex = new AcsJContainerServicesEx(e);
        throw ex;
    }
    return publisher;
}
Also used : NamingContext(org.omg.CosNaming.NamingContext) AcsJContainerServicesEx(alma.JavaContainerError.wrappers.AcsJContainerServicesEx) AcsEventPublisher(alma.acs.nc.AcsEventPublisher) NO_IMPLEMENT(org.omg.CORBA.NO_IMPLEMENT)

Aggregations

NamingContext (org.omg.CosNaming.NamingContext)24 NameComponent (org.omg.CosNaming.NameComponent)11 AcsJContainerServicesEx (alma.JavaContainerError.wrappers.AcsJContainerServicesEx)4 Object (org.omg.CORBA.Object)4 Properties (java.util.Properties)3 CannotProceedException (javax.naming.CannotProceedException)3 NameNotFoundException (javax.naming.NameNotFoundException)3 NamingException (javax.naming.NamingException)3 NotFound (org.omg.CosNaming.NamingContextPackage.NotFound)3 POA (org.omg.PortableServer.POA)3 AcsORBProfilerImplBase (alma.acs.profiling.orb.AcsORBProfilerImplBase)2 FileWriter (java.io.FileWriter)2 PrintWriter (java.io.PrintWriter)2 NotContextException (javax.naming.NotContextException)2 AcsORBProfiler (org.jacorb.orb.acs.AcsORBProfiler)2 AcsProfilingORB (org.jacorb.orb.acs.AcsProfilingORB)2 ORB (org.omg.CORBA.ORB)2 CannotProceed (org.omg.CosNaming.NamingContextPackage.CannotProceed)2 InvalidName (org.omg.CosNaming.NamingContextPackage.InvalidName)2 AcsJBadParameterEx (alma.ACSErrTypeCommon.wrappers.AcsJBadParameterEx)1