1 25 26 package org.objectweb.easybeans.examples.statefulbean; 27 28 import java.rmi.RemoteException ; 29 30 import javax.ejb.Remote ; 31 import javax.ejb.SessionSynchronization ; 32 import javax.ejb.Stateful ; 33 34 38 @Stateful 39 @Remote (StatefulRemote.class) 40 public class StatefulBean implements SessionSynchronization , StatefulRemote { 41 42 45 private int total = 0; 46 47 50 private int newtotal = 0; 51 52 55 public StatefulBean() { 56 total = 0; 57 newtotal = total; } 59 60 75 public void afterBegin() throws RemoteException { 76 newtotal = total; 77 } 78 79 95 public void beforeCompletion() throws RemoteException { 96 } 97 98 113 public void afterCompletion(final boolean committed) throws RemoteException { 114 if (committed) { 115 total = newtotal; 116 } else { 117 newtotal = total; 118 } 119 } 120 121 125 public void buy(final int s) { 126 newtotal = newtotal + s; 127 return; 128 } 129 130 134 public int read() { 135 return newtotal; 136 } 137 } 138 | Popular Tags |