1 25 26 package org.objectweb.jonas.jtests.beans.relation.mnb; 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 49 public abstract class BEC2 implements javax.ejb.EntityBean { 50 51 private AHomeLocal ahl = null; 52 53 public void m1(){ 54 } 55 56 public void assignA(Collection c) throws FinderException { 57 ArrayList al; 58 if (c==null) 59 al = new ArrayList (); 60 else { 61 if (c.size()==-1) 62 al = new ArrayList (); 63 else { 64 al = new ArrayList (c.size()); 65 for(Iterator it = c.iterator(); it.hasNext();) { 66 al.add(ahl.findByPrimaryKey((String ) it.next())); 67 } 68 } 69 } 70 setA(al); 71 } 72 73 public void assignAInNewTx(Collection c) throws FinderException { 74 assignA(c); 75 } 76 77 public Collection retrieveA() { 78 Collection bs = getA(); 79 ArrayList result ; 80 if (bs.size()==-1) 81 result = new ArrayList (); 82 else result = new ArrayList (bs.size()); 83 84 for(Iterator it = bs.iterator(); it.hasNext();) 85 result.add(((ALocal) it.next()).getPrimaryKey()); 86 return result; 87 } 88 89 public Collection retrieveAInNewTx() { 90 return retrieveA(); 91 } 92 93 public void addInA(String pkb) throws FinderException { 94 getA().add(ahl.findByPrimaryKey(pkb)); 95 } 96 public void addInAInNewTx(String pkb) throws FinderException { 97 addInA(pkb); 98 } 99 100 public void addAllInA(Collection pkbs) throws FinderException { 101 ArrayList al = new ArrayList (); 102 for (Iterator it = pkbs.iterator(); it.hasNext();) 103 al.add(ahl.findByPrimaryKey((String ) it.next())); 104 getA().addAll(al); 105 } 106 public void addAllInAInNewTx(Collection pkbs) throws FinderException { 107 addAllInA(pkbs); 108 } 109 110 public void removeFromA(String pkb) throws FinderException { 111 getA().remove(ahl.findByPrimaryKey(pkb)); 112 } 113 public void removeFromAInNewTx(String pkb) throws FinderException { 114 removeFromA(pkb); 115 } 116 117 public void clearA() { 118 getA().clear(); 119 } 120 121 public void clearAInNewTx() { 122 clearA(); 123 } 124 125 public boolean containAllInA(Collection pkbs) throws FinderException { 126 ArrayList al = new ArrayList (pkbs.size()); 127 for(Iterator it = pkbs.iterator(); it.hasNext();) 128 al.add(ahl.findByPrimaryKey((String ) it.next())); 129 return getA().containsAll(al); 130 } 131 132 138 public boolean containInA(String pkb) throws FinderException { 139 return (getA().contains(ahl.findByPrimaryKey(pkb))); 140 } 141 142 public abstract String getId(); 146 147 public abstract void setId(String id); 148 149 public abstract Collection getA(); 150 151 public abstract void setA(Collection bl); 152 153 157 static protected Logger logger = null; 158 EntityContext ejbContext; 159 160 166 public String ejbCreate(String id) throws CreateException , DuplicateKeyException { 167 logger.log(BasicLevel.DEBUG, ""); 168 169 setId(id); 171 172 return null; 174 } 175 176 186 public void setEntityContext(EntityContext ctx) { 187 if (logger == null) 188 logger = Log.getLogger(Log.JONAS_TESTS_PREFIX); 189 logger.log(BasicLevel.DEBUG, ""); 190 ejbContext = ctx; 191 try { 192 Context ictx = new InitialContext (); 193 ahl = (AHomeLocal) ictx.lookup("java:comp/env/ejb/a"); 194 } catch (NamingException e) { 195 throw new EJBException ("Impossible to fetch the ", e); 196 } 197 } 198 199 210 public void unsetEntityContext() { 211 logger.log(BasicLevel.DEBUG, ""); 212 ejbContext = null; 213 } 214 215 228 public void ejbRemove() throws RemoveException { 229 logger.log(BasicLevel.DEBUG, ""); 230 } 231 232 240 public void ejbLoad() { 241 logger.log(BasicLevel.DEBUG, ""); 242 } 243 244 252 public void ejbStore() { 253 logger.log(BasicLevel.DEBUG, ""); 254 } 255 256 261 public void ejbPostCreate(String id) throws CreateException { 262 logger.log(BasicLevel.DEBUG, "id=" + id); 263 } 264 265 269 public void ejbPassivate() { 270 logger.log(BasicLevel.DEBUG, ""); 271 } 272 273 278 public void ejbActivate() { 279 logger.log(BasicLevel.DEBUG, ""); 280 } 281 282 } 283 284 | Popular Tags |