I have a question. At work we are currently experi...
# spring
m
I have a question. At work we are currently experimenting with Kotlin and Spring Boot. One of the nice things of Java and Spring Boot was, that if you had something like "public interface EventProcessor<T>" in Java you could autowire a list of classes that implement that interface. While trying to do this today with Kotlin it didn't work. Why is that so? And is there an alternative to do a similar thing "the kotlin way"? Currently we just transform the object and based on the type we execute a different processor. This is done via a "when (x)..." but that isn't as nice.
n
could you share the code? because that works in exactly the same way
m
will do, give me one second
this is the interface
Copy code
interface EventProcessor<T> {
    
    fun process()
}
how can I properly share code? 😄
c
` ``` `
m
Copy code
@Service
class SomeEventProcessor() : EventProcessor<LegacyEvent>{
    override fun process() { 
    }

}
c
when it's large, use insert snippet
m
Copy code
@Service
class EventProcessorHandler(val processors: List<EventProcessor>)
then this is the code that doesn't work
In java it would have worked
any idea why?
@nfrankel
and thanks @Czar
c
@Martin Schwitalla Your example works for me after I fix syntax errors. Take a look at a snipped I've posted.