iiop-openjdk/src/main/java/org/wildfly/iiop/openjdk/naming/jndi/CNCtx.java
private void initOrbAndRootContext(Hashtable env) throws NamingException {
        org.omg.CORBA.ORB inOrb = null;
        String ncIor = null;

        if (env != null) {
            inOrb = (org.omg.CORBA.ORB) env.get("java.naming.corba.orb");
        }

        // Extract PROVIDER_URL from environment
        String provUrl = null;
        if (env != null) {
            provUrl = (String) env.get(javax.naming.Context.PROVIDER_URL);
        }

        if (provUrl != null && !isCorbaUrl(provUrl)) {
            // Initialize the root naming context by using the IOR supplied
            // in the PROVIDER_URL
            ncIor = getStringifiedIor(provUrl);

            if (inOrb == null) {

                // no ORB instance specified; create one using env and defaults
                inOrb = CorbaORBService.getCurrent();
            }
            setOrbAndRootContext(inOrb, ncIor);
        } else if (provUrl != null) {
            // Initialize the root naming context by using the URL supplied
            // in the PROVIDER_URL
            String insName = initUsingUrl(inOrb, provUrl, env);

            // If name supplied in URL, resolve it to a NamingContext
            if (insName.length() > 0) {
                _name = parser.nameToCosName(parser.parse(insName));
                try {
                    org.omg.CORBA.Object obj = _nc.resolve(_name);
                    _nc = NamingContextHelper.narrow(obj);
                    if (_nc == null) {
                        throw IIOPLogger.ROOT_LOGGER.notANamingContext(insName);
                    }
                } catch (org.omg.CORBA.BAD_PARAM e) {
                    throw IIOPLogger.ROOT_LOGGER.notANamingContext(insName);
                } catch (Exception e) {
                    throw org.wildfly.iiop.openjdk.naming.jndi.ExceptionMapper.mapException(e, this, _name);
                }
            }
        } else {
            // No PROVIDER_URL supplied; initialize using defaults
            if (inOrb == null) {

                // No ORB instance specified; create one using env and defaults
                inOrb = CorbaORBService.getCurrent();
                IIOPLogger.ROOT_LOGGER.debugf("Getting default ORB %s", inOrb);
            }
            setOrbAndRootContext(inOrb, (String) null);
        }
    }
private void initOrbAndRootContext(Hashtable env) throws NamingException {
        org.omg.CORBA.ORB inOrb = null;
        String ncIor = null;

        if (env != null) {
            inOrb = (org.omg.CORBA.ORB) env.get("java.naming.corba.orb");
        }

        // Extract PROVIDER_URL from environment
        String provUrl = null;
        if (env != null) {
            provUrl = (String) env.get(javax.naming.Context.PROVIDER_URL);
        }

        if (provUrl != null && !isCorbaUrl(provUrl)) {
            // Initialize the root naming context by using the IOR supplied
            // in the PROVIDER_URL
            ncIor = getStringifiedIor(provUrl);

            if (inOrb == null) {

                // no ORB instance specified; create one using env and defaults
                inOrb = CorbaORBService.getCurrent();
            }
            setOrbAndRootContext(inOrb, ncIor);
        } else if (provUrl != null) {
            // Initialize the root naming context by using the URL supplied
            // in the PROVIDER_URL
            String insName = initUsingUrl(inOrb, provUrl, env);

            // If name supplied in URL, resolve it to a NamingContext
            if (insName.length() > 0) {
                _name = parser.nameToCosName(parser.parse(insName));
                try {
                    org.omg.CORBA.Object obj = _nc.resolve(_name);
                    _nc = NamingContextHelper.narrow(obj);
                    if (_nc == null) {
                        throw IIOPLogger.ROOT_LOGGER.notANamingContext(insName);
                    }
                } catch (org.omg.CORBA.BAD_PARAM e) {
                    throw IIOPLogger.ROOT_LOGGER.notANamingContext(insName);
                } catch (Exception e) {
                    throw org.wildfly.iiop.openjdk.naming.jndi.ExceptionMapper.mapException(e, this, _name);
                }
            }
        } else {
            // No PROVIDER_URL supplied; initialize using defaults
            if (inOrb == null) {

                // No ORB instance specified; create one using env and defaults
                inOrb = CorbaORBService.getCurrent();
                IIOPLogger.ROOT_LOGGER.debugf("Getting default ORB %s", inOrb);
            }
            setOrbAndRootContext(inOrb, (String) null);
        }
    }
private void initOrbAndRootContext ( Hashtable env ) throws NamingException { org . omg . CORBA . ORB inOrb = null ; String ncIor = null ; if ( env != null ) { inOrb = ( org . omg . CORBA . ORB ) env . get ( "java.naming.corba.orb" ) ; } // Extract PROVIDER_URL from environment String provUrl = null ; if ( env != null ) { provUrl = ( String ) env . get ( javax . naming . Context . PROVIDER_URL ) ; } if ( provUrl != null && ! isCorbaUrl ( provUrl ) ) { // Initialize the root naming context by using the IOR supplied // in the PROVIDER_URL ncIor = getStringifiedIor ( provUrl ) ; if ( inOrb == null ) { // no ORB instance specified; create one using env and defaults inOrb = CorbaORBService . getCurrent ( ) ; } setOrbAndRootContext ( inOrb , ncIor ) ; } else if ( provUrl != null ) { // Initialize the root naming context by using the URL supplied // in the PROVIDER_URL String insName = initUsingUrl ( inOrb , provUrl , env ) ; // If name supplied in URL, resolve it to a NamingContext if ( insName . length ( ) > 0 ) { _name = parser . nameToCosName ( parser . parse ( insName ) ) ; try { org . omg . CORBA . Object obj = _nc . resolve ( _name ) ; _nc = NamingContextHelper . narrow ( obj ) ; if ( _nc == null ) { throw IIOPLogger . ROOT_LOGGER . notANamingContext ( insName ) ; } } catch ( org . omg . CORBA . BAD_PARAM e ) { throw IIOPLogger . ROOT_LOGGER . notANamingContext ( insName ) ; } catch ( Exception e ) { throw org . wildfly . iiop . openjdk . naming . jndi . ExceptionMapper . mapException ( e , this , _name ) ; } } } else { // No PROVIDER_URL supplied; initialize using defaults if ( inOrb == null ) { // No ORB instance specified; create one using env and defaults inOrb = CorbaORBService . getCurrent ( ) ; IIOPLogger . ROOT_LOGGER . debugf ( "Getting default ORB %s" , inOrb ) ; } setOrbAndRootContext ( inOrb , ( String ) null ) ; } }
Initializes the COS Naming Service.
This method initializes the three instance fields:
_nc : The root naming context.
_orb: The ORB to use for connecting RMI/IIOP stubs and for
getting the naming context (_nc) if one was not specified
explicitly via PROVIDER_URL.
_name: The name of the root naming context.
<p/>
_orb is obtained from java.naming.corba.orb if it has been set.
Otherwise, _orb is created using the host/port from PROVIDER_URL
(if it contains an "iiop" or "iiopname" URL), or from initialization
properties specified in env.
<p/>
_nc is obtained from the IOR stored in PROVIDER_URL if it has been
set and does not contain an "iiop" or "iiopname" URL. It can be
a stringified IOR, "corbaloc" URL, "corbaname" URL,
or a URL (such as file/http/ftp) to a location
containing a stringified IOR. If PROVIDER_URL has not been
set in this way, it is obtained from the result of
ORB.resolve_initial_reference("NameService");
<p/>
_name is obtained from the "iiop", "iiopname", or "corbaname" URL.
It is the empty name by default.

@param env Environment The possibly null environment.
@throws NamingException When an error occurs while initializing the
ORB or the naming context.
Initializes the COS Naming Service . This method initializes the three instance fields : _nc : The root naming context . _orb : The ORB to use for connecting RMI / IIOP stubs and for getting the naming context ( _nc ) if one was not specified explicitly via PROVIDER_URL . _name : The name of the root naming context . <p / > _orb is obtained from java . naming . corba . orb if it has been set . Otherwise _orb is created using the host / port from PROVIDER_URL ( if it contains an iiop or iiopname URL ) or from initialization properties specified in env . <p / > _nc is obtained from the IOR stored in PROVIDER_URL if it has been set and does not contain an iiop or iiopname URL . It can be a stringified IOR corbaloc URL corbaname URL or a URL ( such as file / http / ftp ) to a location containing a stringified IOR . If PROVIDER_URL has not been set in this way it is obtained from the result of ORB . resolve_initial_reference ( NameService ) ; <p / > _name is obtained from the iiop iiopname or corbaname URL . It is the empty name by default .