A basic rule could be like RSPEC-2230: detection @TransactionAttribute annotation on non-public methods.
Non-compliant code:
@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
void doTheThing(ArgClass arg) {
// ...
}
This could be extended to checking whether public methods with a @TransactionAttribute annotation are called from within the bean. According to the spec and real-life tests, this has no effect.
Non-compliant code:
// attribute on public method is compliant
@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
public void doTheThingAndMoreOfIt(ArgClass arg) {
doTheThing(ArgClass arg); // ...but this call is non-compliant, or at least a code smell
// ...
}
// attribute on public method is compliant
@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
public void doTheThing(ArgClass arg) {
// ...
}
Some background: