In addition to specifying the event type to listen to via a method
parameter, any @EventListener annotated method can now alternatively
define the event type(s) to listen to via the "classes" attributes (that
is aliased to "value").
Something like
@EventListener({FooEvent.class, BarEvent.class})
public void handleFooBar() { .... }
Issue: SPR-13156
@ -66,7 +69,7 @@ public class ApplicationListenerMethodAdapter implements GenericApplicationListe
@@ -66,7 +69,7 @@ public class ApplicationListenerMethodAdapter implements GenericApplicationListe
@ -76,12 +79,14 @@ public class ApplicationListenerMethodAdapter implements GenericApplicationListe
@@ -76,12 +79,14 @@ public class ApplicationListenerMethodAdapter implements GenericApplicationListe
@ -122,19 +127,20 @@ public class ApplicationListenerMethodAdapter implements GenericApplicationListe
@@ -122,19 +127,20 @@ public class ApplicationListenerMethodAdapter implements GenericApplicationListe
@ -178,14 +184,18 @@ public class ApplicationListenerMethodAdapter implements GenericApplicationListe
@@ -178,14 +184,18 @@ public class ApplicationListenerMethodAdapter implements GenericApplicationListe
@ -240,6 +250,13 @@ public class ApplicationListenerMethodAdapter implements GenericApplicationListe
@@ -240,6 +250,13 @@ public class ApplicationListenerMethodAdapter implements GenericApplicationListe
@ -305,13 +322,48 @@ public class ApplicationListenerMethodAdapter implements GenericApplicationListe
@@ -305,13 +322,48 @@ public class ApplicationListenerMethodAdapter implements GenericApplicationListe
@ -113,6 +113,36 @@ public class ApplicationListenerMethodAdapterTests extends AbstractApplicationEv
@@ -113,6 +113,36 @@ public class ApplicationListenerMethodAdapterTests extends AbstractApplicationEv
@ -131,6 +161,15 @@ public class ApplicationListenerMethodAdapterTests extends AbstractApplicationEv
@@ -131,6 +161,15 @@ public class ApplicationListenerMethodAdapterTests extends AbstractApplicationEv
@ -249,6 +288,40 @@ public class ApplicationListenerMethodAdapterTests extends AbstractApplicationEv
@@ -249,6 +288,40 @@ public class ApplicationListenerMethodAdapterTests extends AbstractApplicationEv
@ -321,14 +394,32 @@ public class ApplicationListenerMethodAdapterTests extends AbstractApplicationEv
@@ -321,14 +394,32 @@ public class ApplicationListenerMethodAdapterTests extends AbstractApplicationEv
@ -339,6 +430,10 @@ public class ApplicationListenerMethodAdapterTests extends AbstractApplicationEv
@@ -339,6 +430,10 @@ public class ApplicationListenerMethodAdapterTests extends AbstractApplicationEv
@ -36,7 +39,7 @@ public class ApplicationListenerMethodTransactionalAdapterTests {
@@ -36,7 +39,7 @@ public class ApplicationListenerMethodTransactionalAdapterTests {
@ -46,24 +49,54 @@ public class ApplicationListenerMethodTransactionalAdapterTests {
@@ -46,24 +49,54 @@ public class ApplicationListenerMethodTransactionalAdapterTests {
@ -76,6 +109,15 @@ public class ApplicationListenerMethodTransactionalAdapterTests {
@@ -76,6 +109,15 @@ public class ApplicationListenerMethodTransactionalAdapterTests {
@ -7900,6 +7900,19 @@ As you can see above, the method signature actually _infer_ which even type it l
@@ -7900,6 +7900,19 @@ As you can see above, the method signature actually _infer_ which even type it l
also works for nested generics as long as the actual event resolves the generics parameter you
would filter on.
If your method should listen to several events or if you want to define it with no
parameter at all, the event type(s) can also be specified on the annotation itself: