我如何监听所有具有参数化名称的 Seam 上下文事件?
Seam 将触发不同类型的事件 与特定范围、任务或流程相关,并将范围、任务或流程的名称附加到事件末尾。
如何监听某个类型的所有事件?
例如,对于任何
,我想监听以下事件:
org.jboss.seam.createProcess.
- 当进程时调用创建org.jboss.seam.endProcess.
— 当进程结束时调用org.jboss.seam.initProcess.
— 当进程结束时调用进程与会话org.jboss.seam.startTask.
关联 — 在任务启动时调用org.jboss.seam.endTask.
> - 在任务结束时调用
我需要执行此操作尽管事先不知道有效名称列表... :-(
我希望使用 @Observer 来创建观察者或其他东西类似,我将在同一组件中监听最多两个事件类。
Seam will fire different kinds of events that relate to particular scopes, tasks, or processes and appends the name of the scope, task or process to the end of the event.
How do I listen to all the events of a type?
E.g. for any <name>
I'd like to listen to events such as these:
org.jboss.seam.createProcess.<name>
— called when the process is createdorg.jboss.seam.endProcess.<name>
— called when the process endsorg.jboss.seam.initProcess.<name>
— called when the process is associated with the conversationorg.jboss.seam.startTask.<name>
— called when the task is startedorg.jboss.seam.endTask.<name>
— called when the task is ended
I need to do this despite not knowing the list of valid names up front... :-(
I hope to be using @Observer to create the observer, or something similar, and I'll listen to up to two event classes in the same component.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以通过用您自己的实现替换 Seam 的 Events 类来轻松地做到这一点。 然后查找以特定字符串开头引发的事件:
您现在可以观察“org.jboss.seam.createProcess”来获取所有 createProcess 事件。
You can easily do this by replacing Seam's Events class with your own implementation. Then look for events that are raised that start with a particular string:
You can now observe "org.jboss.seam.createProcess" to get all createProcess events.
在 if 内部,您必须编写 super.raiseEvent(...) 否则您将得到无限循环。
Inside the if, you must write super.raiseEvent(...) otherwise you'll get an infinite loop.