I am planning to write an interceptor for an EJB that will do basically the following:
@AroundInvoke
public Object setContext(InvocationContext ctx) throws E
You can inject a TransactionSynchronizationRegistry and use getTransactionStatus to get the status of the transaction in the current context, it returns an int
which is a contant in the Status class, in your case you are looking for STATUS_NO_TRANSACTION
Inject:
@Resource
TransactionSynchronizationRegistry tsr;
Check Transaction Status:
if (Status.STATUS_NO_TRANSACTION == tsr.getTransactionStatus()) {
// no transaction
}