WebSphere Application Server for i5/OS, Version 6.1   
             オペレーティング・システム: i5/OS

             目次と検索結果のパーソナライズ化

例: コマンド・ターゲットの書き込み (クライアント・サイド・アダプター)

コマンドは Java アプリケーションと共に使用できますが、 クライアントからサーバーへコマンドを送信する方法は異なります。このトピックの例では、 HTTP プロトコル上でコマンドをサーブレットに送信する方法を示します。 クライアントは CommandTarget インターフェースをローカルに実装します。

ターゲットのクライアント・サイド・アダプターの構造

この例は、 クライアント・サイド・クラスの構造を示します。executeCommand メソッドをインプリメントすることによって、CommandTarget インターフェースをインプリメントします。

...
import java.io.*;
import java.rmi.*;
import com.ibm.websphere.command.*;
public class ServletCommandTarget implements CommandTarget, Serializable
{
protected String hostName = "localhost";
public static void main(String args[]) throws Exception
{
....
}
public TargetableCommand executeCommand(TargetableCommand command)
throws CommandException
{
....
}
public static final byte[] serialize(Serializable serializable)
throws IOException {
... }
public String getHostName() {
... }
public void setHostName(String hostName) {
... }
private static void showHelp() {
... }
}

クライアント・サイド・アダプターのインスタンス化

クライアント・サイド・アダプターの 主なメソッドは、以下のように、CommandTarget オブジェクトを構成および初期化します。

public static void main(String args[]) throws Exception
{
String hostName = InetAddress.getLocalHost().getHostName();
String fileName = "MyServletCommandTarget.ser";
// Parse the command line
...
// Create and initialize the client-side CommandTarget adapter
ServletCommandTarget servletCommandTarget = new ServletCommandTarget();
servletCommandTarget.setHostName(hostName);
...
// Flush and close output streams
...
}



サブトピック
例: クライアント・サイド・アダプターの実装
例: サーブレット内でのコマンドの実行
関連タスク
コマンドの使用
参照トピック    

ご利用条件 | フィードバック

最終更新: Jan 21, 2008 5:46:14 PM EST
http://publib.boulder.ibm.com/infocenter/wasinfo/v6r1/index.jsp?topic=/com.ibm.websphere.base.iseries.doc/info/iseries/ae/rcmd_writecmdtargcl.html