1 25 26 package org.objectweb.jonas.jtests.beans.relation.mou; 27 28 import javax.ejb.CreateException ; 29 import javax.ejb.DuplicateKeyException ; 30 import javax.ejb.EJBException ; 31 import javax.ejb.EntityContext ; 32 import javax.ejb.FinderException ; 33 import javax.ejb.RemoveException ; 34 import javax.naming.Context ; 35 import javax.naming.InitialContext ; 36 import javax.naming.NamingException ; 37 import javax.rmi.PortableRemoteObject ; 38 39 import org.objectweb.jonas.common.Log; 40 import org.objectweb.util.monolog.api.BasicLevel; 41 import org.objectweb.util.monolog.api.Logger; 42 43 46 public abstract class AEC2 implements javax.ejb.EntityBean { 47 48 private BHomeLocal bhl = null; 49 50 public void m1(){ 51 } 52 53 public void assignB(String c) throws FinderException { 54 if (c != null) { 55 BLocal bl = null; 56 bl = bhl.findByPrimaryKey(c); 57 setB(bl); 58 } else 59 setB(null); 60 } 61 62 public void assignBInNewTx(String c) throws FinderException { 63 assignB(c); 64 } 65 66 public String retrieveB() { 67 BLocal lejbB = getB(); 68 if (lejbB == null) { 69 logger.log(BasicLevel.DEBUG, "return null"); 70 return null; 71 } else { 72 logger.log(BasicLevel.DEBUG, "return " + lejbB.getId()); 73 return lejbB.getId(); 74 } 75 } 76 77 public String retrieveBInNewTx() { 78 return retrieveB(); 79 } 80 81 82 public abstract String getId(); 86 87 public abstract void setId(String id); 88 89 public abstract BLocal getB(); 90 91 public abstract void setB(BLocal bl); 92 93 97 static protected Logger logger = null; 98 EntityContext ejbContext; 99 100 106 public String ejbCreate(String id, String idb) throws CreateException , DuplicateKeyException { 107 logger.log(BasicLevel.DEBUG, ""); 108 109 setId(id); 111 112 return null; 114 } 115 116 121 public void ejbPostCreate(String id, String idb) throws CreateException { 122 logger.log(BasicLevel.DEBUG, "id=" + id); 123 try { 124 assignB(idb); 125 } catch (FinderException e) { 126 throw new CreateException ("Bad arg: " + idb); 127 } 128 } 129 130 136 public String ejbCreate(String id) throws CreateException , DuplicateKeyException { 137 logger.log(BasicLevel.DEBUG, ""); 138 139 setId(id); 141 142 return null; 144 } 145 146 151 public void ejbPostCreate(String id) throws CreateException { 152 logger.log(BasicLevel.DEBUG, "id=" + id); 153 } 154 155 161 public String ejbCreate(String id, BLocal b) throws CreateException , DuplicateKeyException { 162 logger.log(BasicLevel.DEBUG, ""); 163 164 setId(id); 166 167 return null; 169 } 170 171 176 public void ejbPostCreate(String id, BLocal b) throws CreateException { 177 logger.log(BasicLevel.DEBUG, "id=" + id); 178 setB(b); 179 } 180 181 191 public void setEntityContext(EntityContext ctx) { 192 if (logger == null) 193 logger = Log.getLogger(Log.JONAS_TESTS_PREFIX); 194 logger.log(BasicLevel.DEBUG, ""); 195 ejbContext = ctx; 196 try { 197 Context ictx = new InitialContext (); 198 bhl = (BHomeLocal) ictx.lookup("java:comp/env/ejb/b"); 199 } catch (NamingException e) { 200 throw new EJBException ("Impossible to fetch the ", e); 201 } 202 } 203 204 215 public void unsetEntityContext() { 216 logger.log(BasicLevel.DEBUG, ""); 217 ejbContext = null; 218 } 219 220 233 public void ejbRemove() throws RemoveException { 234 logger.log(BasicLevel.DEBUG, ""); 235 } 236 237 245 public void ejbLoad() { 246 logger.log(BasicLevel.DEBUG, ""); 247 } 248 249 257 public void ejbStore() { 258 logger.log(BasicLevel.DEBUG, ""); 259 } 260 261 265 public void ejbPassivate() { 266 logger.log(BasicLevel.DEBUG, ""); 267 } 268 269 274 public void ejbActivate() { 275 logger.log(BasicLevel.DEBUG, ""); 276 } 277 278 } 279 | Popular Tags |