Creating a manipulator class

You create a manipulator by extending the Manipulator abstract class and other supporting classes.

A Manipulator requires an @CasManipulator annotation. The annotation has several important attributes you can configure:
  • supportsIncrementals. Required. A Boolean value that indicates whether the manipulator supports input from an incremental acquisition. If one manipulator in an incremental acquisition has this set to false, the incremental acquisition runs in full mode.
  • deleteRecordsBypassManipulator. Required. A Boolean value that indicates whether to send deleted input records directly to the manipulator's output channel or to send deleted input records into the manipulator. A value of true sends records to the output channel (by passing the manipulator). A value of false sends records into the manipulator.
  • displayName. Optional. The name of a manipulator as returned from the listModules task of the CAS Server Command-line Utility.
  • description. Optional. The description of a what the manipulator does to Endeca records that it processes. The description is returned from the listModules task of the CAS Server Command-line Utility, and the description displays in the Add Manipulator dialog of CAS Console.
  • id. Optional. If unspecified, the extension defaults to using the fully qualified class name as its id.

The listModules task of the CAS Server Command-line Utility and the listModules() call of the CAS Server API both return the attribute values you specify in the @CasManipulator annotations.

To create a manipulator extension:

  1. Create a Java project in your development environment of your choice. If you are creating several extensions in one plug-in, you can use the same Java project for each extension.
  2. Add the CAS Extension API libraries to your compile classpath. These include all the libraries available in CAS\version\lib\cas-extension-api.
  3. Create a subclass of Manipulator and specify the PipelineComponentConfiguration subclass that the extension uses. For example:
    public class SubstringManipulator extends Manipulator<SubstringManipulatorConfig>{
    
    }
  4. Add a @CasManipulator annotation to the Manipulator class and any attributes as described above. For example:
    @CasManipulator(
    		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. Implement the getConfigurationClass() method to return the appropriate PipelineComponentConfiguration subclass. For example:
    public Class<SubstringManipulatorConfig> getConfigurationClass() {
    		return SubstringManipulatorConfig.class;
    	}
  6. Implement the createManipulatorRuntime() method to create an implementation of the ManipulatorRuntime class. For example:
    public ManipulatorRuntime createManipulatorRuntime(
    			SubstringManipulatorConfig configuration, PipelineComponentRuntimeContext context) {
    		return new SubstringManipulatorRuntime(context, configuration);
    }
  7. Implement the getRuntimeClass() method to return the runtime class the manipulator creates. For example:
    	public Class<SubstringManipulatorRuntime> getRuntimeClass() {
    		return SubstringManipulatorRuntime.class;
    	}
  8. Optionally, override the deleteInstance() method. CAS Server calls deleteInstance() when it removes an extension from an acquisition. In this method, you can perform any clean up that is necessary when CAS Server calls deleteInstance() to remove the extension from an acquisition. The default implementation of deleteInstance() is empty.

Example of a manipulator extension

To see many of the steps above, refer to the sample manipulator extension in <install path>\CAS\version\sample\cas-extensions\src\main\com\endeca\cas\extension \sample\manipulator\substring\SubstringManipulator.java.