1 22 package org.jboss.test.entity.ejb; 23 24 import javax.ejb.CreateException ; 25 import javax.ejb.EntityBean ; 26 import javax.ejb.EntityContext ; 27 import javax.ejb.RemoveException ; 28 29 import org.jboss.logging.Logger; 30 31 37 public class UnsetEntityContextBean implements EntityBean 38 { 39 private static final Logger log = Logger.getLogger(UnsetEntityContextBean.class); 40 41 private static int setEntityContextCounter = 0; 42 private static int unsetEntityContextCounter = 0; 43 44 private EntityContext entityContext; 45 46 private String name; 47 48 public void setEntityContext(EntityContext context) 49 { 50 log.info("setEntityContext - " + name); 51 ++setEntityContextCounter; 52 entityContext = context; 53 } 54 55 public void unsetEntityContext() 56 { 57 log.info("unsetEntityContext - " + name); 58 ++unsetEntityContextCounter; 59 entityContext = null; 60 } 61 62 public String getName() 63 { 64 log.info("getName"); 65 return name; 66 } 67 68 public String ejbCreate(String name) 69 throws CreateException 70 { 71 log.info("ejbCreate - " + name); 72 this.name = name; 73 return name; 74 } 75 76 public void ejbPostCreate(String name) 77 throws CreateException 78 { 79 log.info("ejbPostCreate - " + name); 80 } 81 82 public String ejbFindByPrimaryKey(String name) 83 { 84 log.info("ejbFindByPrimaryKey - " + name); 85 return name; 86 } 87 88 public void ejbActivate() 89 { 90 log.info("ejbActivate - " + name); 91 } 92 93 public void ejbLoad() 94 { 95 log.info("ejbLoad - " + name); 96 } 97 98 public void ejbPassivate() 99 { 100 log.info("ejbPassivate - " + name); 101 } 102 103 public void ejbRemove() 104 throws RemoveException 105 { 106 log.info("ejbRemove - " + name); 107 } 108 109 public void ejbStore() 110 { 111 log.info("ejbStore - " + name); 112 } 113 114 public int ejbHomeGetSetEntityContextCallCounter() 115 { 116 return setEntityContextCounter; 117 } 118 119 public int ejbHomeGetUnsetEntityContextCallCounter() 120 { 121 return unsetEntityContextCounter; 122 } 123 124 public void ejbHomeClearSetEntityContextCallCounter() 125 { 126 log.info("ejbHomeClearSetEntityContextCallCounter - " + name); 127 setEntityContextCounter = 0; 128 } 129 130 public void ejbHomeClearUnsetEntityContextCallCounter() 131 { 132 log.info("ejbHomeClearUnsetEntityContextCallCounter - " + name); 133 unsetEntityContextCounter = 0; 134 } 135 136 } 137 | Popular Tags |