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 EJBLoadBean 38 implements EntityBean 39 { 40 private static final Logger log = Logger.getLogger(EJBLoadBean.class); 41 42 private EntityContext entityContext; 43 44 private String name; 45 46 private boolean ejbLoadCalled = false; 47 48 private boolean active = false; 49 50 public String getName() 51 { 52 log.info("getName"); 53 assertActive(); 54 return name; 55 } 56 57 public boolean wasEJBLoadCalled() 58 { 59 log.info("wasEJBLoadCalled"); 60 assertActive(); 61 boolean result = ejbLoadCalled; 62 ejbLoadCalled = false; 63 return result; 64 } 65 66 public void noTransaction() 67 { 68 log.info("noTransaction"); 69 assertActive(); 70 ejbLoadCalled = false; 71 } 72 73 public String ejbCreate(String name) 74 throws CreateException 75 { 76 assertActive(); 77 log.info("ejbCreate"); 78 this.name = name; 79 return name; 80 } 81 82 public void ejbPostCreate(String name) 83 throws CreateException 84 { 85 assertActive(); 86 log.info("ejbPostCreate"); 87 } 88 89 public String ejbFindByPrimaryKey(String name) 90 { 91 log.info("ejbFindByPrimaryKey"); 92 return name; 93 } 94 95 public void ejbActivate() 96 { 97 log.info("ejbActivate"); 98 active = true; 99 } 100 101 public void ejbLoad() 102 { 103 log.info("ejbLoad"); 104 ejbLoadCalled = true; 105 assertActive(); 106 } 107 108 public void ejbPassivate() 109 { 110 log.info("ejbPassivate"); 111 assertActive(); 112 active = false; 113 } 114 115 public void ejbRemove() 116 throws RemoveException 117 { 118 log.info("ejbRemove"); 119 assertActive(); 120 active = false; 121 } 122 123 public void ejbStore() 124 { 125 log.info("ejbStore"); 126 assertActive(); 127 } 128 129 public void setEntityContext(EntityContext context) 130 { 131 log.info("setEntityContext"); 132 entityContext = context; 133 } 134 135 public void unsetEntityContext() 136 { 137 log.info("unsetEntityContext"); 138 entityContext = null; 139 } 140 141 private void assertActive() 142 { 143 if (active == false) 144 throw new RuntimeException ("The bean is not active"); 145 } 146 } 147 | Popular Tags |