如何使用参数化名称监听所有Seam上下文事件? [英] How do I listen to all Seam contextual events with parameterized names?

查看:151
本文介绍了如何使用参数化名称监听所有Seam上下文事件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

接缝将触发不同类型的事件涉及特定范围,任务或过程,并将范围,任务或过程的名称附加到事件结束。

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?

例如对于任何< name> 我想听听这些事件:

E.g. for any <name> I'd like to listen to events such as these:


  • org.jboss.seam.createProcess。< name> - 创建流程时调用

  • org.jboss.seam.endProcess。< name> - 当进程结束

  • org.jboss.seam时调用。 initProcess。< name> - 当进程与会话关联时调用

  • org.jboss.seam.startTask。名称> - 任务启动时调用

  • org.jboss.seam.endTask。< name> - 任务结束时调用

  • org.jboss.seam.createProcess.<name> — called when the process is created
  • org.jboss.seam.endProcess.<name> — called when the process ends
  • org.jboss.seam.initProcess.<name> — called when the process is associated with the conversation
  • org.jboss.seam.startTask.<name> — called when the task is started
  • org.jboss.seam.endTask.<name> — called when the task is ended

尽管不知道有效名称列表,我仍然需要这样做 up front ...: - (

I need to do this despite not knowing the list of valid names up front... :-(

我希望使用@Observer创建观察者,或类似的东西,我会听最多两个事件类在同一个组件中。

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.

推荐答案

您可以轻松地通过replaci ng Seam的活动课程与您自己的实现。然后查找以特定字符串开头的事件:

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:

@Scope(ScopeType.STATELESS)
@BypassInterceptors
@Name("org.jboss.seam.core.events")
@Install(precedence=APPLICATION)
public class Events extends org.jboss.seam.core.Events
{
   @Override
   public void raiseEvent(String type, Object... parameters )
   {
       super.raiseEvent( type, parameters );

       if ( type.startsWith( "org.jboss.seam.createProcess" ) )
       {
           super.raiseEvent( "org.jboss.seam.createProcess", parameters );
       }
       //etc.
   }
}

您现在可以观察org.jboss.seam createProcess来获取所有的createProcess事件。

You can now observe "org.jboss.seam.createProcess" to get all createProcess events.

这篇关于如何使用参数化名称监听所有Seam上下文事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆