1 25 26 package org.objectweb.jonas.jtests.beans.relation.s3pkcomp; 27 28 import org.objectweb.jonas.common.Log; 29 import org.objectweb.util.monolog.api.BasicLevel; 30 import org.objectweb.util.monolog.api.Logger; 31 32 import javax.ejb.CreateException ; 33 import javax.ejb.DuplicateKeyException ; 34 import javax.ejb.EntityContext ; 35 import javax.ejb.RemoveException ; 36 import javax.ejb.FinderException ; 37 import javax.ejb.EJBException ; 38 import javax.naming.Context ; 39 import javax.naming.InitialContext ; 40 import javax.naming.NamingException ; 41 import javax.rmi.PortableRemoteObject ; 42 43 import java.util.Collection ; 44 import java.util.ArrayList ; 45 import java.util.Iterator ; 46 47 50 public abstract class AEC2 implements javax.ejb.EntityBean { 51 52 private BHomeLocal bhl = null; 53 54 public void m1(){ 55 } 56 57 public void assignB(Collection c) throws FinderException { 58 ArrayList al = new ArrayList (c.size()); 59 for(Iterator it = c.iterator(); it.hasNext();) 60 al.add(bhl.findByPrimaryKey((Pk) it.next())); 61 setB(al); 62 } 63 public void assignBInNewTx(Collection c) throws FinderException { 64 assignB(c); 65 } 66 67 public Collection retrieveB() { 68 Collection bs = getB(); 69 ArrayList result = new ArrayList (bs.size()); 70 for(Iterator it = bs.iterator(); it.hasNext();) 71 result.add(((BLocal) it.next()).getPrimaryKey()); 72 return result; 73 } 74 public Collection retrieveBInNewTx() { 75 return retrieveB(); 76 } 77 78 public void addInB(Pk pkb) throws FinderException { 79 getB().add(bhl.findByPrimaryKey(pkb)); 80 } 81 public void addInBInNewTx(Pk pkb) throws FinderException { 82 addInB(pkb); 83 } 84 85 public void addAllInB(Collection pkbs) throws FinderException { 86 ArrayList al = new ArrayList (); 87 for (Iterator it = pkbs.iterator(); it.hasNext();) 88 al.add(bhl.findByPrimaryKey((Pk) it.next())); 89 getB().addAll(al); 90 } 91 public void addAllInBInNewTx(Collection pkbs) throws FinderException { 92 addAllInB(pkbs); 93 } 94 95 public void removeFromB(Pk pkb) throws FinderException { 96 getB().remove(bhl.findByPrimaryKey(pkb)); 97 } 98 public void removeFromBInNewTx(Pk pkb) throws FinderException { 99 removeFromB(pkb); 100 } 101 102 public void clearB() { 103 getB().clear(); 104 } 105 106 public void clearBInNewTx() { 107 clearB(); 108 } 109 110 public boolean containAllInB(Collection pkbs) throws FinderException { 111 ArrayList al = new ArrayList (pkbs.size()); 112 for(Iterator it = pkbs.iterator(); it.hasNext();) 113 al.add(bhl.findByPrimaryKey((Pk) it.next())); 114 return getB().containsAll(al); 115 } 116 117 123 public boolean containInB(Pk pkb) throws FinderException { 124 return (getB().contains(bhl.findByPrimaryKey(pkb))); 125 } 126 127 public abstract Integer getId(); 131 132 public abstract void setId(Integer id); 133 134 public abstract Collection getB(); 135 136 public abstract void setB(Collection bl); 137 138 142 static protected Logger logger = null; 143 EntityContext ejbContext; 144 145 151 public String ejbCreate(int id) throws CreateException , DuplicateKeyException { 152 logger.log(BasicLevel.DEBUG, ""); 153 154 setId(new Integer (id)); 156 157 return null; 159 } 160 161 171 public void setEntityContext(EntityContext ctx) { 172 if (logger == null) 173 logger = Log.getLogger(Log.JONAS_TESTS_PREFIX); 174 logger.log(BasicLevel.DEBUG, ""); 175 ejbContext = ctx; 176 try { 177 Context ictx = new InitialContext (); 178 bhl = (BHomeLocal) ictx.lookup("java:comp/env/ejb/b"); 179 } catch (NamingException e) { 180 throw new EJBException ("Impossible to fetch the ", e); 181 } 182 } 183 184 195 public void unsetEntityContext() { 196 logger.log(BasicLevel.DEBUG, ""); 197 ejbContext = null; 198 } 199 200 213 public void ejbRemove() throws RemoveException { 214 logger.log(BasicLevel.DEBUG, ""); 215 } 216 217 225 public void ejbLoad() { 226 logger.log(BasicLevel.DEBUG, ""); 227 } 228 229 237 public void ejbStore() { 238 logger.log(BasicLevel.DEBUG, ""); 239 } 240 241 246 public void ejbPostCreate(int id) throws CreateException { 247 logger.log(BasicLevel.DEBUG, "id=" + id); 248 } 249 250 254 public void ejbPassivate() { 255 logger.log(BasicLevel.DEBUG, ""); 256 } 257 258 263 public void ejbActivate() { 264 logger.log(BasicLevel.DEBUG, ""); 265 } 266 267 } 268 | Popular Tags |