Plase help me to distinguise the 2 ways of using RMI
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Tri_Ngo
Posted On:   Wednesday, September 24, 2008 06:34 AM

The first way, I usually see is: 1) Create object, interface on Server 2) Create file stub & skeleton 3) Create interface on Client, copy stub file to Client 4) Run rmiregistry.exe 5)... The second way is: Using JNDI 1) Create environment env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.rmi.registry.RegistryContextFactory"); env.put(Context.PROVIDER_URL, "rmi://server:1099"); 2) Create context and lookup object by name Context ic = new InitialContext(env); Object obj = ic.lookup(name) If possible, pls give me step-by-step examp   More>>


The first way, I usually see is:

1) Create object, interface on Server

2) Create file stub & skeleton

3) Create interface on Client, copy stub file to Client

4) Run rmiregistry.exe

5)...



The second way is:

Using JNDI

1) Create environment

env.put(Context.INITIAL_CONTEXT_FACTORY,
"com.sun.jndi.rmi.registry.RegistryContextFactory");

env.put(Context.PROVIDER_URL, "rmi://server:1099");

2) Create context and lookup object by name

Context ic = new InitialContext(env);

Object obj = ic.lookup(name)

If possible, pls give me step-by-step example of using JNDI. I run example of the first way already but can't find the example for the second way.


Thanks    <<Less

Re: Plase help me to distinguise the 2 ways of using RMI

Posted By:   Anonymous  
Posted On:   Wednesday, September 24, 2008 08:38 AM

In the first way you are using the RMIRegistry where in you can use the program with the sun provided rmi registry only i.e. the code that you have written in dependent and not portable.

The second way as you are using the JNDI. The code you have written is independent of the JNDI service "com.sun.jndi.rmi.registry.RegistryContextFactory". In future you can simply change the factory and can use the same program to run with some other JNDI vendor.
About | Sitemap | Contact