1 25 26 package org.objectweb.jonas.jtests.beans.relation.pkg.beans; 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 import org.objectweb.jonas.jtests.beans.relation.pkg.itf.BHomeLocal; 48 import org.objectweb.jonas.jtests.beans.relation.pkg.itf.BLocal; 49 50 51 54 public abstract class AEC2 implements javax.ejb.EntityBean { 55 56 private BHomeLocal bhl = null; 57 58 public void m1(){ 59 } 60 61 public void assignB(Collection c) throws FinderException { 62 ArrayList al; 63 if (c==null) 64 al = new ArrayList (); 65 else { 66 if (c.size()==-1) 67 al = new ArrayList (); 68 else { 69 al = new ArrayList (c.size()); 70 for(Iterator it = c.iterator(); it.hasNext();) 71 al.add(bhl.findByPrimaryKey((String ) it.next())); 72 } 73 } 74 setB(al); 75 } 76 public void assignBInNewTx(Collection c) throws FinderException { 77 assignB(c); 78 } 79 80 public Collection retrieveB() { 81 Collection bs = getB(); 82 ArrayList result ; 83 if (bs.size()==-1) 84 result = new ArrayList (); 85 else result = new ArrayList (bs.size()); 86 87 for(Iterator it = bs.iterator(); it.hasNext();) 88 result.add(((BLocal) it.next()).getPrimaryKey()); 89 return result; 90 } 91 92 public Collection retrieveBInNewTx() { 93 return retrieveB(); 94 } 95 96 public void addInB(String pkb) throws FinderException { 97 getB().add(bhl.findByPrimaryKey(pkb)); 98 } 99 public void addInBInNewTx(String pkb) throws FinderException { 100 addInB(pkb); 101 } 102 103 public void addAllInB(Collection pkbs) throws FinderException { 104 ArrayList al = new ArrayList (); 105 for (Iterator it = pkbs.iterator(); it.hasNext();) 106 al.add(bhl.findByPrimaryKey((String ) it.next())); 107 getB().addAll(al); 108 } 109 public void addAllInBInNewTx(Collection pkbs) throws FinderException { 110 addAllInB(pkbs); 111 } 112 113 public void removeFromB(String pkb) throws FinderException { 114 getB().remove(bhl.findByPrimaryKey(pkb)); 115 } 116 public void removeFromBInNewTx(String pkb) throws FinderException { 117 removeFromB(pkb); 118 } 119 120 public void clearB() { 121 getB().clear(); 122 } 123 124 public void clearBInNewTx() { 125 clearB(); 126 } 127 128 public boolean containAllInB(Collection pkbs) throws FinderException { 129 ArrayList al = new ArrayList (pkbs.size()); 130 for(Iterator it = pkbs.iterator(); it.hasNext();) 131 al.add(bhl.findByPrimaryKey((String ) it.next())); 132 return getB().containsAll(al); 133 } 134 135 141 public boolean containInB(String pkb) throws FinderException { 142 return (getB().contains(bhl.findByPrimaryKey(pkb))); 143 } 144 145 public abstract String getId(); 149 150 public abstract void setId(String id); 151 152 public abstract Collection getB(); 153 154 public abstract void setB(Collection bl); 155 156 160 static protected Logger logger = null; 161 EntityContext ejbContext; 162 163 169 public String ejbCreate(String id) throws CreateException , DuplicateKeyException { 170 logger.log(BasicLevel.DEBUG, ""); 171 172 setId(id); 174 175 return null; 177 } 178 179 189 public void setEntityContext(EntityContext ctx) { 190 if (logger == null) 191 logger = Log.getLogger(Log.JONAS_TESTS_PREFIX); 192 logger.log(BasicLevel.DEBUG, ""); 193 ejbContext = ctx; 194 try { 195 Context ictx = new InitialContext (); 196 bhl = (BHomeLocal) ictx.lookup("java:comp/env/ejb/b"); 197 } catch (NamingException e) { 198 throw new EJBException ("Impossible to fetch the ", e); 199 } 200 } 201 202 213 public void unsetEntityContext() { 214 logger.log(BasicLevel.DEBUG, ""); 215 ejbContext = null; 216 } 217 218 231 public void ejbRemove() throws RemoveException { 232 logger.log(BasicLevel.DEBUG, ""); 233 } 234 235 243 public void ejbLoad() { 244 logger.log(BasicLevel.DEBUG, ""); 245 } 246 247 255 public void ejbStore() { 256 logger.log(BasicLevel.DEBUG, ""); 257 } 258 259 264 public void ejbPostCreate(String id) throws CreateException { 265 logger.log(BasicLevel.DEBUG, "id=" + id); 266 } 267 268 272 public void ejbPassivate() { 273 logger.log(BasicLevel.DEBUG, ""); 274 } 275 276 281 public void ejbActivate() { 282 logger.log(BasicLevel.DEBUG, ""); 283 } 284 285 } 286 | Popular Tags |