GH-1461: added early tests for event type hierarchy support

This commit is contained in:
Martin Lippert
2025-02-03 09:22:03 +01:00
parent 0a30bdeba8
commit cace5e3ad5
3 changed files with 37 additions and 0 deletions

View File

@@ -0,0 +1,4 @@
package com.example.events.demo;
public class SpecializedCustomEvent extends CustomEvent {
}

View File

@@ -0,0 +1,19 @@
package com.example.events.demo;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.stereotype.Component;
@Component
public class SpecializedCustomEventPublisher {
private ApplicationEventPublisher publisher;
public SpecializedCustomEventPublisher(ApplicationEventPublisher publisher) {
this.publisher = publisher;
}
public void foo() {
this.publisher.publishEvent(new SpecializedCustomEvent());
}
}

View File

@@ -1,5 +1,6 @@
package com.example.events.demo;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
@@ -15,5 +16,18 @@ public class TestEventsIndexingApplication {
public EventListenerPerInterfaceAndBeanMethod listenerBean() {
return new EventListenerPerInterfaceAndBeanMethod();
}
@Bean
public CommandLineRunner runner(CustomEventPublisher pub, SpecializedCustomEventPublisher specialPub) {
return new CommandLineRunner() {
@Override
public void run(String... args) throws Exception {
System.out.println("RUN!!!");
pub.foo();
specialPub.foo();
}
};
}
}