public List<Binding> listBindings(final Name name) throws NamingException {
   final ServiceName lookupName = buildServiceName(name);
   final ServiceName floor = boundServices.floor(lookupName);
   if (floor != null && floor.isParentOf(lookupName)) {
     // Parent might be a reference or a link
     Object obj = lookup(name.toString(), floor);
     if (obj != null) throw new RequireResolveException(convert(floor));
   }
   final List<ServiceName> children = listChildren(lookupName);
   final String[] lookupParts = lookupName.toArray();
   final Set<String> childContexts = new HashSet<String>();
   final List<Binding> results = new ArrayList<Binding>();
   for (ServiceName child : children) {
     final String[] childParts = child.toArray();
     if (childParts.length > lookupParts.length + 1) {
       childContexts.add(childParts[lookupParts.length]);
     } else {
       final Object binding = lookup(name.toString(), child);
       results.add(new Binding(childParts[childParts.length - 1], binding));
     }
   }
   for (String contextName : childContexts) {
     results.add(
         new Binding(
             contextName, new NamingContext(((Name) name.clone()).add(contextName), this, null)));
   }
   return results;
 }
 private static ServiceName getCacheServiceName(String cacheName) {
   ServiceName baseServiceName =
       CacheContainerServiceName.CACHE_CONTAINER
           .getServiceName(DEFAULT_CACHE_CONTAINER)
           .getParent();
   ServiceName serviceName =
       ServiceName.parse((cacheName != null) ? cacheName : DEFAULT_CACHE_CONTAINER);
   if (!baseServiceName.isParentOf(serviceName)) {
     serviceName = baseServiceName.append(serviceName);
   }
   return (serviceName.length() < 4)
       ? serviceName.append(SubGroupServiceNameFactory.DEFAULT_SUB_GROUP)
       : serviceName;
 }
  public Object lookup(final Name name) throws NamingException {
    if (name.isEmpty()) {
      return new NamingContext(EMPTY_NAME, this, null);
    }
    final ServiceName lookupName = buildServiceName(name);
    Object obj = lookup(name.toString(), lookupName);
    if (obj == null) {
      final ServiceName lower = boundServices.lower(lookupName);
      if (lower != null && lower.isParentOf(lookupName)) {
        // Parent might be a reference or a link
        obj = lookup(name.toString(), lower);
        checkReferenceForContinuation(name, obj);
        return new ResolveResult(obj, suffix(lower, lookupName));
      }

      final ServiceName ceiling = boundServices.ceiling(lookupName);
      if (ceiling != null && lookupName.isParentOf(ceiling)) {
        return new NamingContext((Name) name.clone(), this, null);
      }
      throw new NameNotFoundException(name.toString() + " -- " + lookupName);
    }

    return obj;
  }
 private List<ServiceName> listChildren(final ServiceName name) throws NamingException {
   final ConcurrentSkipListSet<ServiceName> boundServices = this.boundServices;
   if (boundServices.contains(name)) {
     throw MESSAGES.cannotListNonContextBinding();
   }
   final NavigableSet<ServiceName> tail = boundServices.tailSet(name);
   final List<ServiceName> children = new ArrayList<ServiceName>();
   for (ServiceName next : tail) {
     if (name.isParentOf(next)) {
       children.add(next);
     } else {
       break;
     }
   }
   return children;
 }