Search code examples
javaspringspring-el

Spring Expression Language - Is it possible to use #this in SEL


I have a base class where I am annotating method with

@kafkaListener(topics=#{beanName.topicName}).

Every subclass extending a base class could have a unique topicName to which they will be listening to.

Every subclass is a registered bean.

Now what I want to do is, have the method annotated with kafkaListener in the baseClass, I don't want to move it to the subClass. The bean names are going to be different for every subclass. So is there any way I can make the assignment of

topics=#{beanName.topicName}

generalised?

I have tried #{this.topicName} but that does not work.

Thank you in advance.


Solution

  • A reference to the current bean or bean name is not available to the SpEL evaluation.

    Pull Request issued.