org.openejb.core.transaction
Class TxRequiresNew
java.lang.Object
org.openejb.core.transaction.TransactionPolicy
org.openejb.core.transaction.TxRequiresNew
public class TxRequiresNew
- extends TransactionPolicy
17.6.2.4 RequiresNew
The Container must invoke an enterprise Bean method whose transaction
attribute is set to RequiresNew with a new transaction context.
If the client invokes the enterprise Bean?s method while the client is not
associated with a transaction context, the container automatically starts a
new transaction before delegating a method call to the enterprise Bean
business method. The Container automatically enlists all the resource
managers accessed by the business method with the transaction. If the
business method invokes other enterprise beans, the Container passes the
transaction context with the invocation. The Container attempts to commit
the transaction when the business method has completed. The container
performs the commit protocol before the method result is sent to the client.
If a client calls with a transaction context, the container suspends the
association of the transaction context with the current thread before
starting the new transaction and invoking the business method. The container
resumes the suspended transaction association after the business method and
the new transaction have been completed.
- Version:
- $Revision: 1912 $ $Date: 2005-06-16 15:29:56 -0700 (Thu, 16 Jun 2005) $
- Author:
- David Blevins
Fields inherited from class org.openejb.core.transaction.TransactionPolicy |
BeanManaged, container, logger, Mandatory, Never, NotSupported, policyType, Required, RequiresNew, Supports, txLogger |
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 |
TxRequiresNew
public TxRequiresNew(TransactionContainer container)
TxRequiresNew
public TxRequiresNew()
policyToString
public java.lang.String policyToString()
- Overrides:
policyToString
in class TransactionPolicy
beforeInvoke
public void beforeInvoke(javax.ejb.EnterpriseBean instance,
TransactionContext context)
throws SystemException,
ApplicationException
- Specified by:
beforeInvoke
in class TransactionPolicy
- Throws:
SystemException
ApplicationException
afterInvoke
public void afterInvoke(javax.ejb.EnterpriseBean instance,
TransactionContext context)
throws ApplicationException,
SystemException
- Specified by:
afterInvoke
in class TransactionPolicy
- Throws:
ApplicationException
SystemException
handleApplicationException
public void handleApplicationException(java.lang.Throwable appException,
TransactionContext context)
throws ApplicationException
- Container's action
If the instance called setRollbackOnly(), then rollback the transaction,
and re-throw AppException.
Otherwise, attempt to commit the transaction, and then re-throw
AppException.
Client's view
Receives AppException.
If the client executes in a transaction, the client's transaction is not
marked for rollback, and client can continue its work.
- 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
-
Log the exception or error so that the System Administrator is alerted of
the problem.
-
Rollback the container-started transaction.
-
Discard instance. The Container must not invoke any business methods or
container callbacks on the instance.
-
Throw RemoteException to remote client;
throw EJBException to local client.
Client's view
Receives RemoteException or EJBException
If the client executes in a transaction, the client's transaction may or
may not be marked for rollback.
- Specified by:
handleSystemException
in class TransactionPolicy
- Throws:
ApplicationException
SystemException
Copyright © 1999-2011 OpenEJB. All Rights Reserved.