}
}
@Override
protected Object handleInvocation(final InterceptorContext invocation) throws Exception {
final StatefulSessionComponentInstance instance = (StatefulSessionComponentInstance) invocation.getPrivateData(ComponentInstance.class);
TransactionManager tm = getComponent().getTransactionManager();
assert tm.getTransaction() == null : "can't handle BMT transaction, there is a transaction active";
// Is the instance already associated with a transaction?
Transaction tx = instance.getTransaction();
if (tx != null) {
// then resume that transaction.
instance.setTransaction(null);
tm.resume(tx);
}
try {
return invocation.proceed();
} catch (Throwable e) {
throw this.handleException(invocation, e);
} finally {
checkBadStateful();
// Is the instance finished with the transaction?
Transaction newTx = tm.getTransaction();
//always set it, even if null
instance.setTransaction(newTx);
if (newTx != null) {
// remember the association
// and suspend it.
tm.suspend();
}