| Method from org.jboss.ejb.plugins.TxInterceptorCMT Detail: |
protected void checkTransactionStatus(Transaction tx,
InvocationType type) throws TransactionRolledbackException {
if (exceptionRollback)
{
if (log.isTraceEnabled())
log.trace("No exception from ejb, checking transaction status: " + tx);
int status = Status.STATUS_UNKNOWN;
try
{
status = tx.getStatus();
}
catch (Throwable t)
{
log.debug("Ignored error trying to retrieve transaction status", t);
}
if (status != Status.STATUS_ACTIVE)
{
Exception e = new Exception("Transaction cannot be committed (probably transaction timeout): " + tx);
throwJBossException(e, type);
}
}
}
The application has not thrown an exception, but...
When exception-on-rollback is true,
check whether the transaction is not active.
If it did not throw an exception anyway. |
public void create() throws Exception {
super.create();
BeanMetaData bmd = getContainer().getBeanMetaData();
exceptionRollback = bmd.getExceptionRollback();
if (exceptionRollback == false)
exceptionRollback = bmd.getApplicationMetaData().getExceptionRollback();
}
|
public void importXml(Element ielement) {
try
{
Element element = MetaData.getOptionalChild(ielement, "retry-handlers");
if (element == null) return;
ArrayList list = new ArrayList();
Iterator handlers = MetaData.getChildrenByTagName(element, "handler");
while (handlers.hasNext())
{
Element handler = (Element)handlers.next();
String className = MetaData.getElementContent(handler).trim();
Class clazz = SecurityActions.getContextClassLoader().loadClass(className);
list.add(clazz.newInstance());
}
retryHandlers = (TxRetryExceptionHandler[])list.toArray(new TxRetryExceptionHandler[list.size()]);
}
catch (Exception ex)
{
log.warn("Unable to importXml for the TxInterceptorCMT", ex);
}
}
|
public Object invoke(Invocation invocation) throws Exception {
Transaction oldTransaction = invocation.getTransaction();
for (int i = 0; i < MAX_RETRIES; i++)
{
try
{
return runWithTransactions(invocation);
}
catch (Exception ex)
{
checkRetryable(i, ex, oldTransaction);
}
}
throw new RuntimeException("Unreachable");
}
This method does invocation interpositioning of tx management |
public Object invokeHome(Invocation invocation) throws Exception {
Transaction oldTransaction = invocation.getTransaction();
for (int i = 0; i < MAX_RETRIES; i++)
{
try
{
return runWithTransactions(invocation);
}
catch (Exception ex)
{
checkRetryable(i, ex, oldTransaction);
}
}
throw new RuntimeException("Unreachable");
}
|
public static ApplicationDeadlockException isADE(Throwable t) {
// Static --------------------------------------------------------
while (t!=null)
{
if (t instanceof ApplicationDeadlockException)
{
return (ApplicationDeadlockException)t;
}
else if (t instanceof RemoteException)
{
t = ((RemoteException)t).detail;
}
else if (t instanceof EJBException)
{
t = ((EJBException)t).getCausedByException();
}
else
{
return null;
}
}
return null;
}
Detects exception contains is or a ApplicationDeadlockException. |
public void resetStatistic() {
}
|
public Map retrieveStatistic() {
return null;
}
|
public void sample(Object s) {
// Just here to because Monitorable request it but will be removed soon
}
|
protected void throwJBossException(Exception e,
InvocationType type) throws TransactionRolledbackException {
// Unwrap a nested exception if possible. There is no
// point in the extra wrapping, and the EJB spec should have
// just used javax.transaction exceptions
if (e instanceof NestedException)
{
NestedException rollback = (NestedException) e;
if(rollback.getCause() instanceof Exception)
{
e = (Exception) rollback.getCause();
}
}
if (type == InvocationType.LOCAL
|| type == InvocationType.LOCALHOME)
{
throw new JBossTransactionRolledbackLocalException(e);
}
else
{
throw new JBossTransactionRolledbackException(e);
}
}
Rethrow the exception as a rollback or rollback local |