アプリケーション存続時間中に、単一 EAR ファイル内の個々の J2EE コンポーネント (サーブレット またはエンタープライズ Bean) は、互いにシグナル通知する必要があります。java:comp ネーム・スペースには、 通知で使用可能な EAR ファイル内のすべてのコンポーネントにバインドされるイベント・ソースがあります。
java:comp/websphere/ApplicationNotificationService
同じアプリケーション内のコンポーネントは、 非同期イベントを発行し、このアプリケーション通知サービスを使用してイベント・リスナーを登録します。 開始 Bean を使用すると、 このようなイベント・リスナーをアプリケーションの始動時に登録することができます。 開始 Bean を使用しない場合、イベント・リスナーは、実行時に動的に登録されます。
InitialContext ic = new InitialContext(); EventSource appES = (EventSource) ic.lookup("java:comp/websphere/ApplicationNotificationService"); // now, the application can add a listener using the EventSource.addListener method. // MyEventType is an interface. MyEventType myListener = ...; AppES.addListener(myListener); // later another component can fire events as follows InitialContext ic = new InitialContext(); EventSource appES = (EventSource) ic.lookup("java:comp/websphere/ApplicationNotificationService"); // This highlights a constant string on the EventSource interface which // specifies the 'java:comp/websphere/ApplicationNotificationService' string. ic.lookup(appES.APPLICATION_NOTIFICATION_EVENT_SOURCE) // now, the application can add a listener using the EventSource.addListener method. MyEventType proxy = appES.getEventTrigger(MyEventType.class, false); proxy.someEvent(someArguments);