iiop-openjdk/src/main/java/org/wildfly/iiop/openjdk/naming/jndi/CNCtx.java
private void callBindOrRebind(NameComponent[] pth, Name name,
                                  java.lang.Object obj, boolean rebind) throws NamingException {
        if (_nc == null)
            throw IIOPLogger.ROOT_LOGGER.notANamingContext(name.toString());
        try {
            // Call state factories to convert
            obj = NamingManager.getStateToBind(obj, name, this, _env);

            if (obj instanceof CNCtx) {
                // Use naming context object reference
                obj = ((CNCtx) obj)._nc;
            }

            if (obj instanceof org.omg.CosNaming.NamingContext) {
                NamingContext nobj = NamingContextHelper.narrow((org.omg.CORBA.Object) obj);
                if (rebind)
                    _nc.rebind_context(pth, nobj);
                else
                    _nc.bind_context(pth, nobj);

            } else if (obj instanceof org.omg.CORBA.Object) {
                if (rebind)
                    _nc.rebind(pth, (org.omg.CORBA.Object) obj);
                else
                    _nc.bind(pth, (org.omg.CORBA.Object) obj);
            } else
                throw IIOPLogger.ROOT_LOGGER.notACorbaObject();
        } catch (BAD_PARAM e) {
            // probably narrow() failed?
            NamingException ne = new NotContextException(name.toString());
            ne.setRootCause(e);
            throw ne;
        } catch (Exception e) {
            throw org.wildfly.iiop.openjdk.naming.jndi.ExceptionMapper.mapException(e, this, pth);
        }
    }
private void callBindOrRebind(NameComponent[] pth, Name name,
                                  java.lang.Object obj, boolean rebind) throws NamingException {
        if (_nc == null)
            throw IIOPLogger.ROOT_LOGGER.notANamingContext(name.toString());
        try {
            // Call state factories to convert
            obj = NamingManager.getStateToBind(obj, name, this, _env);

            if (obj instanceof CNCtx) {
                // Use naming context object reference
                obj = ((CNCtx) obj)._nc;
            }

            if (obj instanceof org.omg.CosNaming.NamingContext) {
                NamingContext nobj = NamingContextHelper.narrow((org.omg.CORBA.Object) obj);
                if (rebind)
                    _nc.rebind_context(pth, nobj);
                else
                    _nc.bind_context(pth, nobj);

            } else if (obj instanceof org.omg.CORBA.Object) {
                if (rebind)
                    _nc.rebind(pth, (org.omg.CORBA.Object) obj);
                else
                    _nc.bind(pth, (org.omg.CORBA.Object) obj);
            } else
                throw IIOPLogger.ROOT_LOGGER.notACorbaObject();
        } catch (BAD_PARAM e) {
            // probably narrow() failed?
            NamingException ne = new NotContextException(name.toString());
            ne.setRootCause(e);
            throw ne;
        } catch (Exception e) {
            throw org.wildfly.iiop.openjdk.naming.jndi.ExceptionMapper.mapException(e, this, pth);
        }
    }
Performs bind or rebind in the context depending on whether the
flag rebind is set. The only objects allowed to be bound are of
types org.omg.CORBA.Object, org.omg.CosNaming.NamingContext.
You can use a state factory to turn other objects (such as
Remote) into these acceptable forms.
<p/>
Uses the COS Naming apis bind/rebind or
bind_context/rebind_context.

@param pth    NameComponent[] object
@param obj    Object to be bound.
@param rebind perform rebind ? if true performs a rebind.
@throws NotFound      No objects under the name.
@throws org.omg.CosNaming.NamingContextPackage.CannotProceed Unable to obtain a continuation context
@throws org.omg.CosNaming.NamingContextPackage.AlreadyBound  An object is already bound to this name.