Find TransactionalEventListener annotation on target method

Closes gh-31034
This commit is contained in:
Juergen Hoeller
2023-08-12 11:19:21 +02:00
parent 0c15be004e
commit 6fc4898a1b
2 changed files with 36 additions and 6 deletions

View File

@@ -156,6 +156,17 @@ public class TransactionalEventListenerTests {
getEventCollector().assertNoEventReceived();
}
@Test
public void afterCommitWithTransactionalComponentListenerWithInterfaceProxy() {
load(TransactionalComponentTestListenerWithInterface.class);
this.transactionTemplate.execute(status -> {
getContext().publishEvent("SKIP");
getEventCollector().assertNoEventReceived();
return null;
});
getEventCollector().assertNoEventReceived();
}
@Test
public void afterRollback() {
load(AfterCompletionExplicitTestListener.class);
@@ -525,6 +536,25 @@ public class TransactionalEventListenerTests {
}
interface TransactionalComponentTestInterface {
void handleAfterCommit(String data);
}
@Transactional
@Component
static class TransactionalComponentTestListenerWithInterface extends BaseTransactionalTestListener implements
TransactionalComponentTestInterface {
@TransactionalEventListener(condition = "!'SKIP'.equals(#data)")
@Override
public void handleAfterCommit(String data) {
handleEvent(EventCollector.AFTER_COMMIT, data);
}
}
@Component
static class BeforeCommitTestListener extends BaseTransactionalTestListener {