マニピュレータ・クラスの作成

マニピュレータは、Manipulator抽象クラスおよび他のサポート・クラスを拡張することによって作成します。

Manipulatorでは、@IasManipulatorアノテーションが必要です。このアノテーションには、次のような構成可能な重要な属性がいくつかあります。
  • supportsIncrementals.必須。マニピュレータが増分取得からの入力をサポートしているかどうかを示すブール値。増分取得において1つのマニピュレータにこれがfalseに設定されている場合、増分取得は完全モードで実行します。
  • deleteRecordsBypassManipulator.必須。削除された入力レコードを直接マニピュレータの出力チャネルに送信するか、削除された入力レコードをマニピュレータに送信するかを示すブール値。値がtrueのとき、レコードを(マニピュレータをパスして)出力チャネルに送信します。値がfalseのとき、レコードをマニピュレータに送信します。
  • displayName.オプション。IAS Serverコマンドライン・ユーティリティのlistModulesタスクから返されるマニピュレータ名。
  • description.オプション。マニピュレータが処理するEndecaレコードに対して行う操作の説明。この説明は、IAS Serverコマンドライン・ユーティリティのlistModulesタスクから返されます。
  • id.オプション。指定されない場合、拡張機能はデフォルトで完全修飾クラス名をidとして使用します。

IAS Serverコマンドライン・ユーティリティのlistModulesタスクおよびIAS Server APIのlistModules()コールのいずれも、@IasManipulatorアノテーションで指定した属性値を返します。

マニピュレータ拡張機能を作成する手順は次のとおりです。

  1. ご使用の開発環境でJavaプロジェクトを作成します。

    1つのプラグインに複数の拡張機能を作成する場合には、各拡張機能に対して同じJavaプロジェクトを使用できます。

  2. IAS拡張APIライブラリをコンパイル・クラスパスに追加します。これらは、IAS\<バージョン>\lib\ias-extension-apiにあるすべてのライブラリを含みます。
  3. Manipulatorのサブクラスを作成し、拡張機能が使用するPipelineComponentConfigurationサブクラスを指定します。
    たとえば、次のようになります。
    public class SubstringManipulator extends Manipulator<SubstringManipulatorConfig>{
    
    }
  4. Manipulatorクラスに@IasManipulatorアノテーションおよび前述の属性を追加します。
    たとえば、次のようになります。
    @IasManipulator(
    		supportsIncrementals=true, 
    		deleteRecordsBypassManipulator = true,
    		displayName="Substring Manipulator", 
    		description="Generates a new property that is a substring of another property value")
    public class SubstringManipulator extends Manipulator<SubstringManipulatorConfig>
  5. getConfigurationClass()メソッドを実装し、適切なPipelineComponentConfigurationサブクラスが返されるようにします。
    たとえば、次のようになります。
    public Class<SubstringManipulatorConfig> getConfigurationClass() {
    		return SubstringManipulatorConfig.class;
    	}
  6. createManipulatorRuntime()メソッドを実装し、ManipulatorRuntimeクラスの実装を作成します。
    たとえば、次のようになります。
    public ManipulatorRuntime createManipulatorRuntime(
    			SubstringManipulatorConfig configuration, PipelineComponentRuntimeContext 
       context) {
    		return new SubstringManipulatorRuntime(context, configuration);
    }
  7. getRuntimeClass()メソッドを実装し、マニピュレータが作成するランタイム・クラスを返すようにします。
    たとえば、次のようになります。
    	public Class<SubstringManipulatorRuntime> getRuntimeClass() {
    		return SubstringManipulatorRuntime.class;
    	}
  8. オプションで、deleteInstance()メソッドをオーバーライドします。IAS Serverは、取得から拡張機能を削除するときに、deleteInstance()をコールします。このメソッドでは、IAS ServerがdeleteInstance()をコールして取得から拡張機能を削除するときに必要なクリーンアップを実行できます。deleteInstance()のデフォルト実装は空になっています。

マニピュレータ拡張機能の例

前述の手順の詳細は、<インストール・パス>\IAS\<バージョン>\sample\ias-extensions\src\main\com\endeca\ias\extension\sample\manipulator\substring\SubstringManipulator.javaのサンプル・マニピュレータ拡張機能を参照してください。