use of org.apache.naming.NamingContextBindingsEnumeration in project Payara by payara.
the class WebDirContext method listBindings.
/**
* Enumerates the names bound in the named context, along with the
* 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 bindings in this context.
* Each element of the enumeration is of type Binding.
* @exception NamingException if a naming exception is encountered
*/
@Override
public NamingEnumeration<Binding> listBindings(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> jfeList = list(jfeEntry);
if (namingEntries != null) {
namingEntries.addAll(jfeList);
} else {
namingEntries = jfeList;
}
}
if (file == null && jfeEntries.size() == 0) {
throw new NamingException(MessageFormat.format(rb.getString(LogFacade.RESOURCES_NOT_FOUND), name));
}
return new NamingContextBindingsEnumeration(namingEntries.iterator(), this);
}
use of org.apache.naming.NamingContextBindingsEnumeration in project tomcat70 by apache.
the class BaseDirContext method listBindings.
/**
* Enumerates the names bound in the named context, along with the
* objects bound to them.
*
* @param name the name of the context to list
* @return an enumeration of the bindings in this context.
* Each element of the enumeration is of type Binding.
* @exception NamingException if a naming exception is encountered
*/
@Override
public final NamingEnumeration<Binding> listBindings(String name) throws NamingException {
if (!aliases.isEmpty()) {
AliasResult result = findAlias(name);
if (result.dirContext != null) {
return result.dirContext.listBindings(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 NamingContextBindingsEnumeration(bindings.iterator(), this);
}
// Really not found
throw new NameNotFoundException(sm.getString("resources.notFound", name));
}
Aggregations