この章では、カスタムIDサービス・プラグインを作成して特定のサードパーティ・リポジトリに統合する方法を説明しています。
この章で説明する内容は次のとおりです。
カスタムIDサービス・プラグインを作成して、特定のサードパーティ・リポジトリに統合できます。カスタム・プラグインを作成した後、次のタスクを実行します。
すべてのクラスをまとめてカスタム・プラグインJARファイルを作成
JARファイルのデプロイ
JARファイルをOracle BPEL Process Managerクラスパスに追加
is_config.xml
ファイルを構成
システム(デモ)ユーザーおよびロールを作成
この項で説明する内容は次のとおりです。
表3-1は、使用可能なインタフェースを説明したものです。
表3-1 インタフェース
IDサービス実装のエントリ・ポイントはBPMIdentityService
です。
package is.custom.plugin; import java.util.*; import javax.servlet.http.HttpServletRequest; import org.w3c.dom.Element; import oracle.tip.pc.infra.exception.*; import oracle.tip.pc.services.common.*; import oracle.tip.pc.services.identity.*; public class CustomIdentityService extends BPMServiceBase implements BPMIdentityService { /** * Constructor */ private CustomIdentityService(ProviderCfg provCfg) throws ServiceException { super(provCfg); } /** * Factory Method */ public static Service getInstance(String realmName) throws ServiceException { try { BPMIdentityConfigService cfgSrv = ServiceFactory.getIdentityConfigServiceInstance(); if ( realmName == null ) { realmName = cfgSrv.getDefaultRealmName(); } Configuration config = cfgSrv.getConfigurationInstance(realmName); ProviderCfg providerCfg = config.getProviderCfg( ProviderCfg.IDENTITY_SERVICE); CustomIdentityService service = new CustomIdentityService(providerCfg); return service; } catch (Exception e) { throw new ServiceException(e, DiagnosticService.SERVICESCOMPONENT); } } … /** * @see oracle.tip.pc.services.identity. BPMAuthorizationService #lookupUser(String) */ public BPMUser lookupUser(String userName) throws BPMIdentityException, BPMIdentityNotFoundException { Logger.debugLog("CustomIdentityService::lookupUser() begin"); if(userName == null) throw new BPMIdentityException( PCExceptionIndex.IDENTITYSERVICE_NAME_IS_NULL); BPMUser user = getProvider().lookupUser(userName); if(user==null) { throw new BPMIdentityNotFoundException( PCExceptionIndex.IDENTITYSERVICE_USER_NOT_FOUND, new String[] {userName, getRealmName()}); } Logger.debugLog("CustomIdentityService::lookupUser() end"); return user; } …. }
前の例で、CustomIdentityService
はBPMIdentityService
インタフェースを実装するクラスです。構成において認証または認可サービス・プロバイダに対してのみCUSTOM
providerType
が指定されている場合、BPMAuthenticationService
またはBPMAutorizationService
インタフェースを実装する必要があります。
<?xml version = '1.0' encoding = 'UTF-8'? <ISConfiguration xmlns="http://www.oracle.com/pcbpel/identityservice/isconfig" <configurations <configuration realmName="jazn.com" <provider providerType="JAZN" name="xml" service="Identity" <property name="userPropertiesFile" value="users-properties.xml"/ </provider <provider providerType="CUSTOM name="CustomPlugIn" service="Authentication class=Ópackage.name.CustomAuthenticationServiceÓ / </configuration </configurations </ISConfiguration
前の例では、認証プロバイダでのみカスタム実装が使用されているのに対し、他のすべての問合せでJAZN XMLベース・プロバイダが使用されています。CustomAuthenticationService
クラスはBPMAuthenticationService
インタフェースを実装する必要があります。
SOA_Oracle_Home
¥bpel¥system¥services¥config¥
is_config.xml
ファイルでIDサービスのproviderType
としてCUSTOM
が指定されている場合、BPMIdentityService
インタフェースを実装する必要があります。
<?xml version = '1.0' encoding = 'UTF-8'?>
<ISConfiguration xmlns="http://www.oracle.com/pcbpel/identityservice/isconfig">
<configurations>
<configuration realmName="jazn.com">
<provider providerType="CUSTOM"
name="CustomPlugIn" service="Identity"
class=Ópackage.name.CustomIdentityServiceÓ>
<property name=ÓcustomPropertyÓ value=ÓcustomValueÓ />
</configuration>
</configurations>
</ISConfiguration>
BPMIdentityService
、BPMAuthenticationService
またはBPMAuthorization
インタフェースを実装する3つのサービス・クラスはすべて、oracle.tip.pc.services.identity.BPMServiceBase
クラスを拡張して基本サービス機能を活用できます。
すべてのカスタム・サービス・クラスには、サービス・プロバイダのインスタンスを作成するために、静的ファクトリgetInstance()
メソッドが必要です。
public static Service getInstance(String realmName) throws ServiceException;
realmName
はビジネス・プロセスのコンテキストです。realmName
がnull
である場合、デフォルトのレルムが使用されるものとみなされます。構成サービスAPIを使用して、デフォルトのレルム名を取得できます。
BPMIdentityConfigService cfgService = ServiceFactory.getIdentityConfigServiceInstance(); String defaultRealmName = cfgService.getDefaultRealmName();
サービス・ファクトリoracle.tip.pc.service.common.ServiceFactory
のクラスは、次の静的パブリック・メソッドを定義します。
BPMIdentityService getIdentityServiceInstance(String realmName); BPMAutorizationService getAuthorizationServiceInstance(String realmName); BPMAuthenticationService getAuthenticationServiceInstance(String realmName); BPMIdentityService getIdentityServiceInstance(); BPMAutorizationService getAutorizationServiceInstance(); BPMAuthenticationService getAuthenticationServiceInstance();
これらのメソッドは、Javaクライアントが対応するサービス・プロバイダのインスタンスを受け取る際に使用されます。サービスに対してプロバイダ・タイプCUSTOM
が指定されている場合、サービス・ファクトリ・メソッドでは実行時にカスタム・サービス・インスタンスが作成されます。これらのメソッドにより、カスタム・サービスgetInstance(String realmName)
APIが呼び出されます。
サービス・プロバイダ・クラスによりoracle.tip.pc.services.BPMServiceBase
クラスが拡張された場合、サービス・ファクトリ・メソッドは、指定された構成に対してプロパティを定義するProviderCfg
クラスのインスタンスを取得する必要があります。続いてサービスを作成できます。
CustomIdentityService service = new CustomIdentityService(providerCfg);
BPMIdentityConfigService
インスタンスでは、指定されたrealmName
によりConfiguration
オブジェクトにアクセスできます。
Configuration conf = cfgService.getConfigurationInstance(realmName);
続いて、特定のプロバイダ構成をフェッチできます。
ProviderCfg providerCfg = conf.getProviderCfg(serviceName);
ここで、serviceName
は次のいずれかの値となります。
ProviderCfg.IDENTITY_SERVICE
— IDサービス・プロバイダの場合
ProviderCfg.AUTHENTICATION_SERVICE
— 認証サービス・プロバイダの場合
ProviderCfg.AUTHORIZATION_SERVICE
— 認可サービス・プロバイダの場合
カスタム・プラグイン用の認証および認可サービスを記述する最も簡単な方法は、カスタム・リポジトリ用のBPMProvider
インタフェースを実装する方法です。BPMProvider
インタフェースは、必須となる操作の最小セットを定義します。この最小セットは、IDサービスが正しく機能するためにカスタム・リポジトリに対して定義する必要があります。実装オブジェクトのすべてのインスタンスは、リポジトリ固有のコールの処理を受け持つプロバイダにコールを委譲できます。
たとえば、BPMServiceBase
クラスはサービス・プロバイダが拡張できる抽象クラスです。拡張した場合、カスタム・サービス・クラスはinit()
メソッドを実装する必要があります。
public void init() throws BPMIdentityException { m_provider = CustomerProvider.getInstance(m_providerCfg); m_status = new ServiceStatus(true, "Service is available", -1, }
ここで、m_provider
はBPMProvider
オブジェクトを参照するためのBPMServiceBase
の保護メンバーです。CustomerProvider
は、BPMProvider
インタフェースを実装するクラスです。オプションで、プロバイダ・クラスを動的にロードできます。is_config.xml
ファイルからCUSTOM
providerType
のプロバイダ・クラス名を取得します。そのために、プロバイダ要素のname
属性が予約されます。m_status
メンバーは、BPMServiceBase
クラスの保護メンバーです。このメンバーにはServiceStatus
オブジェクトが格納されます。
ワークフロー・サービスでプラグインをインスタンス化して呼び出すためには、Oracle BPEL Process Managerのライブラリ・パス内のディレクトリにデプロイする必要があります。
プラグイン・コードをコンパイルし、クラスをまとめてJARファイルを作成し(isplugin.jar
など)、さらにJARファイルをSOA_Oracle_Home
¥services¥lib
ディレクトリにデプロイする必要があります。
また、ライブラリ・パスがデプロイされたJARファイルをポイントする必要があります。たとえば、SOA_Oracle_Home
¥j2ee¥home¥config
ディレクトリにあるapplication.xml
ファイルに次の行を追加して、ライブラリ・パスにisplugin.jar
を追加する必要があります。
<library path="SOA_Oracle_Home\bpel\system\services\lib\isplugin.jar"/>
プロバイダのJARファイル名など小さな変更を含むカスタム・プラグインに対し、同一のデプロイメント・スキームを使用できます。
IDサービス構成はis_config.xml
ファイルで定義されます。このファイルは、Oracle BPEL Process Managerのクラスパス内のディレクトリに格納されている必要があります。デフォルトでは、このファイルはSOA_Oracle_Home
¥bpel¥system¥services¥config
に格納されています。
次の構成ファイルのサンプルでは、IDサービスのカスタム・プロバイダとして実装されているデータベース・プラグインについて記述しています。
<?xml version = '1.0' encoding = 'UTF-8'?> <ISConfiguration mlns="http://www.oracle.com/pcbpel/identityservice/isconfig"> <configurations> <configuration realmName="realm"> <provider providerType="CUSTOM" service="Identity" name="package.name.CustomerProvider" class=Ópackage.name.CustomIdentityServiceÓ> <property name="dataSource" value="jdbc/BPELSamplesDataSource"/> </provider> </configuration> </configurations> </ISConfiguration>
provider
要素のname
属性はBPMProvider
クラスをロードできます。class
属性は、BPMIdentityService
の実装クラスを定義します。dataSource
という名前のcustom
プロパティは、JDBC接続のデータソース名を取得します。