org.ow2.easybeans.examples.statefulbean
Class StatefulBean

java.lang.Object
  extended by org.ow2.easybeans.examples.statefulbean.StatefulBean
All Implemented Interfaces:
javax.ejb.SessionSynchronization, StatefulRemote

public class StatefulBean
extends java.lang.Object
implements javax.ejb.SessionSynchronization, StatefulRemote

Simple stateful bean.

Author:
Florent Benoit

Constructor Summary
StatefulBean()
          Initialize the amounts for with and without Tx.
 
Method Summary
 void afterBegin()
          The afterBegin method notifies a session Bean instance that a new transaction has started, and that the subsequent business methods on the instance will be invoked in the context of the transaction.
 void afterCompletion(boolean committed)
          The afterCompletion method notifies a session Bean instance that a transaction commit protocol has completed, and tells the instance whether the transaction has been committed or rolled back.
 void beforeCompletion()
          The beforeCompletion method notifies a session Bean instance that a transaction is about to be committed.
 void buy(int s)
          Business method implementation.
 int read()
          Business method implementation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StatefulBean

public StatefulBean()
Initialize the amounts for with and without Tx.

Method Detail

afterBegin

public void afterBegin()
                throws java.rmi.RemoteException
The afterBegin method notifies a session Bean instance that a new transaction has started, and that the subsequent business methods on the instance will be invoked in the context of the transaction. The instance can use this method, for example, to read data from a database and cache the data in the instance fields. This method executes in the proper transaction context.

Specified by:
afterBegin in interface javax.ejb.SessionSynchronization
Throws:
java.rmi.RemoteException - - This exception is defined in the method signature to provide backward compatibility for enterprise beans written for the EJB 1.0 specification. Enterprise beans written for the EJB 1.1 and higher specifications should throw the javax.ejb.EJBException instead of this exception. Enterprise beans written for the EJB 2.0 and higher specifications must not throw the java.rmi.RemoteException.

beforeCompletion

public void beforeCompletion()
                      throws java.rmi.RemoteException
The beforeCompletion method notifies a session Bean instance that a transaction is about to be committed. The instance can use this method, for example, to write any cached data to a database. This method executes in the proper transaction context. Note: The instance may still cause the container to rollback the transaction by invoking the setRollbackOnly() method on the instance context, or by throwing an exception.

Specified by:
beforeCompletion in interface javax.ejb.SessionSynchronization
Throws:
java.rmi.RemoteException - - This exception is defined in the method signature to provide backward compatibility for enterprise beans written for the EJB 1.0 specification. Enterprise beans written for the EJB 1.1 and higher specifications should throw the javax.ejb.EJBException instead of this exception. Enterprise beans written for the EJB 2.0 and higher specifications must not throw the java.rmi.RemoteException.

afterCompletion

public void afterCompletion(boolean committed)
                     throws java.rmi.RemoteException
The afterCompletion method notifies a session Bean instance that a transaction commit protocol has completed, and tells the instance whether the transaction has been committed or rolled back. This method executes with no transaction context.

Specified by:
afterCompletion in interface javax.ejb.SessionSynchronization
Parameters:
committed - - True if the transaction has been committed, false if is has been rolled back.
Throws:
java.rmi.RemoteException - - This exception is defined in the method signature to provide backward compatibility for enterprise beans written for the EJB 1.0 specification. Enterprise beans written for the EJB 1.1 and higher specifications should throw the javax.ejb.EJBException instead of this exception. Enterprise beans written for the EJB 2.0 and higher specifications must not throw the java.rmi.RemoteException.

buy

public void buy(int s)
Business method implementation.

Specified by:
buy in interface StatefulRemote
Parameters:
s - nb of shares to be bought

read

public int read()
Business method implementation.

Specified by:
read in interface StatefulRemote
Returns:
the nb of shares bought


Copyright © 2006-2011 OW2 Consortium. All Rights Reserved.