Due to Java type erasure, currently I have to manually determine the type of the event's config when listening to this event:
@Component
class EurekaInstanceConfigPostProcessor(
private val eureka: EurekaRegistration,
) : ApplicationListener<InstanceRegisteredEvent<*>> {
override fun onApplicationEvent(event: InstanceRegisteredEvent<*>) {
if (event.config is EurekaInstanceConfigBean){
eureka.applicationInfoManager.registerAppMetadata(......)
}
}
}
If InstanceRegisteredEvent can implement ResolvableTypeProvider, i can directly listening and set it's config type:
@Component
class EurekaInstanceConfigPostProcessor(
private val eureka: EurekaRegistration,
) : ApplicationListener<InstanceRegisteredEvent<EurekaInstanceConfigBean>> {
override fun onApplicationEvent(event: InstanceRegisteredEvent<EurekaInstanceConfigBean>) {
eureka.applicationInfoManager.registerAppMetadata(......)
}
}
Due to Java type erasure, currently I have to manually determine the type of the event's config when listening to this event:
If InstanceRegisteredEvent can implement ResolvableTypeProvider, i can directly listening and set it's config type:
https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/core/ResolvableTypeProvider.html