Search in sources :

Example 16 with NameComponent

use of org.omg.CosNaming.NameComponent in project wildfly by wildfly.

the class CNBindingEnumeration method mapBinding.

/**
     * Constructs a JNDI Binding object from the COS Naming binding
     * object.
     *
     * @throws org.omg.CosNaming.NamingContextPackage.CannotProceed   Unable to obtain a continuation context
     * @throws org.omg.CosNaming.NamingContextPackage.InvalidNameCNCtx     Name not understood.
     * @throws NamingException One of the above.
     */
private javax.naming.Binding mapBinding(org.omg.CosNaming.Binding bndg) throws NamingException {
    java.lang.Object obj = _ctx.callResolve(bndg.binding_name);
    Name cname = org.wildfly.iiop.openjdk.naming.jndi.CNNameParser.cosNameToName(bndg.binding_name);
    try {
        obj = NamingManager.getObjectInstance(obj, cname, _ctx, _env);
    } catch (NamingException e) {
        throw e;
    } catch (Exception e) {
        NamingException ne = IIOPLogger.ROOT_LOGGER.errorGeneratingObjectViaFactory();
        ne.setRootCause(e);
        throw ne;
    }
    // Use cname.toString() instead of bindingName because the name
    // in the binding should be a composite name
    String cnameStr = cname.toString();
    javax.naming.Binding jbndg = new javax.naming.Binding(cnameStr, obj);
    NameComponent[] comps = _ctx.makeFullName(bndg.binding_name);
    String fullName = org.wildfly.iiop.openjdk.naming.jndi.CNNameParser.cosNameToInsString(comps);
    jbndg.setNameInNamespace(fullName);
    return jbndg;
}
Also used : NameComponent(org.omg.CosNaming.NameComponent) NamingException(javax.naming.NamingException) NamingException(javax.naming.NamingException) NoSuchElementException(java.util.NoSuchElementException) Name(javax.naming.Name)

Example 17 with NameComponent

use of org.omg.CosNaming.NameComponent in project jdk8u_jdk by JetBrains.

the class CNNameParser method parseComponent.

/**
     * Return a NameComponent given its stringified form.
     */
private static NameComponent parseComponent(String compStr) throws InvalidNameException {
    NameComponent comp = new NameComponent();
    int kindSep = -1;
    int len = compStr.length();
    int j = 0;
    char[] newStr = new char[len];
    boolean escaped = false;
    // Find the kind separator
    for (int i = 0; i < len && kindSep < 0; i++) {
        if (escaped) {
            newStr[j++] = compStr.charAt(i);
            escaped = false;
        } else if (compStr.charAt(i) == escapeChar) {
            if (i + 1 >= len) {
                throw new InvalidNameException(compStr + ": unescaped \\ at end of component");
            } else if (isMeta(compStr.charAt(i + 1))) {
                escaped = true;
            } else {
                throw new InvalidNameException(compStr + ": invalid character being escaped");
            }
        } else if (compStr.charAt(i) == kindSeparator) {
            kindSep = i;
        } else {
            newStr[j++] = compStr.charAt(i);
        }
    }
    // Set id
    comp.id = new String(newStr, 0, j);
    // Set kind
    if (kindSep < 0) {
        // no kind separator
        comp.kind = "";
    } else {
        // unescape kind
        j = 0;
        escaped = false;
        for (int i = kindSep + 1; i < len; i++) {
            if (escaped) {
                newStr[j++] = compStr.charAt(i);
                escaped = false;
            } else if (compStr.charAt(i) == escapeChar) {
                if (i + 1 >= len) {
                    throw new InvalidNameException(compStr + ": unescaped \\ at end of component");
                } else if (isMeta(compStr.charAt(i + 1))) {
                    escaped = true;
                } else {
                    throw new InvalidNameException(compStr + ": invalid character being escaped");
                }
            } else {
                newStr[j++] = compStr.charAt(i);
            }
        }
        comp.kind = new String(newStr, 0, j);
    }
    return comp;
}
Also used : NameComponent(org.omg.CosNaming.NameComponent)

Example 18 with NameComponent

use of org.omg.CosNaming.NameComponent in project wildfly by wildfly.

the class CNCtx method destroySubcontext.

/**
     * Uses the callDestroy function to destroy the context. Destroys
     * the current context if name is empty.
     *
     * @param name JNDI Name
     * @throws javax.naming.OperationNotSupportedException when list is invoked
     *                                        with a non-null argument
     */
public void destroySubcontext(Name name) throws NamingException {
    if (_nc == null)
        throw IIOPLogger.ROOT_LOGGER.notANamingContext(name.toString());
    NamingContext the_nc = _nc;
    NameComponent[] path = org.wildfly.iiop.openjdk.naming.jndi.CNNameParser.nameToCosName(name);
    if (name.size() > 0) {
        try {
            javax.naming.Context ctx = (javax.naming.Context) callResolve(path);
            CNCtx cnc = (CNCtx) ctx;
            the_nc = cnc._nc;
            //remove the reference to the context
            cnc.close();
        } catch (ClassCastException e) {
            throw new NotContextException(name.toString());
        } catch (CannotProceedException e) {
            javax.naming.Context cctx = getContinuationContext(e);
            cctx.destroySubcontext(e.getRemainingName());
            return;
        } catch (NameNotFoundException e) {
            if (e.getRootCause() instanceof NotFound && leafNotFound((NotFound) e.getRootCause(), path[path.length - 1])) {
                // leaf missing OK
                return;
            }
            throw e;
        } catch (NamingException e) {
            throw e;
        }
    }
    callDestroy(the_nc);
    callUnbind(path);
}
Also used : NamingContext(org.omg.CosNaming.NamingContext) NotContextException(javax.naming.NotContextException) NameComponent(org.omg.CosNaming.NameComponent) NameNotFoundException(javax.naming.NameNotFoundException) NamingContext(org.omg.CosNaming.NamingContext) CannotProceedException(javax.naming.CannotProceedException) NamingException(javax.naming.NamingException) NotFound(org.omg.CosNaming.NamingContextPackage.NotFound)

Example 19 with NameComponent

use of org.omg.CosNaming.NameComponent in project wildfly by wildfly.

the class CNNameParser method parseComponent.

/**
     * Return a NameComponent given its stringified form.
     */
private static NameComponent parseComponent(String compStr) throws InvalidNameException {
    NameComponent comp = new NameComponent();
    int kindSep = -1;
    int len = compStr.length();
    int j = 0;
    char[] newStr = new char[len];
    boolean escaped = false;
    // Find the kind separator
    for (int i = 0; i < len && kindSep < 0; i++) {
        if (escaped) {
            newStr[j++] = compStr.charAt(i);
            escaped = false;
        } else if (compStr.charAt(i) == escapeChar) {
            if (i + 1 >= len) {
                throw IIOPLogger.ROOT_LOGGER.unescapedCharacter(compStr);
            } else if (isMeta(compStr.charAt(i + 1))) {
                escaped = true;
            } else {
                throw IIOPLogger.ROOT_LOGGER.invalidEscapedCharacter(compStr);
            }
        } else if (compStr.charAt(i) == kindSeparator) {
            kindSep = i;
        } else {
            newStr[j++] = compStr.charAt(i);
        }
    }
    // Set id
    comp.id = new String(newStr, 0, j);
    // Set kind
    if (kindSep < 0) {
        // no kind separator
        comp.kind = "";
    } else {
        // unescape kind
        j = 0;
        escaped = false;
        for (int i = kindSep + 1; i < len; i++) {
            if (escaped) {
                newStr[j++] = compStr.charAt(i);
                escaped = false;
            } else if (compStr.charAt(i) == escapeChar) {
                if (i + 1 >= len) {
                    throw IIOPLogger.ROOT_LOGGER.unescapedCharacter(compStr);
                } else if (isMeta(compStr.charAt(i + 1))) {
                    escaped = true;
                } else {
                    throw IIOPLogger.ROOT_LOGGER.invalidEscapedCharacter(compStr);
                }
            } else {
                newStr[j++] = compStr.charAt(i);
            }
        }
        comp.kind = new String(newStr, 0, j);
    }
    return comp;
}
Also used : NameComponent(org.omg.CosNaming.NameComponent)

Example 20 with NameComponent

use of org.omg.CosNaming.NameComponent in project wildfly by wildfly.

the class CNNameParser method insStringToStringifiedComps.

/**
     * Converts an INS-syntax string name into a Vector in which
     * each element of the vector contains a stringified form of
     * a NameComponent.
     */
private static Vector insStringToStringifiedComps(String str) throws InvalidNameException {
    int len = str.length();
    Vector components = new Vector(10);
    char[] id = new char[len];
    char[] kind = new char[len];
    int idCount, kindCount;
    boolean idMode;
    for (int i = 0; i < len; ) {
        // reset for new component
        idCount = kindCount = 0;
        // always start off parsing id
        idMode = true;
        while (i < len) {
            if (str.charAt(i) == compSeparator) {
                break;
            } else if (str.charAt(i) == escapeChar) {
                if (i + 1 >= len) {
                    throw IIOPLogger.ROOT_LOGGER.unescapedCharacter(str);
                } else if (isMeta(str.charAt(i + 1))) {
                    // skip escape and let meta through
                    ++i;
                    if (idMode) {
                        id[idCount++] = str.charAt(i++);
                    } else {
                        kind[kindCount++] = str.charAt(i++);
                    }
                } else {
                    throw IIOPLogger.ROOT_LOGGER.invalidEscapedCharacter(str);
                }
            } else if (idMode && str.charAt(i) == kindSeparator) {
                // just look for the first kindSeparator
                // skip kind separator
                ++i;
                idMode = false;
            } else {
                if (idMode) {
                    id[idCount++] = str.charAt(i++);
                } else {
                    kind[kindCount++] = str.charAt(i++);
                }
            }
        }
        components.addElement(stringifyComponent(new NameComponent(new String(id, 0, idCount), new String(kind, 0, kindCount))));
        if (i < len) {
            // skip separator
            ++i;
        }
    }
    return components;
}
Also used : NameComponent(org.omg.CosNaming.NameComponent) Vector(java.util.Vector)

Aggregations

NameComponent (org.omg.CosNaming.NameComponent)34 NamingContext (org.omg.CosNaming.NamingContext)12 NotFound (org.omg.CosNaming.NamingContextPackage.NotFound)10 InvalidName (org.omg.CosNaming.NamingContextPackage.InvalidName)9 CannotProceed (org.omg.CosNaming.NamingContextPackage.CannotProceed)8 AcsJCORBAProblemEx (alma.ACSErrTypeCommon.wrappers.AcsJCORBAProblemEx)3 NamingException (javax.naming.NamingException)3 AcsJUnexpectedExceptionEx (alma.ACSErrTypeCommon.wrappers.AcsJUnexpectedExceptionEx)2 EventChannel (gov.sandia.NotifyMonitoringExt.EventChannel)2 FileWriter (java.io.FileWriter)2 PrintWriter (java.io.PrintWriter)2 Properties (java.util.Properties)2 CannotProceedException (javax.naming.CannotProceedException)2 Name (javax.naming.Name)2 NameNotFoundException (javax.naming.NameNotFoundException)2 ORB (org.omg.CORBA.ORB)2 Object (org.omg.CORBA.Object)2 AlreadyBound (org.omg.CosNaming.NamingContextPackage.AlreadyBound)2 POA (org.omg.PortableServer.POA)2 AcsJNarrowFailedEx (alma.ACSErrTypeCORBA.wrappers.AcsJNarrowFailedEx)1