protected void createMBeans(String prefix,
Context context) throws NamingException {
if (log.isDebugEnabled()) {
log.debug("Creating MBeans for Global JNDI Resources in Context '" +
prefix + "'");
}
try {
NamingEnumeration bindings = context.listBindings("");
while (bindings.hasMore()) {
Binding binding = (Binding) bindings.next();
String name = prefix + binding.getName();
Object value = context.lookup(binding.getName());
if (log.isDebugEnabled()) {
log.debug("Checking resource " + name);
}
if (value instanceof Context) {
createMBeans(name + "/", (Context) value);
} else if (value instanceof UserDatabase) {
try {
createMBeans(name, (UserDatabase) value);
} catch (Exception e) {
log.error("Exception creating UserDatabase MBeans for " + name,
e);
}
}
}
} catch( RuntimeException ex) {
log.error("RuntimeException " + ex);
} catch( OperationNotSupportedException ex) {
log.error("Operation not supported " + ex);
}
}
Create the MBeans for the interesting global JNDI resources in
the specified naming context. |