org.openejb.core.transaction
Class TransactionPolicy

java.lang.Object
  extended by org.openejb.core.transaction.TransactionPolicy
Direct Known Subclasses:
CastorCmpEntityTxPolicy, SessionSynchronizationTxPolicy, StatefulBeanManagedTxPolicy, StatefulContainerManagedTxPolicy, StatelessBeanManagedTxPolicy, TxManditory, TxNever, TxNotSupported, TxRequired, TxRequiresNew, TxSupports

public abstract class TransactionPolicy
extends java.lang.Object

Use container callbacks so containers can implement any special behavior Callbacks are similar to sessionsynchronization with the addition of discardInstace createSystemException

Version:
$Revision: 1912 $ $Date: 2005-06-16 15:29:56 -0700 (Thu, 16 Jun 2005) $
Author:
David Blevins

Field Summary
static int BeanManaged
           
protected  TransactionContainer container
           
protected static Logger logger
           
static int Mandatory
           
static int Never
           
static int NotSupported
           
 int policyType
           
static int Required
           
static int RequiresNew
           
static int Supports
           
protected static Logger txLogger
           
 
Constructor Summary
TransactionPolicy()
           
 
Method Summary
abstract  void afterInvoke(javax.ejb.EnterpriseBean bean, TransactionContext context)
           
abstract  void beforeInvoke(javax.ejb.EnterpriseBean bean, TransactionContext context)
           
protected  void beginTransaction()
           
protected  void commitTransaction(javax.transaction.Transaction tx)
           
protected  void discardBeanInstance(javax.ejb.EnterpriseBean instance, ThreadContext callContext)
           
 TransactionContainer getContainer()
           
protected  javax.transaction.TransactionManager getTxMngr()
           
abstract  void handleApplicationException(java.lang.Throwable appException, TransactionContext context)
           
protected  void handleCallbackException()
          18.3.3 Exceptions from container-invoked callbacks
abstract  void handleSystemException(java.lang.Throwable sysException, javax.ejb.EnterpriseBean instance, TransactionContext context)
           
protected  void logSystemException(java.lang.Throwable sysException)
           
protected  void markTxRollbackOnly(javax.transaction.Transaction tx)
           
 java.lang.String policyToString()
           
protected  void resumeTransaction(javax.transaction.Transaction tx)
           
protected  void rollbackTransaction(javax.transaction.Transaction tx)
           
protected  javax.transaction.Transaction suspendTransaction()
           
protected  void throwAppExceptionToServer(java.lang.Throwable appException)
           
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 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

Mandatory

public static final int Mandatory
See Also:
Constant Field Values

Never

public static final int Never
See Also:
Constant Field Values

NotSupported

public static final int NotSupported
See Also:
Constant Field Values

Required

public static final int Required
See Also:
Constant Field Values

RequiresNew

public static final int RequiresNew
See Also:
Constant Field Values

Supports

public static final int Supports
See Also:
Constant Field Values

BeanManaged

public static final int BeanManaged
See Also:
Constant Field Values

policyType

public int policyType

container

protected TransactionContainer container

logger

protected static final Logger logger

txLogger

protected static final Logger txLogger
Constructor Detail

TransactionPolicy

public TransactionPolicy()
Method Detail

getTxMngr

protected javax.transaction.TransactionManager getTxMngr()

getContainer

public TransactionContainer getContainer()

policyToString

public java.lang.String policyToString()

handleApplicationException

public abstract void handleApplicationException(java.lang.Throwable appException,
                                                TransactionContext context)
                                         throws ApplicationException
Throws:
ApplicationException

handleSystemException

public abstract void handleSystemException(java.lang.Throwable sysException,
                                           javax.ejb.EnterpriseBean instance,
                                           TransactionContext context)
                                    throws ApplicationException,
                                           SystemException
Throws:
ApplicationException
SystemException

beforeInvoke

public abstract void beforeInvoke(javax.ejb.EnterpriseBean bean,
                                  TransactionContext context)
                           throws SystemException,
                                  ApplicationException
Throws:
SystemException
ApplicationException

afterInvoke

public abstract void afterInvoke(javax.ejb.EnterpriseBean bean,
                                 TransactionContext context)
                          throws ApplicationException,
                                 SystemException
Throws:
ApplicationException
SystemException

markTxRollbackOnly

protected void markTxRollbackOnly(javax.transaction.Transaction tx)
                           throws SystemException
Throws:
SystemException

suspendTransaction

protected javax.transaction.Transaction suspendTransaction()
                                                    throws SystemException
Throws:
SystemException

resumeTransaction

protected void resumeTransaction(javax.transaction.Transaction tx)
                          throws SystemException
Throws:
SystemException

commitTransaction

protected void commitTransaction(javax.transaction.Transaction tx)
                          throws SystemException
Throws:
SystemException

rollbackTransaction

protected void rollbackTransaction(javax.transaction.Transaction tx)
                            throws SystemException
Throws:
SystemException

throwAppExceptionToServer

protected void throwAppExceptionToServer(java.lang.Throwable appException)
                                  throws ApplicationException
Throws:
ApplicationException

throwTxExceptionToServer

protected void throwTxExceptionToServer(java.lang.Throwable sysException)
                                 throws ApplicationException
Throws:
ApplicationException

throwExceptionToServer

protected void throwExceptionToServer(java.lang.Throwable sysException)
                               throws ApplicationException
Throw RemoteException to remote client; throw EJBException to local client.

Parameters:
sysException -
Throws:
ApplicationException

logSystemException

protected void logSystemException(java.lang.Throwable sysException)

discardBeanInstance

protected void discardBeanInstance(javax.ejb.EnterpriseBean instance,
                                   ThreadContext callContext)

beginTransaction

protected void beginTransaction()
                         throws javax.transaction.SystemException
Throws:
javax.transaction.SystemException

handleCallbackException

protected void handleCallbackException()
18.3.3 Exceptions from container-invoked callbacks

Handles the exceptions thrown from the from the following container-invoked callback methods of the enterprise bean. EntityBean: ? ejbActivate() ? ejbLoad() ? ejbPassivate() ? ejbStore() ? setEntityContext(EntityContext) ? unsetEntityContext() SessionBean: ? ejbActivate() ? ejbPassivate() ? setSessionContext(SessionContext) MessageDrivenBean: ? setMessageDrivenContext(MessageDrivenContext) SessionSynchronization interface: ? afterBegin() ? beforeCompletion() ? and afterCompletion(boolean)

The Container must handle all exceptions or errors from these methods as follows: ? Log the exception or error to bring the problem to the attention of the System Administrator. ? If the instance is in a transaction, mark the transaction for rollback. ? Discard the instance. The Container must not invoke any business methods or container callbacks on the instance. ? If the exception or error happened during the processing of a client invoked method, throw the java.rmi.RemoteException to the client if the client is a remote client or throw the javax.ejb.EJBException to the client if the client is a local client. If the instance executed in the client's transaction, the Container should throw the javax.transaction.TransactionRolledbackException to a remote client or the javax.ejb.TransactionRolledbackLocalException to a local client, because it provides more information to the client. (The client knows that it is fruitless to continue the transaction.)



Copyright © 1999-2011 OpenEJB. All Rights Reserved.