spring eventListener with external condition

前端 未结 1 736
被撕碎了的回忆
被撕碎了的回忆 2021-01-12 06:35

I need a flexible filters for FooEvents for multiple EventListeners all over my code. I can use @EventListener(condition=\"event.enabled\"), but my filters requ

1条回答
  •  离开以前
    2021-01-12 07:36

    You're using the wrong definition, as fooPredicate is a spring bean you need to use '@' instead of '#' to resolve it as a bean. see 10.5.13 Bean references

    @EventListener(condition="@fooPredicate.test(#event)")
    public void handle(FooEvent event) {
        System.out.println();
    }
    

    0 讨论(0)
提交回复
热议问题