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); }
private Name getAbsoluteName(final Name name) throws NamingException { if(name.isEmpty()) { return composeName(name, prefix); } final String firstComponent = name.get(0); if(firstComponent.startsWith("java:")) { final String cleaned = firstComponent.substring(5); final Name suffix = name.getSuffix(1); if(cleaned.isEmpty()) { return suffix; } return suffix.add(0, cleaned); } else if(firstComponent.isEmpty()) { return name.getSuffix(1); } else { return composeName(name, prefix); } }
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);
/** Bind 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 bind(Context ctx, Name name, Object value) throws NamingException { int size = name.size(); String atom = name.get(size - 1); Context parentCtx = createSubcontext(ctx, name.getPrefix(size - 1)); parentCtx.bind(atom, value); }
public final T visit(final ContextNode contextNode) throws NamingException { if (isEmpty(currentName)) { return found(contextNode); } final String childName = currentName.get(0); traversedName.add(childName); currentName = currentName.getSuffix(1); final TreeNode node = contextNode.children.get(childName); if (node == null) { if (createIfMissing) { final NamingContext subContext = new NamingContext((Name)traversedName.clone(), InMemoryNamingStore.this, new Hashtable<String, Object>()); return contextNode.addOrGetChild(childName, new ContextNode(contextNode, childName, (Name)traversedName.clone(), subContext)).accept(this); } else { throw nameNotFoundException(childName, contextNode.fullName); } } return node.accept(this); }
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; }
/** 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(Context ctx, Name name, Object value) throws NamingException { int size = name.size(); String atom = name.get(size - 1); Context parentCtx = createSubcontext(ctx, name.getPrefix(size - 1)); parentCtx.rebind(atom, value); }
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))); }
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 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; }
/** * Get name without the url prefix. * @param name the absolute name. * @return the relative name (without prefix). * @throws NamingException if the naming failed. */ private Name getRelativeName(Name name) throws NamingException { if (name.get(0).equals(URL_PREFIX)) { return (name.getSuffix(1)); } else { TraceCarol.error("relative name! :" + name); throw new NameNotFoundException("Invalid name:" + name); } }
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));