1 22 package org.jboss.test.dtmusertx.ejb; 23 24 import javax.ejb.SessionSynchronization ; 25 26 import org.jboss.logging.Logger; 27 import org.jboss.test.util.ejb.SessionSupport; 28 29 30 35 public class StatefulSessionBean 36 extends SessionSupport 37 implements SessionSynchronization 38 { 39 private static transient Logger log = Logger.getLogger(StatefulSessionBean.class); 40 private transient int counterAtTxStart; 41 private String testName; 42 private int counter; 43 44 public void ejbCreate(String testName) 45 { 46 this.testName = testName; 47 log = Logger.getLogger(StatefulSessionBean.class.getName()+"#"+testName); 48 log.debug("ejbCreate("+testName+"), ctx="+sessionCtx); 49 } 50 51 public void afterBegin () 52 { 53 log.debug("afterBegin()..., counter="+counter); 54 counterAtTxStart = counter; 55 } 56 public void afterCompletion (boolean isCommited) 57 { 58 log.debug("afterCompletion(), isCommited="+isCommited 59 +", counter="+counter+", counterAtTxStart="+counterAtTxStart); 60 if( isCommited == false ) 61 { 62 counter = counterAtTxStart; 63 log.debug("Rolling counter back to: "+counter); 64 } 65 else 66 { 67 log.debug("Committed updated counter: "+counter); 68 } 69 } 70 public void beforeCompletion () 71 { 72 log.debug("beforeCompletion(), counter="+counter 73 +", counterAtTxStart="+counterAtTxStart); 74 } 75 76 public void incCounter () 77 { 78 counter++; 79 } 80 81 public void decCounter () 82 { 83 counter--; 84 } 85 86 public int getCounter () 87 { 88 return counter; 89 } 90 91 public void setCounter (int value) 92 { 93 counter = value; 94 } 95 96 public String txMandatoryMethod(String msg) 97 { 98 log.debug("txMandatoryMethod( ), msg="+msg); 99 return msg; 100 } 101 102 } 103 | Popular Tags |