use of org.apache.naming.NamingContextEnumeration in project tomcat70 by apache.
the class BaseDirContext method list.
/**
* Enumerates the names bound in the named context, along with the class
* names of objects bound to them.
*
* @param name the name of the context to list
* @return an enumeration of the names and class names of the bindings in
* this context. Each element of the enumeration is of type NameClassPair.
* @exception NamingException if a naming exception is encountered
*/
@Override
public NamingEnumeration<NameClassPair> list(String name) throws NamingException {
if (!aliases.isEmpty()) {
AliasResult result = findAlias(name);
if (result.dirContext != null) {
return result.dirContext.list(result.aliasName);
}
}
// Next do a standard lookup
List<NamingEntry> bindings = doListBindings(name);
// Check the alternate locations
List<NamingEntry> altBindings = null;
String resourceName = "/META-INF/resources" + name;
for (DirContext altDirContext : altDirContexts) {
if (altDirContext instanceof BaseDirContext) {
altBindings = ((BaseDirContext) altDirContext).doListBindings(resourceName);
}
if (altBindings != null) {
if (bindings == null) {
bindings = altBindings;
} else {
bindings.addAll(altBindings);
}
}
}
if (bindings != null) {
return new NamingContextEnumeration(bindings.iterator());
}
// Really not found
throw new NameNotFoundException(sm.getString("resources.notFound", name));
}
use of org.apache.naming.NamingContextEnumeration in project Payara by payara.
the class WebDirContext method list.
/**
* Enumerates the names bound in the named context, along with the class
* names of objects bound to them. The contents of any subcontexts are
* not included.
* <p>
* If a binding is added to or removed from this context, its effect on
* an enumeration previously returned is undefined.
*
* @param name the name of the context to list
* @return an enumeration of the names and class names of the bindings in
* this context. Each element of the enumeration is of type NameClassPair.
* @exception NamingException if a naming exception is encountered
*/
@Override
public NamingEnumeration<NameClassPair> list(String name) throws NamingException {
List<NamingEntry> namingEntries = null;
File file = file(name, true);
if (file != null) {
namingEntries = list(file);
}
List<JarFileEntry> jfeEntries = lookupAllFromJars(name);
for (JarFileEntry jfeEntry : jfeEntries) {
List<NamingEntry> jfList = list(jfeEntry);
if (namingEntries != null) {
namingEntries.addAll(jfList);
} else {
namingEntries = jfList;
}
}
if (file == null && jfeEntries.size() == 0) {
throw new NamingException(MessageFormat.format(rb.getString(LogFacade.RESOURCES_NOT_FOUND), name));
}
return new NamingContextEnumeration(namingEntries.iterator());
}
Aggregations