• 検索結果がありません。

: 通知リ スナの作成

ドキュメント内 logging.book (ページ 30-35)

4 WebLogic Server ログからのメ ッ セージのリ スン

手順 1 : 通知リ スナの作成

手順 2 : 通知 リ スナの登録

手順 3 : 通知フ ィ ルタの作成 と 登録

注意

:

アプ リ ケーシ ョ ンが WebLogic Server JVM の外部で実行さ れ る場合、 そ のアプ リ ケーシ ョ ンは WebLogic Server ロ グ通知を リ ス ンでき ますが、

WebLogic

ロ ギ ング サービ ス を利用し て メ ッ セージ をブロー ド キ ャ ス ト する こ と はで き ません。

手順 1 : 通知リ スナの作成

通知 リ スナを作成する ための手順は、 アプ リ ケーシ ョ ンが WebLogic Server JVM 内で実行さ れて い る かど う かに よ っ て異な り ます。

こ の節では、 以下の項目について説明し ます。

MyNotificationListener LogBroadcasterRuntimeMBean

handleNotification() 登録 リ スナ :

MyNotificationListener

WebLogicLogNotification

手順

1 :

通知 リ ス ナの作成

WebLogic Server JVM

内で実行 さ れる アプ リ ケーシ ョ ン用の通知 リ スナの作 成

リ モー ト アプ リ ケーシ ョ ン用の通知 リ スナの作成

WebLogic Server JVM 内で実行されるアプ リ ケー シ ョ ン用の通知リ スナの作成

アプ リ ケーシ ョ ンが WebLogic Server JVM 内で実行さ れる場合、次の手順に従い ます。

1.

javax.management.Notification.*イ ン タ フ ェース を イ ンポー ト し ます。

WebLogic Server はすでに こ れ ら の イ ン タ フ ェース を持ち、 ク ラ スパス上に

あ る こ と を要求し てい る ため、 ク ラ スに入れ る必要があ るのは イ ンポー ト 文 のみです。

2.

NotificationListenerを実装する ク ラ ス を作成し ます。 実装には NotificationListener.handleNotification() メ ソ ッ ド を含め る必要が あ り ます。

NotificationListenerの詳細については、

javax.management.Notification

Javadoc

http://jcp.org/aboutJava/communityprocess/final/jsr003/index.html

) を参照し て く だ さ い。

図 4-2 に、 JSP が WebLogic Server JVM 内で実行さ れて い る シ ス テ ムを示し ま す。 JSP は、LogBroadcasterRuntimeMBean

か ら の通知を リ ス ン し ます。

4 WebLogic Server

ログからの メ ッ セージの リ ス ン

4-2

ローカル

JSP

用のリ スナ

コー ド リ ス ト 4-1に、 ローカル ク ラ イ アン ト の通知 リ スナの例を示し ます。 こ の リ スナは、WebLogicLogNotification

ゲ ッ ター メ ソ ッ ド を使用し て、 受信し

たすべての メ ッ セージ を出力し ます。 詳細については、

4-13

ページの

「WebLogicLogNotification オブジ ェ ク ト 」 を参照し てく だ さ い。

コー ド リ ス ト

4-1

ローカル ク ラ イアン ト 用の通知リ スナの例

import javax.management.Notification;

import javax.management.NotificationFilter;

import javax.management.NotificationListener;

import javax.management.Notification.*;

...

public class MyNotificationListener implements NotificationListener {

...

public void handleNotification(Notification notification, Object obj) { WebLogicLogNotification wln = (WebLogicLogNotification)notification;

System.out.println("WebLogicLogNotification");

System.out.println(" type = " + wln.getType());

System.out.println(" message id = " + wln.getMessageId());

System.out.println(" server name = " + wln.getServername());

System.out.println(" timestamp = " + wln.getTimeStamp());

System.out.println(" message = " + wln.getMessage() + "\n");

}

JSP

MyNotificationListener LogBroadcasterRuntimeMBean

MBean

handleNotification() WebLogic Server JVM

手順

1 :

通知 リ ス ナの作成

リ モー ト アプ リ ケーシ ョ ン用の通知リ スナの作成

アプ リ ケーシ ョ ンが WebLogic Server JVM の外部で実行さ れ る場合、次の手順に 従います。

1.

WL_HOME/server/lib/weblogic_sp.jar

WL_HOME/server/lib/weblogic.jarがアプ リ ケーシ ョ ンの ク ラ スパスにあ る こ と を確認し ます。

2.

javax.management.Notification.*イ ン タ フ ェース を イ ンポー ト し ます。

3.

weblogic.management.RemoteNotificationListenerを実装する ク ラ ス を 作成し ます。RemoteNotificationListener

MBean は、

javax.management.NotificationListener

および

java.rmi

を拡張する こ

と に よ っ て 、 RMI を介し てリ モー ト アプ リ ケーシ ョ ンで通知を使用でき る よ う に し ます。

実装には RemoteNotificationListener.handleNotification() メ ソ ッ ド を含め る必要があ り ます。 詳細については、

weblogic.management.RemoteNotificationListener

Javadoc

を参照し て く だ さ い。

図 4-3に、 JSP が WebLogic Server JVM 内で実行さ れ、 アプ リ ケーシ ョ ンが リ モー ト JVM で実行 さ れる シ ス テム を示し ます。 メ ッ セージ を リ ス ンする ために、

JSP

は NotificationListenerを実装し、 リ モー ト アプ リ ケーシ ョ ンは RemoteNotificationListenerを実装し ます。

4 WebLogic Server

ログからの メ ッ セージの リ ス ン

4-3

ローカル

JSP

と リ モー ト アプ リ ケーシ ョ ン

コー ド リ ス ト 4-2に、 リ モー ト ク ラ イ アン ト の通知 リ スナの例を示し ます。

コー ド リ ス ト

4-2

リ モー ト ク ラ イアン ト 用の通知リ スナの例 import javax.management.Notification;

import javax.management.NotificationFilter;

import javax.management.NotificationListener;

import javax.management.Notification.*;

import weblogic.management.RemoteNotificationListener;

import weblogic.management.logging.WebLogicLogNotification;

...

public class MyRemoteNotificationListener implements RemoteNotificationListener {

...

JSP

NotificationListener WebLogic Server JVM

Remote JVM

MyRemoteNotificationListener LogBroadcasterRuntimeMBean

MBean

handleNotification()

handleNotification()

ドキュメント内 logging.book (ページ 30-35)

関連したドキュメント