summaryrefslogtreecommitdiffstats
path: root/Master/Reference Architectures and Patterns/EJB 3.0 Code/Gerald Examples/src/examples/jndi/Client.java
blob: 1500a48b24a8bb92f7cbba11bb013497ea025ebe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
package examples.jndi;

import javax.naming.*;
import javax.rmi.*;

public class Client { 

     public static void main (String[] args) throws Exception { 

          // Lookup the remote object via JNDI
          Context ctx = new InitialContext(System.getProperties());
          Object remoteObject = ctx.lookup("PKGenerator");

          // Cast the remote object, RMI-IIOP style
          PrimaryKeyGenerator generator = (PrimaryKeyGenerator)
               PortableRemoteObject.narrow(
                    remoteObject, PrimaryKeyGenerator.class);

          // Generate a PK by calling the RMI-IIOP stub
          System.out.println(generator.generate());
     } 
}