use of org.eclipse.jetty.jndi.BindingEnumeration in project jetty.project by eclipse.
the class localContextRoot method listBindings.
/**
*
*
* @see javax.naming.Context#listBindings(javax.naming.Name)
*/
public NamingEnumeration listBindings(Name name) throws NamingException {
synchronized (__root) {
//return __root.listBindings(getSuffix(name));
Name cname = __root.toCanonicalName(name);
if (cname == null) {
List<Binding> empty = Collections.emptyList();
return new BindingEnumeration(empty.iterator());
}
if (cname.size() == 0) {
return new BindingEnumeration(__root.getBindings().values().iterator());
}
//multipart name
String firstComponent = cname.get(0);
Object ctx = null;
//at this level in the tree
if (firstComponent.equals(""))
ctx = this;
else {
//it is a non-empty name component
Binding binding = __root.getBinding(firstComponent);
if (binding == null)
throw new NameNotFoundException();
ctx = binding.getObject();
if (ctx instanceof Reference) {
//deference the object
try {
ctx = NamingManager.getObjectInstance(ctx, getNameParser("").parse(firstComponent), __root, _env);
} catch (NamingException e) {
throw e;
} catch (Exception e) {
__log.warn("", e);
throw new NamingException(e.getMessage());
}
}
}
if (!(ctx instanceof Context))
throw new NotContextException();
return ((Context) ctx).listBindings(cname.getSuffix(1));
}
}
Aggregations