use of org.eclipse.jetty.jndi.NameEnumeration in project jetty.project by eclipse.
the class localContextRoot method list.
/**
*
*
* @see javax.naming.Context#list(javax.naming.Name)
*/
public NamingEnumeration list(Name name) throws NamingException {
synchronized (__root) {
//return __root.list(getSuffix(name));
Name cname = __root.toCanonicalName(name);
if (cname == null) {
List<Binding> empty = Collections.emptyList();
return new NameEnumeration(empty.iterator());
}
if (cname.size() == 0) {
return new NameEnumeration(__root.getBindings().values().iterator());
}
//multipart name
String firstComponent = cname.get(0);
Object ctx = null;
if (firstComponent.equals(""))
ctx = this;
else {
Binding binding = __root.getBinding(firstComponent);
if (binding == null)
throw new NameNotFoundException();
ctx = binding.getObject();
if (ctx instanceof Reference) {
//deference the object
if (__log.isDebugEnabled())
__log.debug("Dereferencing Reference for " + name.get(0));
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).list(cname.getSuffix(1));
}
}
Aggregations