1 import javax.naming.InitialContext;
   2 import javax.naming.Context;
   3 
   4 public class HelloServer {
   5 
   6     static final int MAX_RETRY = 10;
   7     static final int ONE_SECOND = 1000;
   8 
   9     public static void main(String[] args) {
  10         int retryCount = 0;
  11         while (retryCount < MAX_RETRY) {
  12             try {
  13                 //HelloServer.set("SETTING TEST ITL");
  14                 // Step 1: Instantiate the Hello servant
  15                 HelloImpl helloRef = new HelloImpl();
  16 
  17                 // Step 2: Publish the reference in the Naming Service
  18                 // using JNDI API
  19                 Context initialNamingContext = new InitialContext();
  20                 initialNamingContext.rebind("HelloService", helloRef);
  21 
  22                 System.out.println("Hello Server: Ready...");
  23                 break;
  24             } catch (Exception e) {
  25                 System.out.println("Server initialization problem: " + e);
  26                 e.printStackTrace();
  27                 retryCount++;
  28                 try {
  29                     Thread.sleep(ONE_SECOND);
  30                 } catch (InterruptedException e1) {
  31                     e1.printStackTrace();
  32                 }
  33             }
  34         }
  35     }
  36 }