1 27 28 package timerclient; 29 30 import javax.naming.Context ; 31 import javax.naming.InitialContext ; 32 import javax.rmi.PortableRemoteObject ; 33 import timer.TimerSessionRemote; 34 import timer.TimerSessionRemoteHome; 35 36 40 public class Main { 41 42 43 public Main() { 44 } 45 46 49 public static void main(String [] args) { 50 try { 51 Context initial = new InitialContext (); 52 Object objref = 53 initial.lookup("ejb/TimerSessionBean"); 54 TimerSessionRemoteHome home = 55 (TimerSessionRemoteHome) PortableRemoteObject.narrow(objref, 56 TimerSessionRemoteHome.class); 57 58 TimerSessionRemote timerSession = home.create(); 59 long intervalDuration = 30000; 60 61 System.out.println("Creating a timer with an interval duration of " + 62 intervalDuration + " ms."); 63 timerSession.myCreateTimer(intervalDuration); 64 timerSession.remove(); 65 66 System.exit(0); 67 } catch (Exception ex) { 68 System.err.println("Caught an unexpected exception!"); 69 ex.printStackTrace(); 70 System.exit(1); 71 } 72 } 73 74 } 75 | Popular Tags |