org.openejb.core.stateful
Class StatefulBeanManagedTxPolicy

java.lang.Object
  extended by org.openejb.core.transaction.TransactionPolicy
      extended by org.openejb.core.stateful.StatefulBeanManagedTxPolicy

public class StatefulBeanManagedTxPolicy
extends TransactionPolicy

Version:
$Revision: 2495 $ $Date: 2006-02-22 23:30:53 -0800 (Wed, 22 Feb 2006) $
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
StatefulBeanManagedTxPolicy()
           
StatefulBeanManagedTxPolicy(TransactionContainer container)
           
 
Method Summary
 void afterInvoke(javax.ejb.EnterpriseBean instance, TransactionContext context)
          In the case of a stateful session bean, it is possible that the business method that started a transaction completes without committing or rolling back the transaction.
 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()
           
protected  void throwExceptionToServer(java.lang.Throwable sysException)
          Throw RemoteException to remote client; throw EJBException to local client.
protected  void throwTxExceptionToServer(java.lang.Throwable sysException)
           
 
Methods inherited from class org.openejb.core.transaction.TransactionPolicy
beginTransaction, commitTransaction, discardBeanInstance, getContainer, getTxMngr, handleCallbackException, logSystemException, markTxRollbackOnly, resumeTransaction, rollbackTransaction, suspendTransaction, throwAppExceptionToServer
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StatefulBeanManagedTxPolicy

public StatefulBeanManagedTxPolicy(TransactionContainer container)

StatefulBeanManagedTxPolicy

public StatefulBeanManagedTxPolicy()
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. If there is a transaction associated with the instance (this would happen if the instance started the transaction in some previous business method), the Container associates the method execution with this transaction. The Container must make the javax.transaction.UserTransaction interface available to the enterprise bean's business method or onMessage method via the javax.ejb.EJBContext interface and under the environment entry java:comp/UserTransaction. When an instance uses the javax.transaction.UserTransaction interface to demarcate a transaction, the Container must enlist all the resource managers used by the instance between the begin() and commit() or rollback() methods with the transaction. When the instance attempts to commit the transaction, the Container is responsible for the global coordination of the transaction commit.

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
In the case of a stateful session bean, it is possible that the business method that started a transaction completes without committing or rolling back the transaction. In such a case, the Container must retain the association between the transaction and the instance across multiple client calls until the instance commits or rolls back the transaction. When the client invokes the next business method, the Container must invoke the business method in this transaction context.

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

throwExceptionToServer

protected void throwExceptionToServer(java.lang.Throwable sysException)
                               throws ApplicationException
Description copied from class: TransactionPolicy
Throw RemoteException to remote client; throw EJBException to local client.

Overrides:
throwExceptionToServer in class TransactionPolicy
Throws:
ApplicationException

throwTxExceptionToServer

protected void throwTxExceptionToServer(java.lang.Throwable sysException)
                                 throws ApplicationException
Overrides:
throwTxExceptionToServer in class TransactionPolicy
Throws:
ApplicationException


Copyright © 1999-2011 OpenEJB. All Rights Reserved.