Ejemplo n.º 1
0
 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;
 }
Ejemplo n.º 2
0
  private Name suffix(ServiceName parent, ServiceName child) {
    String[] p = parent.toArray();
    String[] c = child.toArray();

    CompositeName name = new CompositeName();
    for (int i = p.length; i < c.length; i++) {
      try {
        name.add(c[i]);
      } catch (InvalidNameException e) {
        throw new IllegalStateException(e);
      }
    }

    return name;
  }
Ejemplo n.º 3
0
  private Name convert(ServiceName serviceName) {
    String[] c = serviceName.toArray();
    CompositeName name = new CompositeName();
    for (int i = 0; i < c.length; i++) {
      try {
        name.add(c[i]);
      } catch (InvalidNameException e) {
        throw new IllegalStateException(e);
      }
    }

    return name;
  }