1 25 26 package org.objectweb.jonas.jtests.beans.relation.mnu; 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; 59 if (c == null) { 60 al = new ArrayList (); 61 } else { 62 if (c.size() == -1) { 63 al = new ArrayList (); 64 } else { 65 al = new ArrayList (c.size()); 66 for (Iterator it = c.iterator(); it.hasNext();) { 67 al.add(bhl.findByPrimaryKey((String ) it.next())); 68 } 69 } 70 } 71 setB(al); 72 } 73 74 public void assignBInNewTx(Collection c) throws FinderException { 75 assignB(c); 76 } 77 78 public Collection retrieveB() { 79 Collection bs = getB(); 80 ArrayList result; 81 if (bs.size() == -1) { 82 result = new ArrayList (); 83 } else { 84 result = new ArrayList (bs.size()); 85 } 86 87 for (Iterator it = bs.iterator(); it.hasNext();) { 88 result.add(((BLocal) it.next()).getPrimaryKey()); 89 } 90 return result; 91 } 92 93 public Collection retrieveBInNewTx() { 94 return retrieveB(); 95 } 96 97 public void addInB(String pkb) throws FinderException { 98 getB().add(bhl.findByPrimaryKey(pkb)); 99 } 100 101 public void addInBInNewTx(String pkb) throws FinderException { 102 addInB(pkb); 103 } 104 105 public void addAllInB(Collection pkbs) throws FinderException { 106 ArrayList al = new ArrayList (); 107 for (Iterator it = pkbs.iterator(); it.hasNext();) { 108 al.add(bhl.findByPrimaryKey((String ) it.next())); 109 } 110 getB().addAll(al); 111 } 112 113 public void addAllInBInNewTx(Collection pkbs) throws FinderException { 114 addAllInB(pkbs); 115 } 116 117 public void removeFromB(String pkb) throws FinderException { 118 getB().remove(bhl.findByPrimaryKey(pkb)); 119 } 120 121 public void removeFromBInNewTx(String pkb) throws FinderException { 122 removeFromB(pkb); 123 } 124 125 public void clearB() { 126 getB().clear(); 127 } 128 129 public void clearBInNewTx() { 130 clearB(); 131 } 132 133 public boolean containAllInB(Collection pkbs) throws FinderException { 134 ArrayList al = new ArrayList (pkbs.size()); 135 for (Iterator it = pkbs.iterator(); it.hasNext();) { 136 al.add(bhl.findByPrimaryKey((String ) it.next())); 137 } 138 return getB().containsAll(al); 139 } 140 141 147 public boolean containInB(String pkb) throws FinderException { 148 return (getB().contains(bhl.findByPrimaryKey(pkb))); 149 } 150 151 public abstract String getId(); 155 156 public abstract void setId(String id); 157 158 public abstract Collection getB(); 159 160 public abstract void setB(Collection bl); 161 162 166 protected static Logger logger = null; 167 EntityContext ejbContext; 168 169 175 public String ejbCreate(String id) throws CreateException , DuplicateKeyException { 176 logger.log(BasicLevel.DEBUG, ""); 177 178 setId(id); 180 181 return null; 183 } 184 185 195 public void setEntityContext(EntityContext ctx) { 196 if (logger == null) { 197 logger = Log.getLogger(Log.JONAS_TESTS_PREFIX); 198 } 199 logger.log(BasicLevel.DEBUG, ""); 200 ejbContext = ctx; 201 try { 202 Context ictx = new InitialContext (); 203 bhl = (BHomeLocal) ictx.lookup("java:comp/env/ejb/b"); 204 } catch (NamingException e) { 205 throw new EJBException ("Impossible to fetch the ", e); 206 } 207 } 208 209 220 public void unsetEntityContext() { 221 logger.log(BasicLevel.DEBUG, ""); 222 ejbContext = null; 223 } 224 225 238 public void ejbRemove() throws RemoveException { 239 logger.log(BasicLevel.DEBUG, ""); 240 } 241 242 250 public void ejbLoad() { 251 logger.log(BasicLevel.DEBUG, ""); 252 } 253 254 262 public void ejbStore() { 263 logger.log(BasicLevel.DEBUG, ""); 264 } 265 266 271 public void ejbPostCreate(String id) throws CreateException { 272 logger.log(BasicLevel.DEBUG, "id=" + id); 273 } 274 275 279 public void ejbPassivate() { 280 logger.log(BasicLevel.DEBUG, ""); 281 } 282 283 288 public void ejbActivate() { 289 logger.log(BasicLevel.DEBUG, ""); 290 } 291 292 } 293 | Popular Tags |