Incubator AltRMI

the Incubator site
 
   

Client-side Usage

printer
print-friendly
PDF

by Paul Hammant

Introduction

On the client you can choose to use JNDI or AltRMI's own clases to lookup a remote interface.

JNDI

If you are using Ant for builds, then you can use the 'altrmiproxies' taskdef to make proxies in advance of use.


Hashtable env = new Hashtable();
env.put(
    Context.INITIAL_CONTEXT_FACTORY,
    "org.apache.altrmi.client.impl.naming.DefaultInitialContextFactory");
env.put(Context.PROVIDER_URL, "altrmi://somehost:1235/SocketCustomStream");
Context ctx = new InitialContext(env);
TestInterface ti = (TestInterface) ctx.lookup("Hello");

Custom AltRMI lookup

Directly using AltRMI classes, you can lookup the same interface.


Factory factory = new ClientSideClassFactory(false);
factory.setHostContext(new SocketCustomStreamHostContext("somehost", 1235));
TestInterface ti = (TestInterface) af.lookup("Hello");