JNDI

JNDI is a standard Java API that is bundled with JDK1.3 and higher. JNDI provides a common interface to a variety of existing naming services: DNS, LDAP, Active Directory, RMI registry, COS registry, NIS, and file systems.

http://docs.jboss.org/jbossas/jboss4guide/r1/html/ch3.chapter.html

http://stackoverflow.com/questions/13643127/how-does-the-ejb-client-locate-the-ejb-server-without-url

Sample

Properties:

File test/Client.java

   1 package test;
   2 import java.security.Security;
   3 import java.util.Properties;
   4 import javax.naming.Context;
   5 import javax.naming.InitialContext;
   6 import org.allowed.bitarus.IWSTest;
   7                     
   8 public class Client
   9 {
  10     public static void main(String args[]) throws Exception
  11     {
  12         Properties env = new Properties();
  13         env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
  14         env.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");
  15         env.put(Context.PROVIDER_URL, "jnp://127.0.0.1:1099");
  16         InitialContext context = new InitialContext(env);
  17         IWSTest test = (IWSTest) context.lookup("WSTest/remote");
  18         System.out.println( test.helloWorld() );
  19     }
  20 }

Build:

Run:

Java/JNDI (last edited 2014-06-10 21:50:17 by 95)