use of org.jboss.as.naming.JndiViewManagedReferenceFactory in project wildfly by wildfly.
the class JndiViewOperation method addEntries.
private void addEntries(final ModelNode current, final Context context) throws NamingException {
final NamingEnumeration<NameClassPair> entries = context.list("");
while (entries.hasMore()) {
final NameClassPair pair = entries.next();
final ModelNode node = current.get(pair.getName());
node.get("class-name").set(pair.getClassName());
try {
final Object value;
if (context instanceof NamingContext) {
value = ((NamingContext) context).lookup(pair.getName(), false);
} else {
value = context.lookup(pair.getName());
}
if (value instanceof Context) {
addEntries(node.get("children"), Context.class.cast(value));
} else if (value instanceof Reference) {
//node.get("value").set(value.toString());
} else {
String jndiViewValue = JndiViewManagedReferenceFactory.DEFAULT_JNDI_VIEW_INSTANCE_VALUE;
if (value instanceof JndiViewManagedReferenceFactory) {
try {
jndiViewValue = JndiViewManagedReferenceFactory.class.cast(value).getJndiViewInstanceValue();
} catch (Throwable e) {
// just log, don't stop the operation
NamingLogger.ROOT_LOGGER.failedToLookupJndiViewValue(pair.getName(), e);
}
} else if (!(value instanceof ManagedReferenceFactory)) {
jndiViewValue = String.valueOf(value);
}
node.get("value").set(jndiViewValue);
}
} catch (NamingException e) {
// just log, don't stop the operation
NamingLogger.ROOT_LOGGER.failedToLookupJndiViewValue(pair.getName(), e);
}
}
}
Aggregations