summaryrefslogtreecommitdiffstats
path: root/Master/Reference Architectures and Patterns/EJB 3.0 Code/Gerald Examples/src/examples/jndi/Startup.java
blob: c6e9afa1281134677aeb20c475d79189d9798d2c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package examples.jndi;
import javax.naming.*;

/**
 * A helper class which starts our RMI-IIOP server
 */
public class Startup { 

     /**
      * Our main() method starts things up
      */
     public static void main(String args[]) throws Exception { 

          /*
           * Start up our PKGenerator remote object.  It will
           * automatically export itself.
           */
          PrimaryKeyGenerator generator = new PrimaryKeyGeneratorImpl();

          /*
           * Bind our PKGenerator remote object to the JNDI tree
           */
          Context ctx = new InitialContext(System.getProperties());
          ctx.rebind("PKGenerator", generator);
          System.out.println("PKGenerator bound to JNDI tree.");

          // wait for clients
          synchronized (generator) { 
            generator.wait();
          } 
     } 
}