1 25 26 package org.objectweb.jonas.jtests.beans.relation.pkg.beans; 27 28 import org.objectweb.util.monolog.api.Logger; 29 import org.objectweb.util.monolog.api.BasicLevel; 30 import org.objectweb.jonas.common.Log; 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.AHomeLocal; 48 import org.objectweb.jonas.jtests.beans.relation.pkg.itf.ALocal; 49 50 53 public abstract class BEC2 implements javax.ejb.EntityBean { 54 55 private AHomeLocal ahl = null; 56 57 public void m1(){ 58 } 59 60 public void assignA(Collection c) throws FinderException { 61 ArrayList al; 62 if (c==null) 63 al = new ArrayList (); 64 else { 65 if (c.size()==-1) 66 al = new ArrayList (); 67 else { 68 al = new ArrayList (c.size()); 69 for(Iterator it = c.iterator(); it.hasNext();) { 70 al.add(ahl.findByPrimaryKey((String ) it.next())); 71 } 72 } 73 } 74 setA(al); 75 } 76 77 public void assignAInNewTx(Collection c) throws FinderException { 78 assignA(c); 79 } 80 81 public Collection retrieveA() { 82 Collection bs = getA(); 83 ArrayList result ; 84 if (bs.size()==-1) 85 result = new ArrayList (); 86 else result = new ArrayList (bs.size()); 87 88 for(Iterator it = bs.iterator(); it.hasNext();) 89 result.add(((ALocal) it.next()).getPrimaryKey()); 90 return result; 91 } 92 93 public Collection retrieveAInNewTx() { 94 return retrieveA(); 95 } 96 97 public void addInA(String pkb) throws FinderException { 98 getA().add(ahl.findByPrimaryKey(pkb)); 99 } 100 public void addInAInNewTx(String pkb) throws FinderException { 101 addInA(pkb); 102 } 103 104 public void addAllInA(Collection pkbs) throws FinderException { 105 ArrayList al = new ArrayList (); 106 for (Iterator it = pkbs.iterator(); it.hasNext();) 107 al.add(ahl.findByPrimaryKey((String ) it.next())); 108 getA().addAll(al); 109 } 110 public void addAllInAInNewTx(Collection pkbs) throws FinderException { 111 addAllInA(pkbs); 112 } 113 114 public void removeFromA(String pkb) throws FinderException { 115 getA().remove(ahl.findByPrimaryKey(pkb)); 116 } 117 public void removeFromAInNewTx(String pkb) throws FinderException { 118 removeFromA(pkb); 119 } 120 121 public void clearA() { 122 getA().clear(); 123 } 124 125 public void clearAInNewTx() { 126 clearA(); 127 } 128 129 public boolean containAllInA(Collection pkbs) throws FinderException { 130 ArrayList al = new ArrayList (pkbs.size()); 131 for(Iterator it = pkbs.iterator(); it.hasNext();) 132 al.add(ahl.findByPrimaryKey((String ) it.next())); 133 return getA().containsAll(al); 134 } 135 136 142 public boolean containInA(String pkb) throws FinderException { 143 return (getA().contains(ahl.findByPrimaryKey(pkb))); 144 } 145 146 public abstract String getId(); 150 151 public abstract void setId(String id); 152 153 public abstract Collection getA(); 154 155 public abstract void setA(Collection bl); 156 157 161 static protected Logger logger = null; 162 EntityContext ejbContext; 163 164 170 public String ejbCreate(String id) throws CreateException , DuplicateKeyException { 171 logger.log(BasicLevel.DEBUG, ""); 172 173 setId(id); 175 176 return null; 178 } 179 180 190 public void setEntityContext(EntityContext ctx) { 191 if (logger == null) 192 logger = Log.getLogger(Log.JONAS_TESTS_PREFIX); 193 logger.log(BasicLevel.DEBUG, ""); 194 ejbContext = ctx; 195 try { 196 Context ictx = new InitialContext (); 197 ahl = (AHomeLocal) ictx.lookup("java:comp/env/ejb/a"); 198 } catch (NamingException e) { 199 throw new EJBException ("Impossible to fetch the ", e); 200 } 201 } 202 203 214 public void unsetEntityContext() { 215 logger.log(BasicLevel.DEBUG, ""); 216 ejbContext = null; 217 } 218 219 232 public void ejbRemove() throws RemoveException { 233 logger.log(BasicLevel.DEBUG, ""); 234 } 235 236 244 public void ejbLoad() { 245 logger.log(BasicLevel.DEBUG, ""); 246 } 247 248 256 public void ejbStore() { 257 logger.log(BasicLevel.DEBUG, ""); 258 } 259 260 265 public void ejbPostCreate(String id) throws CreateException { 266 logger.log(BasicLevel.DEBUG, "id=" + id); 267 } 268 269 273 public void ejbPassivate() { 274 logger.log(BasicLevel.DEBUG, ""); 275 } 276 277 282 public void ejbActivate() { 283 logger.log(BasicLevel.DEBUG, ""); 284 } 285 286 } 287 288 | Popular Tags |