Search in sources :

Example 16 with ResolveResult

use of javax.naming.spi.ResolveResult in project jdk8u_jdk by JetBrains.

the class GenericURLContext method createSubcontext.

public Context createSubcontext(String name) throws NamingException {
    ResolveResult res = getRootURLContext(name, myEnv);
    Context ctx = (Context) res.getResolvedObj();
    try {
        return ctx.createSubcontext(res.getRemainingName());
    } finally {
        ctx.close();
    }
}
Also used : ResolveResult(javax.naming.spi.ResolveResult)

Example 17 with ResolveResult

use of javax.naming.spi.ResolveResult in project jdk8u_jdk by JetBrains.

the class GenericURLContext method bind.

public void bind(String name, Object obj) throws NamingException {
    ResolveResult res = getRootURLContext(name, myEnv);
    Context ctx = (Context) res.getResolvedObj();
    try {
        ctx.bind(res.getRemainingName(), obj);
    } finally {
        ctx.close();
    }
}
Also used : ResolveResult(javax.naming.spi.ResolveResult)

Example 18 with ResolveResult

use of javax.naming.spi.ResolveResult in project jdk8u_jdk by JetBrains.

the class GenericURLContext method unbind.

public void unbind(String name) throws NamingException {
    ResolveResult res = getRootURLContext(name, myEnv);
    Context ctx = (Context) res.getResolvedObj();
    try {
        ctx.unbind(res.getRemainingName());
    } finally {
        ctx.close();
    }
}
Also used : ResolveResult(javax.naming.spi.ResolveResult)

Example 19 with ResolveResult

use of javax.naming.spi.ResolveResult in project jdk8u_jdk by JetBrains.

the class GenericURLContext method listBindings.

public NamingEnumeration<Binding> listBindings(String name) throws NamingException {
    ResolveResult res = getRootURLContext(name, myEnv);
    Context ctx = (Context) res.getResolvedObj();
    try {
        return ctx.listBindings(res.getRemainingName());
    } finally {
        ctx.close();
    }
}
Also used : ResolveResult(javax.naming.spi.ResolveResult)

Example 20 with ResolveResult

use of javax.naming.spi.ResolveResult in project wildfly by wildfly.

the class NamingContext method lookup.

public Object lookup(final Name name, boolean dereference) throws NamingException {
    check(name, JndiPermission.ACTION_LOOKUP);
    if (isEmpty(name)) {
        return new NamingContext(prefix, namingStore, environment);
    }
    final Name absoluteName = getAbsoluteName(name);
    Object result;
    try {
        result = namingStore.lookup(absoluteName, dereference);
    } catch (CannotProceedException cpe) {
        final Context continuationContext = NamingManager.getContinuationContext(cpe);
        if (continuationContext instanceof NamingContext) {
            result = ((NamingContext) continuationContext).lookup(cpe.getRemainingName(), dereference);
        } else {
            result = continuationContext.lookup(cpe.getRemainingName());
        }
    }
    if (result instanceof ResolveResult) {
        final ResolveResult resolveResult = (ResolveResult) result;
        final Object resolvedObject = resolveResult.getResolvedObj();
        Object context;
        if (resolvedObject instanceof Context) {
            context = resolvedObject;
        } else if (resolvedObject instanceof LinkRef) {
            context = resolveLink(resolvedObject, dereference);
        } else {
            context = getObjectInstance(resolvedObject, absoluteName, environment);
        }
        if (!(context instanceof Context)) {
            throw notAContextException(absoluteName.getPrefix(absoluteName.size() - resolveResult.getRemainingName().size()));
        }
        final Context namingContext = (Context) context;
        if (namingContext instanceof NamingContext) {
            return ((NamingContext) namingContext).lookup(resolveResult.getRemainingName(), dereference);
        } else {
            return namingContext.lookup(resolveResult.getRemainingName());
        }
    } else if (result instanceof LinkRef) {
        result = resolveLink(result, dereference);
    } else if (result instanceof Reference) {
        result = getObjectInstance(result, absoluteName, environment);
        if (result instanceof LinkRef) {
            result = resolveLink(result, dereference);
        }
    }
    return result;
}
Also used : Context(javax.naming.Context) InitialContext(javax.naming.InitialContext) EventContext(javax.naming.event.EventContext) CannotProceedException(javax.naming.CannotProceedException) Reference(javax.naming.Reference) ResolveResult(javax.naming.spi.ResolveResult) CompositeName(javax.naming.CompositeName) Name(javax.naming.Name) LinkRef(javax.naming.LinkRef)

Aggregations

ResolveResult (javax.naming.spi.ResolveResult)31 CompositeName (javax.naming.CompositeName)2 Context (javax.naming.Context)2 Name (javax.naming.Name)2 Reference (javax.naming.Reference)2 LdapURL (com.sun.jndi.ldap.LdapURL)1 RegistryContext (com.sun.jndi.rmi.registry.RegistryContext)1 GenericURLContext (com.sun.jndi.toolkit.url.GenericURLContext)1 CannotProceedException (javax.naming.CannotProceedException)1 InitialContext (javax.naming.InitialContext)1 LinkRef (javax.naming.LinkRef)1 NameNotFoundException (javax.naming.NameNotFoundException)1 EventContext (javax.naming.event.EventContext)1 Resolver (javax.naming.spi.Resolver)1 ServiceName (org.jboss.msc.service.ServiceName)1 Test (org.junit.Test)1