org.openejb.core.stateless
Class StatelessBeanManagedTxPolicy

java.lang.Object
  extended by org.openejb.core.transaction.TransactionPolicy
      extended by org.openejb.core.stateless.StatelessBeanManagedTxPolicy

public class StatelessBeanManagedTxPolicy
extends TransactionPolicy

Transaction policy for Stateless Session beans with bean-managed transaction demarcation.

Version:
$Revision: 1096 $ $Date: 2004-03-26 13:41:16 -0800 (Fri, 26 Mar 2004) $
Author:
David Blevins

Field Summary
 
Fields inherited from class org.openejb.core.transaction.TransactionPolicy
BeanManaged, container, logger, Mandatory, Never, NotSupported, policyType, Required, RequiresNew, Supports, txLogger
 
Constructor Summary
StatelessBeanManagedTxPolicy()
           
StatelessBeanManagedTxPolicy(TransactionContainer container)
           
 
Method Summary
 void afterInvoke(javax.ejb.EnterpriseBean instance, TransactionContext context)
          If a stateless session bean instance starts a transaction in a business method, it must commit the transaction before the business method returns.
 void beforeInvoke(javax.ejb.EnterpriseBean instance, TransactionContext context)
          When a client invokes a business method via the enterprise bean?s home or component interface, the Container suspends any transaction that may be associated with the client request.
 void handleApplicationException(java.lang.Throwable appException, TransactionContext context)
          Container's action
 void handleSystemException(java.lang.Throwable sysException, javax.ejb.EnterpriseBean instance, TransactionContext context)
          A system exception is any exception that is not an Application Exception.
 java.lang.String policyToString()
           
 
Methods inherited from class org.openejb.core.transaction.TransactionPolicy
beginTransaction, commitTransaction, discardBeanInstance, getContainer, getTxMngr, handleCallbackException, logSystemException, markTxRollbackOnly, resumeTransaction, rollbackTransaction, suspendTransaction, throwAppExceptionToServer, throwExceptionToServer, throwTxExceptionToServer
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StatelessBeanManagedTxPolicy

public StatelessBeanManagedTxPolicy(TransactionContainer container)

StatelessBeanManagedTxPolicy

public StatelessBeanManagedTxPolicy()
Method Detail

policyToString

public java.lang.String policyToString()
Overrides:
policyToString in class TransactionPolicy

beforeInvoke

public void beforeInvoke(javax.ejb.EnterpriseBean instance,
                         TransactionContext context)
                  throws SystemException,
                         ApplicationException
When a client invokes a business method via the enterprise bean?s home or component interface, the Container suspends any transaction that may be associated with the client request.

Specified by:
beforeInvoke in class TransactionPolicy
Parameters:
instance -
context -
Throws:
SystemException
ApplicationException

afterInvoke

public void afterInvoke(javax.ejb.EnterpriseBean instance,
                        TransactionContext context)
                 throws ApplicationException,
                        SystemException
If a stateless session bean instance starts a transaction in a business method, it must commit the transaction before the business method returns. The Container must detect the case in which a transaction was started, but not completed, in the business method, and handle it as follows: ? Log this as an application error to alert the system administrator. ? Roll back the started transaction. ? Discard the instance of the session bean. ? Throw the java.rmi.RemoteException to the client if the client is a remote client, or throw the javax.ejb.EJBException if the client is a local client.

Specified by:
afterInvoke in class TransactionPolicy
Parameters:
instance -
context -
Throws:
ApplicationException
SystemException

handleApplicationException

public void handleApplicationException(java.lang.Throwable appException,
                                       TransactionContext context)
                                throws ApplicationException
Container's action

Re-throw AppException

Client's view

Client receives AppException.

Specified by:
handleApplicationException in class TransactionPolicy
Throws:
ApplicationException

handleSystemException

public void handleSystemException(java.lang.Throwable sysException,
                                  javax.ejb.EnterpriseBean instance,
                                  TransactionContext context)
                           throws ApplicationException,
                                  SystemException
A system exception is any exception that is not an Application Exception. Container's action

  1. Log the exception or error so that the System Administrator is alerted of the problem.
  2. Mark for rollback a transaction that has been started, but not yet completed, by the instance.
  3. Discard instance. The Container must not invoke any business methods or container callbacks on the instance.
  4. Throw RemoteException to remote client; throw EJBException to local client.

Client's view

Receives RemoteException or EJBException.

Specified by:
handleSystemException in class TransactionPolicy
Throws:
ApplicationException
SystemException


Copyright © 1999-2011 OpenEJB. All Rights Reserved.