As per spring's Event handling mechanism, we can use SpEL to select a specific handler under some circumstances. Taken from the spring doc.
public class EventXHandler {
private String handlerClassName;
@EventListener(condition = "#event.name == handlerClassName")
public void processBlockedListEvent(BlockedListEvent event) {
// notify appropriate parties via notificationAddress...
}
}
My question is; if I can access to the handler class' property in the spel.
CodePudding user response:
No; you cannot do that.
If you know the bean name and add a public
getter for the property, you can use
#event.name == @beanName.handlerClassName
.