Refine search
/** * Rebind val to name in ctx, and make sure that all intermediate contexts exist * * @param ctx the parent JNDI Context under which value will be bound * @param name the name relative to ctx where value will be bound * @param value the value to bind. * @throws NamingException for any error */ public static void rebind(final Context ctx, final Name name, final Object value) throws NamingException { final int size = name.size(); final String atom = name.get(size - 1); final Context parentCtx = createSubcontext(ctx, name.getPrefix(size - 1)); parentCtx.rebind(atom, value); }
protected Object foundReferenceInsteadOfContext(final BindingNode bindingNode) throws NamingException { final Name remainingName = targetName.getSuffix(bindingNode.fullName.size()); final Object boundObject = bindingNode.binding.getObject(); checkReferenceForContinuation(remainingName, boundObject); return new ResolveResult(boundObject, remainingName); } }
remaining = name; } else { final String first = name.get(0); if (first.startsWith("java:")) { final String theRest = first.substring(5); namespace = null; remaining = getNameParser(theRest).parse(theRest); } else if (theRest.equals("jboss") && name.size() > 1 && name.get(1).equals("exported")) { namespace = "jboss/exported"; remaining = name.getSuffix(2); } else { namespace = theRest; remaining = name.getSuffix(1);
public Attributes getAttributes(Name name) throws NamingException { if (name.size() <= 1) return this.attributes; /* find context */ Name child = name.getPrefix(2).getSuffix(1); Name descendant = name.getSuffix(1); DirContext ctx = (DirContext) children.get(child); if (ctx == null) throw new NamingException("Cannot resolve name " + name); return ctx.getAttributes(descendant); }
public static void unbind(Context ctx, String strName) throws NamingException { Name name = ctx.getNameParser("").parse(strName); int size = name.size(); String atom = name.get(size - 1); Context parentCtx = Util.createSubcontext(ctx, name.getPrefix(size - 1)); String key = parentCtx.getNameInNamespace() + "/" + atom; wrapperMap.remove(key); Util.unbind(ctx, strName); }
checkIsDestroyed(); Name parsedName = getParsedName(name); if (parsedName.size() == 0 || parsedName.get(0).length() == 0) { throw new InvalidNameException( "Name can not be empty!"); String nameToBind = parsedName.get(0); if (parsedName.size() == 1) { ctxMaps.put(nameToBind, obj); } else { ((Context) boundObject).bind(parsedName.getSuffix(1), obj); } else { if (boundObject == null) { sub.bind(parsedName.getSuffix(1), obj); } else { throw new NotContextException(String.format("Expected Context but found %s",
public boolean endsWith(final Name name) { final ArrayList<String> segments = this.segments; final int size = name.size(); final int ourSize = segments.size(); if (size > ourSize) { return false; } final int offs = ourSize - size; for (int i = 0; i < size; i ++) { if (! segments.get(i + offs).equals(name.get(i))) { return false; } } return true; }
/** {@inheritDoc} */ public NamingEnumeration<NameClassPair> list(final Name name) throws NamingException { check(name, JndiPermission.ACTION_LIST); try { return namingEnumeration(namingStore.list(getAbsoluteName(name))); } catch(CannotProceedException cpe) { final Context continuationContext = NamingManager.getContinuationContext(cpe); return continuationContext.list(cpe.getRemainingName()); } catch (RequireResolveException r) { final Object o = lookup(r.getResolve()); if (o instanceof Context) { return ((Context)o).list(name.getSuffix(r.getResolve().size())); } throw notAContextException(r.getResolve()); } }
checkIsDestroyed(); Name parsedName = getParsedName(name); if (parsedName.size() == 0 || parsedName.get(0).length() == 0) { throw new InvalidNameException( "Name can not be empty!"); String nameToRemove = parsedName.get(0); if (parsedName.size() == 1) { ctxMaps.remove(nameToRemove); } else { if (boundObject instanceof Context) { ((Context) boundObject).unbind(parsedName.getSuffix(1)); } else {
/** * Determine if a name is empty, or if ot contains only one component which is the empty string. * * @param name the name * @return {@code true} if the name is empty or contains one empty component */ public static boolean isEmpty(final Name name) { return name.isEmpty() || (name.size() == 1 && "".equals(name.get(0))); }
/** {@inheritDoc} */ public NamingEnumeration<Binding> listBindings(final Name name) throws NamingException { check(name, JndiPermission.ACTION_LIST_BINDINGS); try { return namingEnumeration(namingStore.listBindings(getAbsoluteName(name))); } catch(CannotProceedException cpe) { final Context continuationContext = NamingManager.getContinuationContext(cpe); return continuationContext.listBindings(cpe.getRemainingName()); } catch (RequireResolveException r) { final Object o = lookup(r.getResolve()); if (o instanceof Context) { return ((Context)o).listBindings(name.getSuffix(r.getResolve().size())); } throw notAContextException(r.getResolve()); } }
checkIsDestroyed(); Name parsedName = getParsedName(name); if (parsedName.size() == 0) { Vector bindings = new Vector(); Iterator iterat = ctxMaps.keySet().iterator(); Object subContext = ctxMaps.get(parsedName.get(0)); if (subContext instanceof Context) { Name nextLayer = nameParser.parse(""); if (parsedName.size() > 1) { nextLayer = parsedName.getSuffix(1); if (subContext == null && !ctxMaps.containsKey(parsedName.get(0))) { throw new NameNotFoundException( String.format("Name %s not found", name));
public SimpleName addAll(final int pos, final Name name) { if (name instanceof SimpleName) { segments.addAll(pos, ((SimpleName) name).segments); return this; } final ArrayList<String> segments = this.segments; final int size = name.size(); final int ourSize = segments.size(); segments.ensureCapacity(ourSize + size); for (int i = 0; i < size; i ++) { add(pos + i, name.get(i)); } return this; }
/** * Get leaf name component from specified Name object. * * @param name the name to retrieve leaf from * @return the leaf name component * @throws javax.naming.NamingException if an error occurs */ protected Name getLeafName( final Name name ) throws NamingException { return name.getSuffix( name.size() - 1 ); } }
checkIsDestroyed(); Name parsedName = getParsedName(name); if (parsedName.size() == 0 || parsedName.get(0).length() == 0) { throw new InvalidNameException( "Name can not be empty!"); String subContextName = parsedName.get(0); Object boundObject = ctxMaps.get(parsedName.get(0)); if (parsedName.size() == 1) { return ((Context) boundObject).createSubcontext(parsedName.getSuffix(1)); } else { throw new NotContextException(String.format("Expected Context but found %s",
public SimpleName addAll(final Name suffix) { if (suffix instanceof SimpleName) { segments.addAll(((SimpleName) suffix).segments); return this; } final ArrayList<String> segments = this.segments; final int size = suffix.size(); final int ourSize = segments.size(); segments.ensureCapacity(ourSize + size); for (int i = 0; i < size; i ++) { add(suffix.get(i)); } return this; }