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;
 }
Example #2
0
  /**
   * Join two names together. These are treated as CompoundNames.
   *
   * @param name a <code>Name</code> value
   * @param prefix a <code>Name</code> value
   * @return a <code>Name</code> value
   * @exception NamingException if an error occurs
   */
  public Name composeName(Name name, Name prefix) throws NamingException {
    if (name == null) throw new NamingException("Name cannot be null");
    if (prefix == null) throw new NamingException("Prefix cannot be null");

    Name compoundName = (CompoundName) prefix.clone();
    compoundName.addAll(name);
    return compoundName;
  }
  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;
  }
 public Name composeName(Name name, Name prefix) throws NamingException {
   final Name result = (Name) prefix.clone();
   result.addAll(name);
   return result;
 }
Example #5
0
 @Override
 public Name composeName(Name name, Name prefix) throws NamingException {
   Name result = (Name) (prefix.clone());
   result.addAll(name);
   return result;
 }
Example #6
0
 public void setRemainingName(Name name)
 {
   remainingName = (Name) name.clone();
 }
 /**
  * Composes the name of this context with a name relative to this context.
  *
  * <p>Given a name (name) relative to this context, and the name (prefix) of this context relative
  * to one of its ancestors, this method returns the composition of the two names using the syntax
  * appropriate for the naming system(s) involved. That is, if name names an object relative to
  * this context, the result is the name of the same object, but relative to the ancestor context.
  * None of the names may be null.
  *
  * @param name a name relative to this context
  * @param prefix the name of this context relative to one of its ancestors
  * @return the composition of prefix and name
  * @exception NamingException if a naming exception is encountered
  */
 @Override
 public Name composeName(Name name, Name prefix) throws NamingException {
   prefix = (Name) prefix.clone();
   return prefix.addAll(name);
 }
Example #8
0
 /** {@inheritDoc} */
 public Name composeName(Name name, Name prefix) throws NamingException {
   Name newName = (Name) prefix.clone();
   return newName.addAll(name);
 }