1 package org.objectweb.jonas.jtests.beans.ejbql; 2 3 import java.util.Collection ; 4 5 import javax.ejb.CreateException ; 6 import javax.ejb.EntityContext ; 7 import javax.ejb.FinderException ; 8 import javax.ejb.RemoveException ; 9 import javax.naming.InitialContext ; 10 11 public abstract class CruiseBean implements javax.ejb.EntityBean { 12 13 private SequenceSessionLocalHome seqHome = null; 14 private SequenceSessionLocal seqLocal = null; 15 private ShipHomeLocal shipHome = null; 16 17 public Integer ejbCreate(String name,Integer ship) throws CreateException { 18 setName(name); 19 int id = seqLocal.getNextNumberInSequence("Cruise"); 20 setId(new Integer (id)); 21 return null; 22 } 23 24 public void ejbPostCreate(String name, Integer ship) { 25 try { 26 ShipLocal shiploc = shipHome.findByPrimaryKey(ship); 27 setShip(shiploc); 28 } catch (FinderException e) { 29 System.out.println("Ship not found during Cruise creation :"+ship); 30 } 31 } 32 33 35 public abstract void setId(Integer id); 36 public abstract Integer getId(); 37 public abstract void setName(String name); 38 public abstract String getName( ); 39 40 public abstract void setShip(ShipLocal ship); 41 public abstract ShipLocal getShip( ); 42 43 45 public abstract void setReservations(Collection res); 46 public abstract Collection getReservations( ); 47 48 50 public void setEntityContext(EntityContext ec){ 51 try { 52 InitialContext cntx = new InitialContext ( ); 53 SequenceSessionLocalHome seqHome = 54 (SequenceSessionLocalHome)cntx.lookup("java:comp/env/ejb/SequenceSessionLocalHome"); 55 shipHome = 56 (ShipHomeLocal)cntx.lookup("java:comp/env/ejb/ShipLocalHome"); 57 58 seqLocal = seqHome.create(); 59 } catch(Exception e) { 60 throw new javax.ejb.EJBException (e); 61 } 62 } 63 64 public void unsetEntityContext(){} 65 public void ejbLoad(){} 66 public void ejbStore(){} 67 public void ejbActivate(){} 68 public void ejbPassivate(){} 69 public void ejbRemove() throws RemoveException {} 70 71 } 72 | Popular Tags |