1 25 26 package org.objectweb.jonas.jtests.beans.relation.omb; 27 28 import org.objectweb.util.monolog.api.Logger; 29 import org.objectweb.util.monolog.api.BasicLevel; 30 import org.objectweb.jonas.common.Log; 31 32 import javax.ejb.EntityContext ; 33 import javax.ejb.CreateException ; 34 import javax.ejb.DuplicateKeyException ; 35 import javax.ejb.EJBException ; 36 import javax.ejb.FinderException ; 37 import javax.ejb.RemoveException ; 38 39 import javax.naming.Context ; 40 import javax.naming.InitialContext ; 41 import javax.naming.NamingException ; 42 import javax.rmi.PortableRemoteObject ; 43 44 47 public abstract class BEC2 implements javax.ejb.EntityBean { 48 49 private AHomeLocal ahl = null; 50 51 public void m1() { 52 } 53 54 public void testSetCmrWithDeleted() throws EJBException { 55 logger.log(BasicLevel.DEBUG, ""); 56 ALocal ax9; 57 try { 58 ax9 = ahl.create("ax9"); 59 ax9.remove(); 60 } catch (Exception e) { 61 throw new EJBException ("Initial state creation problem: " + e); 62 } 63 try { 64 this.setA(ax9); 65 throw new EJBException ("entity was not deleted, expected IllegalArgumentException"); 66 } catch (IllegalArgumentException e) { 67 } catch (Exception e) { 69 throw new EJBException ("Caugth unexpected exception: " + e); 70 } 71 } 72 73 public void assignA(String pkA) throws FinderException { 74 logger.log(BasicLevel.DEBUG, "param=" + pkA); 75 ALocal a = null; 76 if (pkA != null) { 77 a = ahl.findByPrimaryKey(pkA); 78 } 79 logger.log(BasicLevel.DEBUG, "assign:" + a); 80 setA(a); 81 } 82 83 public void assignAInNewTx(String pkA) throws FinderException { 84 assignA(pkA); 85 } 86 87 public String retrieveA() { 88 if (getA() == null) { 89 logger.log(BasicLevel.DEBUG, "return null"); 90 return null; 91 } 92 logger.log(BasicLevel.DEBUG, "return : " + getA().getPrimaryKey()); 93 return (String ) (getA().getPrimaryKey()); 94 } 95 96 public String retrieveAInNewTx() { 97 return retrieveA(); 98 } 99 100 public boolean equalsRelA(String pka) throws FinderException { 101 return (pka == retrieveA()); 102 } 103 104 public abstract String getId(); 108 public abstract void setId(String id); 109 110 public abstract Product getProduct(); 113 public abstract void setProduct(Product p); 114 115 116 public abstract ALocal getA(); 117 public abstract void setA(ALocal a); 118 119 123 static protected Logger logger = null; 124 125 EntityContext ejbContext; 126 127 132 public String ejbCreate(String id) throws CreateException , DuplicateKeyException { 133 logger.log(BasicLevel.DEBUG, ""); 134 135 setId(id); 137 setProduct(new Product()); 138 139 return null; 141 } 142 143 152 public void setEntityContext(EntityContext ctx) { 153 if (logger == null) logger = Log.getLogger(Log.JONAS_TESTS_PREFIX); 154 logger.log(BasicLevel.DEBUG, ""); 155 ejbContext = ctx; 156 try { 157 Context ictx = new InitialContext (); 158 ahl = (AHomeLocal) ictx.lookup("java:comp/env/ejb/a"); 159 } catch (NamingException e) { 160 throw new EJBException ("Impossible to fetch the ", e); 161 } 162 } 163 164 173 public void unsetEntityContext() { 174 logger.log(BasicLevel.DEBUG, ""); 175 ejbContext = null; 176 } 177 178 190 public void ejbRemove() throws RemoveException { 191 logger.log(BasicLevel.DEBUG, ""); 192 } 193 194 201 public void ejbLoad() { 202 logger.log(BasicLevel.DEBUG, ""); 203 } 204 205 212 public void ejbStore() { 213 logger.log(BasicLevel.DEBUG, ""); 214 } 215 216 220 public void ejbPostCreate(String id) throws CreateException { 221 logger.log(BasicLevel.DEBUG, "id=" + id); 222 setA(null); 223 } 224 225 229 public void ejbPassivate() { 230 logger.log(BasicLevel.DEBUG, ""); 231 } 232 233 238 public void ejbActivate() { 239 logger.log(BasicLevel.DEBUG, ""); 240 } 241 242 } 243 244 | Popular Tags |