FAQ/S2RMI
をテンプレートにして作成
[
トップ
] [
新規
|
一覧
|
検索
|
最終更新
|
ヘルプ
|
ログイン
]
開始行:
[[FAQ]]
*S2RMI [#t2cbf122]
#contents
**S2RMIのプログラムをサービス化する方法 [#s8d03fff]
>[[S2サポーター]] (2006-04-29 (土) 19:04:37)~
~
''Question''~
~
S2RMIのドキュメント通りにサーバプログラムを起動しますが、~
終了はCtrl+Cです。この終了ができるように(つまりサービス...
実装したいと思っています。~
~
これがサーブレットならtomcatなどを使えばよいのでしょうが、~
S2RMIではどのように実装すればいいかよくわかりません。~
~
下記ページのようにThreadを使用する方法が一つ分かっていま...
他に適切な方法はありますか?~
http://seasarproject.g.hatena.ne.jp/ueyama/comment?date=2...
~
''Answer''~
~
1.stopメソッドをもつIStoppableインターフェースを作成しま...
~
package examples.service.main;
public interface IStoppable {
void stop();
}
~
2.ServerMainクラスはIStoppableを実装します。~
~
public class ServerMain implements IStoppable
~
3.ServerMainクラスにstopメソッドを実装します。~
新しいスレッドを作成してstaticなexitメソッドを呼びます。~
~
public void stop() {
Thread destroyer = new Thread() {
public void run() {
ServerMain.exit();
}
};
destroyer.start();
}
~
4.ServerMainクラスにexitメソッドを実装します。~
コンテナをdestroyしてexitします。~
~
public static void exit() {
if (container != null) {
System.out.println("デストロイヤー参上!");
container.destroy();
System.exit(0);
}
}
~
5.stopを呼び出すクライアントプログラムとdiconファイルを書...
~
public class RemotingStop {
private static final String PATH="dicon/RemotingStop...
public static void main(String[] args) {
S2Container container = S2ContainerFactory.creat...
container.init();
try {
IStoppable service = (IStoppable)container.g...
service.stop();
} finally {
container.destroy();
}
}
}
~
(dicon/RemotingStop.diconファイル抜粋)
<component name="remotingStopper" class="examples.servic...
IStoppable">
<aspect>remoting</aspect>
</component>
~
ServerMainを実行し、その後でRemotingStopを実行すれば終了...
~
~
''参考投稿''~
http://ml.seasar.org/archives/seasar-user/2006-February/0...
http://ml.seasar.org/archives/seasar-user/2006-February/0...
//
終了行:
[[FAQ]]
*S2RMI [#t2cbf122]
#contents
**S2RMIのプログラムをサービス化する方法 [#s8d03fff]
>[[S2サポーター]] (2006-04-29 (土) 19:04:37)~
~
''Question''~
~
S2RMIのドキュメント通りにサーバプログラムを起動しますが、~
終了はCtrl+Cです。この終了ができるように(つまりサービス...
実装したいと思っています。~
~
これがサーブレットならtomcatなどを使えばよいのでしょうが、~
S2RMIではどのように実装すればいいかよくわかりません。~
~
下記ページのようにThreadを使用する方法が一つ分かっていま...
他に適切な方法はありますか?~
http://seasarproject.g.hatena.ne.jp/ueyama/comment?date=2...
~
''Answer''~
~
1.stopメソッドをもつIStoppableインターフェースを作成しま...
~
package examples.service.main;
public interface IStoppable {
void stop();
}
~
2.ServerMainクラスはIStoppableを実装します。~
~
public class ServerMain implements IStoppable
~
3.ServerMainクラスにstopメソッドを実装します。~
新しいスレッドを作成してstaticなexitメソッドを呼びます。~
~
public void stop() {
Thread destroyer = new Thread() {
public void run() {
ServerMain.exit();
}
};
destroyer.start();
}
~
4.ServerMainクラスにexitメソッドを実装します。~
コンテナをdestroyしてexitします。~
~
public static void exit() {
if (container != null) {
System.out.println("デストロイヤー参上!");
container.destroy();
System.exit(0);
}
}
~
5.stopを呼び出すクライアントプログラムとdiconファイルを書...
~
public class RemotingStop {
private static final String PATH="dicon/RemotingStop...
public static void main(String[] args) {
S2Container container = S2ContainerFactory.creat...
container.init();
try {
IStoppable service = (IStoppable)container.g...
service.stop();
} finally {
container.destroy();
}
}
}
~
(dicon/RemotingStop.diconファイル抜粋)
<component name="remotingStopper" class="examples.servic...
IStoppable">
<aspect>remoting</aspect>
</component>
~
ServerMainを実行し、その後でRemotingStopを実行すれば終了...
~
~
''参考投稿''~
http://ml.seasar.org/archives/seasar-user/2006-February/0...
http://ml.seasar.org/archives/seasar-user/2006-February/0...
//
ページ名: