2009-07-08 7 views
1

TimerServiceに関連して、2つのTimerインスタンスを定義して、各EJBを同じEJB内の@Timeoutというアノテーションを付けた特定の(異なる)メソッドにバインドできますか?TimerService EJB 3

おかげで、 ロッド

+0

なぜこれをやりたいですか? 1つのタイマーで多くのEJBを処理できますか? – skaffman

答えて

2

そうでもありません。

ただし、 2つのタイマー

ctx.getTimerService().createTimer(1000, 1000, "timerA"); 
ctx.getTimerService().createTimer(1000, 1000, "timerB"); 

を定義して、両方のタイマのタイムアウトを処理するために、1つのタイムアウトメソッドを持つことができます。

@Timeout 
    public void handleTimeout(Timer timer) { 
    String info = (String)timer.getInfo(); 
    if ("timerA".equals(info) { handleTimerEventA(); } 
    else if ("timerB".equals(info) { handleTimerEventB(); } 
} 
関連する問題