1 25 26 package org.objectweb.jonas.jtests.beans.relation.s2pkcomp; 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 Pk getId(){ 54 return (Pk)ejbContext.getPrimaryKey(); 55 } 56 57 public void assignB(Pk c) throws FinderException { 58 logger.log(BasicLevel.DEBUG, "param=" + c.toString()); 59 if (c != null) { 60 BLocal bl = null; 61 bl = bhl.findByPrimaryKey(c); 62 setB(bl); 63 } else { 64 setB(null); 65 } 66 } 67 public void assignBInNewTx(Pk c) throws FinderException { 68 assignB(c); 69 } 70 71 public Pk retrieveB() { 72 BLocal lejbB = getB(); 73 if (lejbB == null) { 74 logger.log(BasicLevel.DEBUG, "return null"); 75 return null; 76 } else { 77 logger.log(BasicLevel.DEBUG, "return " + lejbB.getId()); 78 return lejbB.getId(); 79 } 80 } 81 82 public Pk retrieveBInNewTx() { 83 return retrieveB(); 84 } 85 86 public abstract String getId1(); 90 public abstract void setId1(String id1); 91 public abstract int getId2(); 92 public abstract void setId2(int id2); 93 public abstract BLocal getB(); 94 public abstract void setB(BLocal bl); 95 96 100 static protected Logger logger = null; 101 EntityContext ejbContext; 102 103 109 public Pk ejbCreate(String id1, int id2) throws CreateException , DuplicateKeyException { 110 logger.log(BasicLevel.DEBUG, ""); 111 112 setId1(id1); 114 setId2(id2); 115 116 return null; 118 } 119 120 130 public void setEntityContext(EntityContext ctx) { 131 if (logger == null) 132 logger = Log.getLogger(Log.JONAS_TESTS_PREFIX); 133 logger.log(BasicLevel.DEBUG, ""); 134 ejbContext = ctx; 135 try { 136 Context ictx = new InitialContext (); 137 bhl = (BHomeLocal) ictx.lookup("java:comp/env/ejb/b"); 138 } catch (NamingException e) { 139 throw new EJBException ("Impossible to fetch the ", e); 140 } 141 } 142 143 154 public void unsetEntityContext() { 155 logger.log(BasicLevel.DEBUG, ""); 156 ejbContext = null; 157 } 158 159 172 public void ejbRemove() throws RemoveException { 173 logger.log(BasicLevel.DEBUG, ""); 174 } 175 176 184 public void ejbLoad() { 185 logger.log(BasicLevel.DEBUG, ""); 186 } 187 188 196 public void ejbStore() { 197 logger.log(BasicLevel.DEBUG, ""); 198 } 199 200 205 public void ejbPostCreate(String id1, int id2) throws CreateException { 206 logger.log(BasicLevel.DEBUG, "id1="+id1+", id2="+id2); 207 } 208 209 213 public void ejbPassivate() { 214 logger.log(BasicLevel.DEBUG, ""); 215 } 216 217 222 public void ejbActivate() { 223 logger.log(BasicLevel.DEBUG, ""); 224 } 225 226 } 227 | Popular Tags |