1 22 package org.jboss.test.txiiop.ejb; 23 24 import java.io.ByteArrayInputStream ; 25 import java.io.ByteArrayOutputStream ; 26 import java.io.ObjectInputStream ; 27 import java.io.ObjectOutputStream ; 28 import java.rmi.RemoteException ; 29 import javax.ejb.CreateException ; 30 import javax.ejb.EJBException ; 31 import javax.ejb.EJBObject ; 32 import javax.ejb.Handle ; 33 import javax.ejb.RemoveException ; 34 import javax.ejb.SessionSynchronization ; 35 import javax.naming.Context ; 36 import javax.naming.InitialContext ; 37 38 import org.jboss.logging.Logger; 39 import org.jboss.test.cts.interfaces.BeanContextInfo; 40 import org.jboss.test.cts.interfaces.CtsCmpLocal; 41 import org.jboss.test.cts.interfaces.CtsCmpLocalHome; 42 import org.jboss.test.cts.interfaces.StatefulSession; 43 import org.jboss.test.cts.interfaces.StatefulSessionHome; 44 import org.jboss.test.cts.interfaces.StatelessSession; 45 import org.jboss.test.cts.interfaces.StatelessSessionHome; 46 import org.jboss.test.cts.keys.AccountPK; 47 import org.jboss.test.util.ejb.SessionSupport; 48 49 50 55 public class StatefulSessionBean 56 extends SessionSupport 57 implements SessionSynchronization 58 { 59 private static transient Logger log = Logger.getLogger(StatefulSessionBean.class); 60 private transient int counterAtTxStart; 61 private String testName; 62 private int counter; 63 64 public void ejbCreate(String testName) 65 { 66 this.testName = testName; 67 log = Logger.getLogger(StatefulSessionBean.class.getName()+"#"+testName); 68 log.debug("ejbCreate("+testName+"), ctx="+sessionCtx); 69 } 70 71 public void afterBegin () 72 { 73 log.debug("afterBegin()..., counter="+counter); 74 counterAtTxStart = counter; 75 } 76 public void afterCompletion (boolean isCommited) 77 { 78 log.debug("afterCompletion(), isCommited="+isCommited 79 +", counter="+counter+", counterAtTxStart="+counterAtTxStart); 80 if( isCommited == false ) 81 { 82 counter = counterAtTxStart; 83 log.debug("Rolling counter back to: "+counter); 84 } 85 else 86 { 87 log.debug("Committed updated counter: "+counter); 88 } 89 } 90 public void beforeCompletion () 91 { 92 log.debug("beforeCompletion(), counter="+counter 93 +", counterAtTxStart="+counterAtTxStart); 94 } 95 96 public void incCounter () 97 { 98 counter++; 99 } 100 101 public void decCounter () 102 { 103 counter--; 104 } 105 106 public int getCounter () 107 { 108 return counter; 109 } 110 111 public void setCounter (int value) 112 { 113 counter = value; 114 } 115 116 public String txMandatoryMethod(String msg) 117 { 118 log.debug("txMandatoryMethod( ), msg="+msg); 119 return msg; 120 } 121 122 } 123 | Popular Tags |