Writing Components
Component Types
The first step in writing a custom component is to choose what type of component you need. The component types are broken down by basic function. Almost all components you write will be one of the first three (which are document transformers). When creating a new component, choose the most specific type that meets your needs.
Type | Description |
| A document transformer that can do anything to the document passed to it. It can delete, modify, and add fields to the document. This transformer type also allows you to choose to drop the document. |
| A document transformer that creates new fields in the document based on existing fields. |
| A document transformer that modifies existing fields in the document. This transformer type also allows you to choose to drop the document. |
| An advanced document transformer that allows you to modify an existing "parent" document and to generate new "child" documents based on it. The new documents will then flow through the system independent of the "parent" document. |
| A transformer that can modify queries before they are processed by the search engine. |
| A transformer that can modify the resposnse to queries after they are processed by the search engine but before the response is returned to the user. |
| An advanced component that can change the workflow that will be used for a system message. |
| An advanced catch-all component that operates on raw system messages, doing whatever it likes to them. |
The Mix-In Interfaces
Once you have chosen a component type, you can also add a number of mix-in interfaces to the component. These allow you to indicate additional capabilities or requirements to the platform for your component.
Lifecycle
Name | Description |
| Provides a hook for the component to do initialization after its properties have been set before it does any processing. |
| Provides a hook for the component to clean up resources before system shutdown. |
| Provides a hook for the component to do initialization after all instances of this component have been started ( |
| Provides a hook for the component to do initialization after all components in the system have been started. |
Component Configuration
Name | Description |
| Provides option to set a default/backoff locale for component |
| Provides option to set a case mode property for component |
| Provides option to configure document dropping when an exception occurs for component |
| Provides option to set a field mappings property for component |
| Provides option to set a list of fields for component |
| Provides option to set a list of input fields for component |
| Provides option to set an input field for component |
| Provides option to configure overwriting of existing values in output fields for component |
| Provides option to set a query language (simple, advanced, xml) for component |
| Provides option to set a schema to validate against for component |
| Provides option to set a tokenizer the component should use |
Miscellaneous
Name | Description |
| Indicates that the component needs to know what its component name is |
| Provides an option to set a |
| Indicates that the component needs to know what its qualified component name is |
| Provides a |
| Provides a |
Annotations
Name | Description |
| Used for document transformers that create multiple output documents or messages for each input document |
| Indicate that |
| Indicate that |
| Indicate that |
| Indicates that the component is thread safe and does not require an object pool |
Testing your component
It is important to write focused and concise unit tests for your custom components. Attivio provides a number of testing utilities and mock implementations to make writing good unit tests simple. This archetype generation referenced by the README page provides examples of the techniques described here.
Create the component
Configure your component
Optionally "start" your component
If your component uses any of the lifecycle or miscellaneous mix-ins, there is a test utility that will call them and set them up with appropriate mock implementations as needed:
Create a sample document to use in your test
Process the document with your component
Assert conditions on the document
Last updated