Group(グループ)  目次

Oracle Service RegistryのGroup(グループ)デモは、Oracle Service RegistryのApplication Programming Interface(API)の機能およびこのAPIの使用方法のデモンストレーションを行うために使用します。

グループを作成または更新、取得、検索および削除する方法を学習します。

Oracle Service RegistryのSecurityのGroup(グループ)デモ・セットには、Oracle Service RegistryのクライアントAPIの学習を支援する次のデモが含まれています。

Save Save_groupオブジェクトをビルドして入力し、UDDIレジストリのGroupスタブを取得し、save_groupコールを実行する方法のデモンストレーションです。

Delete Delete_groupオブジェクトをビルドして入力し、UDDIレジストリのGroupスタブを取得し、delete_groupコールを実行する方法のデモンストレーションです。

Get Get_groupオブジェクトをビルドして入力し、UDDIレジストリのGroupスタブを取得し、get_groupコールを実行する方法のデモンストレーションです。

Find Find_groupオブジェクトをビルドして入力し、UDDIレジストリのGroupスタブを取得し、find_groupコールを実行する方法のデモンストレーションです。

WhereIAm Where_amIオブジェクトをビルドして入力し、UDDIレジストリのGroupスタブを取得し、where_amIコールを実行する方法のデモンストレーションです。

前提条件および準備手順: コード  目次

Oracle Service Registryがすでにインストールされ、環境変数REGISTRY_HOMEにレジストリのインストール場所が設定されていることを想定しています。

Oracle Service Registryのデモを実行するには、レジストリが実行中である必要があります。

デモを構成する必要があります。構成システムには、グローバルとローカルの2つのレベルがあります。グローバル・レベルで定義されたプロパティは、ローカル・レベルで上書きできます。グローバル・プロパティは、次のファイルにあります。

Windows: %REGISTRY_HOME%¥demos¥env.properties
UNIX: $REGISTRY_HOME/demos/env.properties

Oracle Service Registryのインストール中に設定された値はそのまま使用でき、値の変更はすべてのデモに影響を与えます。単一のデモについて(つまりローカル・レベルで)プロパティの値を再定義する必要がある場合は、env.propertiesを編集してください。このファイルは、ファイルrun.shrun.bat)と同じディレクトリにあります。Groupデモのローカル・レベルのプロパティは、次のファイルからロードされます。

Windows: %REGISTRY_HOME%¥demos¥security¥group¥env.properties
UNIX: $REGISTRY_HOME/demos/security/group/env.properties

表13 デモで使用されるプロパティ

名前デフォルト値説明
uddi.demos.url.grouphttp://localhost:8888/registry/uddi/groupグループWebサービス・ポートのURL
uddi.demos.url.securityhttp://localhost:8888/registry/uddi/securityセキュリティWebサービス・ポートのURL

プレゼンテーションおよび機能プレゼンテーション  目次

この項では、すべてのデモで使用されるプログラミング・パターンを、WhereIAmデモを例にして説明します。このデモのソース・コードは次のファイルにあります。

Windows: %REGISTRY_HOME%¥demos¥security¥group¥src¥demo¥uddi¥group¥WhereIAm.java
UNIX: $REGISTRY_HOME/demos/security/group/src/demo/uddi/group/WhereIAm.java

mainメソッドは、ユーザーからの構成情報の収集で始まります。1つ目の情報であるログイン名を使用してコマンドが実行され、2つ目はwhere_amI操作の引数になります。次にユーザーがレジストリにログインし、Where_amIオブジェクトが作成されてSOAP経由で送信され、ログインが属するグループのリストが出力されます。

String user = UserInput.readString("Enter login to authenticate",
	               DemoProperties.getProperty(USER_JOHN_NAME));
String password = UserInput.readString("Enter password",
                       DemoProperties.getProperty(USER_JOHN_PASSWORD));
String login = UserInput.readString("Enter login to search", user);
System.out.println();

UDDI_Security_PortType security = getSecurityStub();
String authInfo = getAuthInfo(user, password, security);
Where_amI save = createWhereAmI(login, authInfo);
GroupList groups = whereAmI(save);
printGroupList(groups);
discardAuthInfo(authInfo, security);

メソッドcreateWhereAmIを使用して、where_amI操作を表すオブジェクトが作成されます。

public static Where_amI createWhereAmI(String login, String authInfo)
  throws InvalidParameterException {
    System.out.println("login = " + login);

    Where_amI find = new Where_amI();
    find.setLoginName(login);
    find.setAuthInfo(authInfo);

    return find;
}

ヘルパー・メソッドgetGroupStub()によって、URL_GROUPプロパティで指定されたURLでリスニングするWebサービスのUDDI Groupスタブが返ります。

public static GroupApi getGroupStub() throws SOAPException {
    // you can specify your own URL in property - uddi.demos.url.group
    String url = DemoProperties.getProperty(URL_GROUP, "http://localhost:8888/registry/uddi/group");
    System.out.print("Using Group API at url " + url + " ..");
    GroupApi account = GroupStub.getInstance(url);
    System.out.println(" done");
    return account;
}

Oracle Service RegistryのAPIコールwhere_amIが、whereAmIメソッドで実行されます。

public static GroupList whereAmI(Where_amI find)
  throws SOAPException, GroupException {
    GroupApi groupApi = getGroupStub();
    System.out.print("Search in progress ...");
    GroupList groups = groupApi.where_amI(find);
    System.out.println(" done");
    return groups;
}

最後にメソッドprintGroupListを使用して、見つかったグループがコンソールに出力されます。

public static void printGroupList(GroupList groups) {
    System.out.println();
    ListDescription listDescription = groups.getListDescription();
    if (listDescription != null) {
        // list description is mandatory part of result, if the resultant list is subset of available data
        int includeCount = listDescription.getIncludeCount();
        int actualCount = listDescription.getActualCount();
        int listHead = listDescription.getListHead();
        System.out.println("Displaying " + includeCount + " of " + actualCount + ",
	                                                  starting at position " + listHead);
    }

    GroupInfoArrayList groupInfoArrayList = groups.getGroupInfoArrayList();
    if (groupInfoArrayList == null) {
        System.out.println("Nothing found");
        return;
    }

    int position = 1;
    for (Iterator iterator = groupInfoArrayList.iterator(); iterator.hasNext();) {
        GroupInfo group = (GroupInfo) iterator.next();
        System.out.println("Group " + position);
        System.out.println(group.toXML());
        System.out.println();
        System.out.println("********************************************************");
        position++;
    }
}

デモのビルドと実行  目次

この項では、Oracle Service Registryのグループ・デモをビルドして実行する方法を示します。

  1. デモが適切に構成され、Oracle Service Registryが実行中であることを確認してください。

  2. 次のディレクトリに移動します。

    Windows: %REGISTRY_HOME%¥demos¥security¥group
    UNIX: $REGISTRY_HOME/demos/security/group

  3. 次のコマンドを使用して、デモをビルドします。

    Windows: run.bat make
    UNIX: ./run.sh make

    注意注意

    Windowsプラットフォームでデモをコンパイルすると、次のテキストが表示されることがあります。

    A subdirectory or file ..\..\common\.\build\classes already exists.

    これは予想される現象であり、問題を示すものではありません。

  4. 利用可能なすべてのコマンドのリストを表示するには、次のコマンドを実行します。

    Windows: run.bat help
    UNIX: ./run.sh help

  5. 選択したデモを実行するには、runコマンドのパラメータにデモの名前を指定して実行します。たとえば、WhereIAmデモを実行するには、次のように起動します。

    Windows: run.bat WhereIAm
    UNIX: ./run.sh WhereIAm

    このデモの出力は次のようになります。

    Running WhereIAm demo...
    Find groups of user where
    Enter login to authenticate [demo_john]:
    Enter password [demo_john]:
    Enter login to search [demo_john]:
    
    Using Security at url https://mycomp.com:8443/registry/uddi/security .. done
    Logging in .. done
    login = demo_john
    Using Group API at url https://mycomp.com:8443/registry/uddi/group .. done
    Search in progress ... done
    
    Group 1
    <groupInfo xmlns="http://systinet.com/uddi/group/5.0">
    <name>system#everyone</name>
    <description>The special group that contains all users.</description>
    <privateGroup>false</privateGroup>
    <external>false</external>
    </groupInfo>
    
    ********************************************************
    Group 2
    <groupInfo xmlns="http://systinet.com/uddi/group/5.0">
    <name>system#registered</name>
    <description>The special group that contains all users who are logged
    onto the UDDI registry.</description>
    <privateGroup>false</privateGroup>
    <external>false</external>
    </groupInfo>
    
    ********************************************************
    Logging out .. done
  6. デモを再ビルドするには、run.bat clean./run.sh clean)を実行してclassesディレクトリを削除し、run.bat make./run.sh make)を実行してデモ・クラスを再ビルドします。