1 22 package org.jboss.test.cmp2.cmrstress.ejb; 23 24 import java.util.HashMap ; 25 import java.util.Iterator ; 26 import java.util.Map ; 27 import java.util.Set ; 28 29 import javax.ejb.CreateException ; 30 import javax.ejb.EJBException ; 31 import javax.ejb.EntityBean ; 32 import javax.ejb.EntityContext ; 33 import javax.ejb.RemoveException ; 34 import javax.naming.NamingException ; 35 36 import org.jboss.logging.Logger; 37 import org.jboss.test.cmp2.cmrstress.interfaces.ChildLocal; 38 import org.jboss.test.cmp2.cmrstress.interfaces.ChildUtil; 39 40 76 public abstract class ParentBean implements EntityBean 77 { 78 85 public abstract String getId(); 86 87 92 public abstract void setId(String id); 93 94 108 public abstract Set getChildren(); 109 110 115 public abstract void setChildren(Set children); 116 117 125 public Map getPropertyMap() 126 { 127 Map result = new HashMap (); 128 Set children = getChildren(); 129 for (Iterator i = children.iterator(); i.hasNext(); ) 130 { 131 ChildLocal c = (ChildLocal) i.next(); 132 result.put(c.getName(), c.getValue()); 133 } 134 135 return result; 136 } 137 138 143 public void addChild(int k, String field1, String field2) throws CreateException 144 { 145 msLog.debug("Adding child with pk: " + k); 146 try 147 { 148 getChildren().add(ChildUtil.getLocalHome().create(Integer.toString(k), field1, field2)); 149 } 150 catch (NamingException e) 151 { 152 throw new EJBException (e); 153 } 154 } 155 156 157 162 public String ejbCreate(String id) throws javax.ejb.CreateException 163 { 164 msLog.debug("Created '" + id + "'"); 165 setId(id); 166 return null; 167 } 168 169 public void ejbPostCreate(String id) 170 { 171 } 172 173 176 public void ejbActivate() 177 { 178 } 179 180 183 public void ejbLoad() 184 { 185 } 186 187 190 public void ejbPassivate() 191 { 192 } 193 194 197 public void ejbRemove() throws RemoveException 198 { 199 msLog.debug("Removed"); 200 } 201 202 205 public void ejbStore() 206 { 207 } 208 209 212 public void setEntityContext(EntityContext arg0) 213 { 214 } 215 216 219 public void unsetEntityContext() 220 { 221 } 222 223 private static final Logger msLog = Logger.getLogger(ParentBean.class); 224 225 } 226 | Popular Tags |