1 23 package enterprise.lottery_annotation_client; 24 25 import javax.naming.InitialContext ; 26 27 import enterprise.lottery_annotation_ejb_stateful.Lottery; 28 import enterprise.lottery_annotation_ejb_stateless.Dice; 29 30 public class JavaClient { 31 32 public static void main(String args[]) { 33 34 try { 35 36 InitialContext ic = new InitialContext (); 37 38 Lottery lottery = 39 (Lottery) ic.lookup("enterprise.lottery_annotation_ejb_stateful.Lottery"); 40 41 Dice dice; 42 for(int i=0; i<5; i++) { 43 dice = 44 (Dice) ic.lookup("enterprise.lottery_annotation_ejb_stateless.Dice"); 45 lottery.select(dice.play()); 46 } 47 48 String lotteryName = lottery.getName(); 49 String lotteryNumber = lottery.getNumber(); 50 String lotteryDate = lottery.getDate(); 51 52 String results = "Your" + " " + lotteryName + " " + 53 "quick pick, played on" + " " + lotteryDate + 54 " " + "is" + " " + lotteryNumber; 55 56 System.out.println(results); 57 58 } catch(Exception e) { 59 System.out.println("Exception: " + e); 60 e.printStackTrace(); 61 } 62 63 } 64 65 } 66 | Popular Tags |