1 22 package org.jboss.test.cmp2.jbas979; 23 24 25 import javax.ejb.EntityBean ; 26 import javax.ejb.EntityContext ; 27 import javax.ejb.RemoveException ; 28 import javax.ejb.CreateException ; 29 import javax.ejb.EJBException ; 30 import javax.transaction.TransactionManager ; 31 import javax.transaction.SystemException ; 32 import org.jboss.tm.TransactionManagerLocator; 33 34 35 39 public abstract class ABean implements EntityBean 40 { 41 private Object longTx; 42 43 49 public abstract Integer getId(); 50 51 public abstract void setId(Integer id); 52 53 57 public abstract String getName(); 58 59 62 public abstract void setName(String name); 63 64 public void longTx() throws Exception 65 { 66 TransactionManager tm = TransactionManagerLocator.getInstance().locate(); 67 longTx = tm.getTransaction(); 68 if(longTx == null) 69 { 70 throw new EJBException ("longTx invoked w/o a transaction!"); 71 } 72 } 73 74 78 public Integer ejbCreate(Integer id, String name) 79 throws CreateException 80 { 81 setId(id); 82 setName(name); 83 return null; 84 } 85 86 public void ejbPostCreate(Integer id, String name) 87 { 88 } 89 90 93 public void setEntityContext(EntityContext ctx) 94 { 95 } 96 97 100 public void unsetEntityContext() 101 { 102 } 103 104 public void ejbActivate() 105 { 106 } 107 108 public void ejbLoad() 109 { 110 } 111 112 public void ejbPassivate() 113 { 114 TransactionManager tm = TransactionManagerLocator.getInstance().locate(); 115 try 116 { 117 if(longTx != null && longTx.equals(tm.getTransaction())) 119 { 120 JBAS979UnitTestCase.PASSIVATED_IN_AFTER_COMPLETION = true; 121 } 122 else 123 { 124 JBAS979UnitTestCase.PASSIVATED_IN_AFTER_COMPLETION = false; 125 } 126 JBAS979UnitTestCase.ERROR_IN_EJB_PASSIVATE = null; 127 } 128 catch(SystemException e) 129 { 130 JBAS979UnitTestCase.ERROR_IN_EJB_PASSIVATE = e; 131 } 132 } 133 134 public void ejbRemove() throws RemoveException 135 { 136 } 137 138 public void ejbStore() 139 { 140 } 141 } 142 | Popular Tags |