Service Registry 3.1 開発ガイド

組織のサービスおよびサービスバインディングの取得

ほとんどの組織はサービスを提供します。JAXR には、組織のサービスおよびサービスバインディングを取得するメソッドがあります。

Service オブジェクトは、ほかのレジストリオブジェクトの属性をすべて持っています。さらに、通常は、サービスへのアクセス方法に関する情報を提供する「サービスバインディング」も持ちます。通常、ServiceBinding オブジェクトは、その他の属性とともに、アクセス URL を持っています。また、サービスバインディングと技術仕様をリンクする仕様リンクを持つこともできます。技術仕様には、サービスバインディングを通してサービスを使用する方法が記述されています。

仕様リンクには次の属性があります。

Service.getProvidingOrganization メソッドを使用して、サービスを提供している組織を取得できます。また、ServiceBinding.getService メソッドを使用して、サービスバインディングのサービスを取得できます。

次のコードは、組織 org のサービスを取得します。続いて、各サービスのサービスバインディングを取得し、各サービスバインディングについてそのアクセス URI を取得します。

Collection services = org.getServices();
Iterator svcIter = services.iterator();
while (svcIter.hasNext()) {
    Service svc = (Service) svcIter.next();
    System.out.println(" Service name: " + getName(svc));
    System.out.println(" Service description: " +
        getDescription(svc));

    Collection serviceBindings = svc.getServiceBindings();
    Iterator sbIter = serviceBindings.iterator();
    while (sbIter.hasNext()) {
        ServiceBinding sb = (ServiceBinding) sbIter.next();
        System.out.println("  Binding name: " +
            getName(sb));
        System.out.println("  Binding description: " +
            getDescription(sb));
        System.out.println("  Access URI: " +
            sb.getAccessURI());
        }
    }
}

「組織の属性の取得: 例」のサンプルは、検索した組織のサービスおよびサービスバインディングも表示します。

サービスは組織から独立して存在することも多くあります。BusinessQueryManagerImpl.findObjects メソッドを使用すると、そのようなサービスを直接検索できます。