List of usage examples for javax.naming Binding toString
public String toString()
From source file:de.micromata.genome.util.runtime.jndi.JndiDumper.java
public static void dumpJndiBinding(InitialContext initialContext, String parentKey, Binding binding, StringBuilder sb, String indent) throws NamingException { try {/*www . j av a 2s . c om*/ Object obj = binding.getObject(); ClassLoader bindClassLoader = obj.getClass().getClassLoader(); sb.append(indent).append(parentKey + "/" + binding.getName()).append("(") .append(System.identityHashCode(binding)).append(", cl: ").append(bindClassLoader).append("): ") .append(binding.toString()); if (obj instanceof Context) { sb.append("\n"); Context ctx = (Context) obj; indent += " "; NamingEnumeration<Binding> bindings = ctx.listBindings(""); while (bindings.hasMore()) { Binding cbinding = bindings.next(); dumpJndiBinding(initialContext, parentKey + "/" + binding.getName(), cbinding, sb, indent); } } else if (obj instanceof Reference) { Reference ref = (Reference) obj; // binding.get // ref. sb.append("\n"); } else if (obj instanceof Session) { Session sess = (Session) obj; sb.append("\n"); } else if (obj instanceof DataSource) { DataSource ds = (DataSource) obj; if (ds instanceof BasicDataSource) { BasicDataSource dbds = (BasicDataSource) ds; sb.append(" '" + dbds.getUrl() + "'"); } sb.append("\n"); } else if (obj != null) { Class<? extends Object> clazz = obj.getClass(); sb.append(" unkown type: " + clazz); sb.append("\n"); } } catch (NamingException ex) { sb.append("Error access binding: " + binding.getName() + ": " + ex.getMessage()); } }