如何在jpbm 4.2 EventListener中获取spring上下文引用?
如何从 EventListener 实例中获取 spring 上下文,该实例在流程转换后会收到通知:
<transition g="-36,11" name="A" to="B">
<event-listener class="com.test.handlers.MyRequestHandler">
</event-listener>
</transition>
我希望能够
@Override
public void notify(EventListenerExecution execution) throws Exception {
..
MyOtherSpringBean sender = (MyOtherSpringBean )applicationContext.get("MyOtherSpringBean ");
在提前感谢
Denis中执行类似以下操作
How to obtain spring context from within EventListener instance which gets notified following this transition of process:
<transition g="-36,11" name="A" to="B">
<event-listener class="com.test.handlers.MyRequestHandler">
</event-listener>
</transition>
I want to be able to do something like the following in my
@Override
public void notify(EventListenerExecution execution) throws Exception {
..
MyOtherSpringBean sender = (MyOtherSpringBean )applicationContext.get("MyOtherSpringBean ");
Thanks in advance,
Denis
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以让您的
EventListener
成为 spring 上下文的一部分,因此您可以将其他 bean 注入其中(使用@Autowired private MyOtherSpringBean bean
)请参阅 此线程,以及此问题
You can have your
EventListener
be part of the spring context, and hence you can inject other beans into it (using@Autowired private MyOtherSpringBean bean
)See this thread, and this issue