1 25 26 package org.objectweb.jonas.jtests.beans.relation.cascade; 27 28 import java.rmi.RemoteException ; 29 import javax.ejb.CreateException ; 30 import javax.ejb.EntityContext ; 31 import javax.ejb.EntityBean ; 32 import javax.ejb.RemoveException ; 33 34 import org.objectweb.jonas.common.Log; 35 import org.objectweb.util.monolog.api.BasicLevel; 36 import org.objectweb.util.monolog.api.Logger; 37 38 42 public abstract class InsuranceBean implements EntityBean { 43 44 static protected Logger logger = null; 45 protected EntityContext ejbContext = null; 46 47 public Integer ejbCreate(String number) throws CreateException { 48 logger.log(BasicLevel.DEBUG, ""); 49 setNumber(number); 50 return null; 51 } 52 53 public void ejbPostCreate(String number) { 54 logger.log(BasicLevel.DEBUG, ""); 55 } 56 57 public abstract Integer getId(); 59 public abstract void setId(Integer id); 60 public abstract String getNumber(); 61 public abstract void setNumber(String number); 62 63 public abstract CarL getCar(); 65 public abstract void setCar(CarL car); 66 67 68 public void setEntityContext(EntityContext ec) { 69 if (logger == null) 70 logger = Log.getLogger(Log.JONAS_TESTS_PREFIX); 71 logger.log(BasicLevel.DEBUG, ""); 72 ejbContext = ec; 73 } 74 75 public void unsetEntityContext() { 76 logger.log(BasicLevel.DEBUG, ""); 77 ejbContext = null; 78 } 79 80 public void ejbLoad() { 81 logger.log(BasicLevel.DEBUG, ""); 82 } 83 84 public void ejbStore() { 85 logger.log(BasicLevel.DEBUG, ""); 86 } 87 88 public void ejbActivate() { 89 logger.log(BasicLevel.DEBUG, ""); 90 } 91 92 public void ejbPassivate() { 93 logger.log(BasicLevel.DEBUG, ""); 94 } 95 96 100 public void ejbRemove() throws javax.ejb.RemoveException { 101 logger.log(BasicLevel.DEBUG, ""); 102 CarL mycar = getCar(); 103 if (mycar == null) { 104 logger.log(BasicLevel.ERROR, "CMR field is null"); 105 throw new RemoveException ("Cannot access CMR field inside ejbRemove"); 106 } 107 String carnumber = mycar.getNumber(); 108 if (! getNumber().equals("000" + carnumber)) { 109 throw new RemoveException ("Bad car number while removing Insurance:" + carnumber); 110 } 111 CustomerL cust = mycar.getCustomer(); 112 if (cust == null) { 113 logger.log(BasicLevel.ERROR, "Cannot get customer from insurance"); 114 throw new RemoveException ("Cannot get customer from insurance"); 115 } 116 } 117 } 118 | Popular Tags |