HelloImpl.java

 


 /*
  *
  * 
  */
 
 
 package toejb;
 
 import javax.naming.Context;
 import javax.naming.InitialContext;
 import javax.rmi.PortableRemoteObject;
 import toejb.greeting.GreetingHome;
 import toejb.greeting.Greeting;
 
 public class HelloImpl implements HelloIF {
 
     public String sayHello String(name) {
 
         String result = null;
 
         try {
             Context initial = new InitialContext();
             Context myEnv = (Context)initial.lookup("java:comp/env");
             Object objref = myEnv.lookup("ejb/SimpleGreeting");
  
             GreetingHome home = 
                 (GreetingHome)PortableRemoteObject.narrow(objref, 
                                              GreetingHome.class);
  
             Greeting salutation = home.create();
             result = salutation.sayHey(name);
  
         } catch  Exception(ex) {
             System.out.println("Exception in sayHello: " + ex.getMessage());
         }
 
         return result;
 
     } // sayHello
 
 } // HelloImpl