1 26 27 package org.objectweb.earsample.beans.secusb; 28 29 import javax.ejb.EJBException ; 30 import javax.ejb.SessionBean ; 31 import javax.ejb.SessionContext ; 32 import javax.ejb.SessionSynchronization ; 33 34 38 public class OpBean implements SessionBean , SessionSynchronization { 39 40 43 private int total = 0; 44 45 48 private int newtotal = 0; 49 50 53 private String clientUser = null; 54 55 59 private SessionContext sessionContext = null; 60 61 62 63 68 public void ejbCreate(String user) { 69 total = 0; 70 newtotal = total; 72 clientUser = user; 73 } 74 75 76 77 92 public void ejbActivate() throws EJBException , java.rmi.RemoteException { 93 } 95 96 113 public void ejbPassivate() throws EJBException , java.rmi.RemoteException { 114 } 116 117 132 public void ejbRemove() throws EJBException , java.rmi.RemoteException { 133 } 135 136 152 public void setSessionContext(SessionContext sessionContext) throws EJBException , java.rmi.RemoteException { 153 this.sessionContext = sessionContext; 154 } 155 156 160 161 178 public void afterBegin() throws EJBException , java.rmi.RemoteException { 179 newtotal = total; 180 } 181 182 200 public void beforeCompletion() throws EJBException , java.rmi.RemoteException { 201 } 202 203 220 public void afterCompletion(boolean committed) throws EJBException , java.rmi.RemoteException { 221 222 if (committed) { 223 total = newtotal; 224 } else { 225 newtotal = total; 226 } 227 } 228 229 230 231 235 public void buy(int s) { 236 newtotal = newtotal + s; 237 return; 238 } 239 240 244 public int read() { 245 return newtotal; 246 } 247 } | Popular Tags |