Thursday, January 09, 2003

An Example Using NamingEnumeration to Find JBOSS JNDI Names

  Hashtable ht = new Hashtable();
  ht.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
  ht.put(Context.PROVIDER_URL, "localhost");
  ht.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces" );
  Context lContext = new InitialContext(ht);
  String a = "java:/";
  NamingEnumeration ne = lContext.list(a);
  while (ne.hasMore()) {
    System.out.println("A: " + ne.next().toString());
  }
Post a Comment