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); } }
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);
/** * Remove leading or trailing empty components from * name. Eg "/comp/env/" -> "comp/env" * * @param name the name to normalize * @return normalized name */ public Name toCanonicalName (Name name) { Name canonicalName = name; if (name != null) { if (canonicalName.size() > 1) { if (canonicalName.get(0).equals("")) canonicalName = canonicalName.getSuffix(1); if (canonicalName.get(canonicalName.size()-1).equals("")) canonicalName = canonicalName.getPrefix(canonicalName.size()-1); } } return canonicalName; }
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); }
/** * Remove leading or trailing empty components from * name. Eg "/comp/env/" -> "comp/env" * * @param name the name to normalize * @return normalized name */ public Name toCanonicalName (Name name) { Name canonicalName = name; if (name != null) { if (canonicalName.size() > 1) { if (canonicalName.get(0).equals("")) canonicalName = canonicalName.getSuffix(1); if (canonicalName.get(canonicalName.size()-1).equals("")) canonicalName = canonicalName.getPrefix(canonicalName.size()-1); } } return canonicalName; }
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); }
public Object lookup(Name name) throws NamingException { if (name.size() == 1) return this; if (name.size() > 1) { /* recurse */ /* 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.lookup(descendant); } throw new NamingException( "Number of components in name is negative ?????"); }
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",
/** * Remove leading or trailing empty components from * name. Eg "/comp/env/" -> "comp/env" * * @param name the name to normalize * @return normalized name */ public Name toCanonicalName (Name name) { Name canonicalName = name; if (name != null) { if (canonicalName.size() > 1) { if (canonicalName.get(0).equals("")) canonicalName = canonicalName.getSuffix(1); if (canonicalName.get(canonicalName.size()-1).equals("")) canonicalName = canonicalName.getPrefix(canonicalName.size()-1); } } return canonicalName; }
/** {@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()); } }
private String extractSlice(String nameAsString, NameParser nameParser, int startIndex, int endIndex) throws NamingException { int startI = startIndex; int endI = endIndex; Name name = nameParser.parse(nameAsString); if (startI < 0) { startI = name.size() + startI; } if (endI < 0) { endI = name.size() + endI; } return name.getPrefix(endI).getSuffix(startI).toString(); } }
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 {
/** * Remove leading or trailing empty components from * name. Eg "/comp/env/" -> "comp/env" * * @param name the name to normalize * @return normalized name */ public Name toCanonicalName (Name name) { Name canonicalName = name; if (name != null) { if (canonicalName.size() > 1) { if (canonicalName.get(0).equals("")) canonicalName = canonicalName.getSuffix(1); if (canonicalName.get(canonicalName.size()-1).equals("")) canonicalName = canonicalName.getPrefix(canonicalName.size()-1); } } return canonicalName; }
/** {@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));