Search in sources :

Example 26 with NamingContext

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

the class ExceptionMapper method mapException.

public static NamingException mapException(Exception e, CNCtx ctx, NameComponent[] inputName) throws NamingException {
    if (e instanceof NamingException) {
        return (NamingException) e;
    }
    if (e instanceof RuntimeException) {
        throw (RuntimeException) e;
    }
    NamingException ne;
    if (e instanceof NotFound) {
        if (ctx.federation) {
            return tryFed((NotFound) e, ctx, inputName);
        } else {
            ne = new NameNotFoundException();
        }
    } else if (e instanceof CannotProceed) {
        ne = new CannotProceedException();
        NamingContext nc = ((CannotProceed) e).cxt;
        NameComponent[] rest = ((CannotProceed) e).rest_of_name;
        // NotFound doesn't set rest as expected. -RL
        if (inputName != null && (inputName.length > rest.length)) {
            NameComponent[] resolvedName = new NameComponent[inputName.length - rest.length];
            System.arraycopy(inputName, 0, resolvedName, 0, resolvedName.length);
            // Wrap resolved NamingContext inside a CNCtx
            // Guess that its name (which is relative to ctx)
            // is the part of inputName minus rest_of_name
            ne.setResolvedObj(new CNCtx(ctx._orb, nc, ctx._env, ctx.makeFullName(resolvedName)));
        } else {
            ne.setResolvedObj(ctx);
        }
        ne.setRemainingName(org.wildfly.iiop.openjdk.naming.jndi.CNNameParser.cosNameToName(rest));
    } else if (e instanceof InvalidName) {
        ne = new InvalidNameException();
    } else if (e instanceof AlreadyBound) {
        ne = new NameAlreadyBoundException();
    } else if (e instanceof NotEmpty) {
        ne = new ContextNotEmptyException();
    } else {
        ne = new NamingException();
    }
    ne.setRootCause(e);
    return ne;
}
Also used : NameNotFoundException(javax.naming.NameNotFoundException) CannotProceed(org.omg.CosNaming.NamingContextPackage.CannotProceed) NamingContext(org.omg.CosNaming.NamingContext) NameAlreadyBoundException(javax.naming.NameAlreadyBoundException) InvalidName(org.omg.CosNaming.NamingContextPackage.InvalidName) InvalidNameException(javax.naming.InvalidNameException) CannotProceedException(javax.naming.CannotProceedException) ContextNotEmptyException(javax.naming.ContextNotEmptyException) NamingException(javax.naming.NamingException) AlreadyBound(org.omg.CosNaming.NamingContextPackage.AlreadyBound) NotEmpty(org.omg.CosNaming.NamingContextPackage.NotEmpty) NotFound(org.omg.CosNaming.NamingContextPackage.NotFound)

Example 27 with NamingContext

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

Aggregations

NamingContext (org.omg.CosNaming.NamingContext)27 NameComponent (org.omg.CosNaming.NameComponent)14 AcsJContainerServicesEx (alma.JavaContainerError.wrappers.AcsJContainerServicesEx)4 Object (org.omg.CORBA.Object)4 PrintWriter (java.io.PrintWriter)3 Properties (java.util.Properties)3 CannotProceedException (javax.naming.CannotProceedException)3 NameNotFoundException (javax.naming.NameNotFoundException)3 NamingException (javax.naming.NamingException)3 BAD_PARAM (org.omg.CORBA.BAD_PARAM)3 NotFound (org.omg.CosNaming.NamingContextPackage.NotFound)3 AcsORBProfilerImplBase (alma.acs.profiling.orb.AcsORBProfilerImplBase)2 File (java.io.File)2 FileNotFoundException (java.io.FileNotFoundException)2 FileReader (java.io.FileReader)2 FileWriter (java.io.FileWriter)2 IOException (java.io.IOException)2 LineNumberReader (java.io.LineNumberReader)2 NotContextException (javax.naming.NotContextException)2 AcsORBProfiler (org.jacorb.orb.acs.AcsORBProfiler)2