Search in sources :

Example 1 with CorbaNamingContext

use of org.wildfly.iiop.openjdk.naming.CorbaNamingContext in project wildfly by wildfly.

the class CorbaNamingService method start.

@Override
public void start(StartContext context) throws StartException {
    IIOPLogger.ROOT_LOGGER.debugf("Starting service %s", context.getController().getName().getCanonicalName());
    ORB orb = orbInjector.getValue();
    POA rootPOA = rootPOAInjector.getValue();
    POA namingPOA = namingPOAInjector.getValue();
    try {
        // initialize the static naming service variables.
        CorbaNamingContext.init(orb, rootPOA);
        // create and initialize the root context instance according to the configuration.
        CorbaNamingContext ns = new CorbaNamingContext();
        ns.init(namingPOA, false, false);
        // create and activate the root context.
        byte[] rootContextId = "root".getBytes();
        namingPOA.activate_object_with_id(rootContextId, ns);
        namingService = NamingContextExtHelper.narrow(namingPOA.create_reference_with_id(rootContextId, "IDL:omg.org/CosNaming/NamingContextExt:1.0"));
        // exporting the NameService initial reference
        ((com.sun.corba.se.impl.orb.ORBImpl) orb).register_initial_reference(Constants.NAME_SERVICE_INIT_REF, namingPOA.servant_to_reference(ns));
        // exporting root-context initial reference
        final boolean exportCorbaloc = properties.getProperty(Constants.NAMING_EXPORT_CORBALOC).equals("true");
        if (exportCorbaloc) {
            final String rootContext = properties.getProperty(Constants.NAMING_ROOT_CONTEXT);
            ((com.sun.corba.se.impl.orb.ORBImpl) orb).register_initial_reference(rootContext, namingPOA.servant_to_reference(ns));
        }
    } catch (Exception e) {
        throw IIOPLogger.ROOT_LOGGER.failedToStartJBossCOSNaming(e);
    }
    // bind the corba naming service to JNDI.
    CorbaServiceUtil.bindObject(context.getChildTarget(), "corbanaming", namingService);
    if (IIOPLogger.ROOT_LOGGER.isDebugEnabled()) {
        IIOPLogger.ROOT_LOGGER.corbaNamingServiceStarted();
        IIOPLogger.ROOT_LOGGER.debugf("Naming: [%s]", orb.object_to_string(namingService));
    }
}
Also used : POA(org.omg.PortableServer.POA) CorbaNamingContext(org.wildfly.iiop.openjdk.naming.CorbaNamingContext) ORB(org.omg.CORBA.ORB) StartException(org.jboss.msc.service.StartException)

Aggregations

StartException (org.jboss.msc.service.StartException)1 ORB (org.omg.CORBA.ORB)1 POA (org.omg.PortableServer.POA)1 CorbaNamingContext (org.wildfly.iiop.openjdk.naming.CorbaNamingContext)1