diff --git a/spring-modulith-events/spring-modulith-events-api/src/main/java/org/springframework/modulith/events/ApplicationModuleListener.java b/spring-modulith-events/spring-modulith-events-api/src/main/java/org/springframework/modulith/events/ApplicationModuleListener.java index 2296f641..7235dd69 100644 --- a/spring-modulith-events/spring-modulith-events-api/src/main/java/org/springframework/modulith/events/ApplicationModuleListener.java +++ b/spring-modulith-events/spring-modulith-events-api/src/main/java/org/springframework/modulith/events/ApplicationModuleListener.java @@ -52,6 +52,8 @@ public @interface ApplicationModuleListener { /** * Whether the transaction to be run for the event listener is supposed to be read-only (default {@literal false}). + * + * @see Transactional#readOnly() */ @AliasFor(annotation = Transactional.class, attribute = "readOnly") boolean readOnlyTransaction() default false; @@ -72,7 +74,7 @@ public @interface ApplicationModuleListener { * {@code ""}, meaning the event is always handled. * * @since 1.2 - * @see EventListener#condition + * @see EventListener#condition() */ @AliasFor(annotation = EventListener.class, attribute = "condition") String condition() default ""; diff --git a/spring-modulith-events/spring-modulith-events-api/src/test/java/org/springframework/modulith/events/ApplicationModuleListenerUnitTests.java b/spring-modulith-events/spring-modulith-events-api/src/test/java/org/springframework/modulith/events/ApplicationModuleListenerUnitTests.java index 7d8db131..68b9e48e 100644 --- a/spring-modulith-events/spring-modulith-events-api/src/test/java/org/springframework/modulith/events/ApplicationModuleListenerUnitTests.java +++ b/spring-modulith-events/spring-modulith-events-api/src/test/java/org/springframework/modulith/events/ApplicationModuleListenerUnitTests.java @@ -16,13 +16,13 @@ package org.springframework.modulith.events; import static org.assertj.core.api.Assertions.*; +import static org.springframework.core.annotation.AnnotatedElementUtils.*; import java.lang.reflect.Method; import org.junit.jupiter.api.Test; import org.springframework.context.event.ApplicationListenerMethodAdapter; import org.springframework.context.event.EventListener; -import org.springframework.core.annotation.AnnotatedElementUtils; import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; @@ -37,7 +37,7 @@ class ApplicationModuleListenerUnitTests { void exposesEventListenerCondition() throws Exception { var method = Sample.class.getDeclaredMethod("someMethod", Object.class); - var annotation = AnnotatedElementUtils.findMergedAnnotation(method, EventListener.class); + var annotation = findMergedAnnotation(method, EventListener.class); assertThat(annotation.condition()).isEqualTo("#{false}"); } @@ -45,9 +45,7 @@ class ApplicationModuleListenerUnitTests { @Test // GH-518 void exposesConditionToAdapter() throws Exception { - var method = Sample.class.getDeclaredMethod("someMethod", Object.class); - - var adapter = new CustomAdapter("someName", Sample.class, method) {}; + var adapter = new CustomAdapter("someName", Sample.class.getDeclaredMethod("someMethod", Object.class)); assertThat(adapter.getCondition()).isEqualTo("#{false}"); } @@ -72,8 +70,8 @@ class ApplicationModuleListenerUnitTests { static class CustomAdapter extends ApplicationListenerMethodAdapter { - public CustomAdapter(String beanName, Class targetClass, Method method) { - super(beanName, targetClass, method); + public CustomAdapter(String beanName, Method method) { + super(beanName, method.getDeclaringClass(), method); } /*