use of org.apache.openejb.client.NameClassPairEnumeration in project tomee by apache.
the class JndiRequestHandler method doList.
private void doList(final JNDIRequest req, final JNDIResponse res, final String prefix) {
final String name = req.getRequestString();
try {
final NamingEnumeration<NameClassPair> namingEnumeration = rootContext.list(prefix + name);
if (namingEnumeration == null) {
res.setResponseCode(ResponseCodes.JNDI_OK);
res.setResult(null);
} else {
res.setResponseCode(ResponseCodes.JNDI_ENUMERATION);
final ArrayList<NameClassPair> list = Collections.list(namingEnumeration);
for (final NameClassPair pair : list) {
if (pair.getClassName().equals(IvmContext.class.getName())) {
pair.setClassName(javax.naming.Context.class.getName());
}
}
res.setResult(new NameClassPairEnumeration(list));
}
} catch (NameNotFoundException e) {
res.setResponseCode(ResponseCodes.JNDI_NOT_FOUND);
} catch (NamingException e) {
res.setResponseCode(ResponseCodes.JNDI_NAMING_EXCEPTION);
res.setResult(new ThrowableArtifact(e));
}
}
Aggregations