Creating Custom Components for CloudView

All custom components in Exalead CloudView (except Mashup) use a generic mechanism, called CVComponent, to handle the instantiation and configuration aspects.

See Also
About Customizing Exalead CloudView
Packaging Custom Components as Plugins

In the Exalead CloudView configuration, you use your custom component by:

  • Referencing its class.

  • Providing the configuration for this usage of the component.

The CVComponent mechanism transmits the configuration to a new instance of your class.

In the Exalead CloudView configuration, the configuration of the custom component is given as a hierarchical listing of string key-values.

It is then transformed into a structured object, which must implement the CVComponentConfig interface.

For example, to create a custom analysis processor that connects to an auxiliary data source needing a login and password, define the component as follows:

package com.mycompany.myprocessor;
import com.exalead.mercury.component.config.CVComponentConfig;

public class MyProcessorConfig implements CVComponentConfig {
    private String login;
    private String password;

    public String getLogin() { return login; }
    public void setLogin(String login) { this.login = login; }

    public String getPassword() { return password; }
    public void setPassword(String password) { this.password = password; }}
package com.mycompany.myprocessor;
import com.mycompany.myprocessor.MyProcessorConfig;
import com.exalead.pdoc.analysis.CustomDocumentProcessor;
import com.exalead.mercury.component.config.CVComponentConfigClass;

@CVComponentConfigClass(configClass=MyProcessorConfig.class)
public class MyProcessor extends CustomDocumentProcessor {
  public MyProcessor(MyProcessorConfig config) {
    super(config);
    this.config = config;
  }

  @Override
  public void process(DocumentProcessingContext context,ProcessableDocument document) throws Exception {
     // Connect to the data source
     connect(config.login, config.password);
     // Work ...
  }
}

And in the configuration:

<CustomDocumentProcessor classId="com.exalead.myprocessor.MyProcessor">
  <KeyValue xmlns="exa:exa.bee" key="Login" value="mylogin" />
  <KeyValue xmlns="exa:exa.bee" key="Password" value="myverysecretpassword" />
</CustomDocumentProcessor>

Exalead CloudView automatically transforms the KeyValue in the object specified on @CVComponentConfigClass annotation on your component.

The basic rules are:

  • If your component does not have any configuration, you must annotate it with: @CVComponentConfigClass(configClass=CVComponentConfigNone.class).

  • Your config class must inherit CVComponentConfig.

  • Your config class must have the regular Java Beans getters and setters.