ConnectorLib Java 25.2
ConnectorLib Java SDK Programming Guide

# Extend ConnectorBase

To create a new connector you must create a class that extends the `com.autonomy.connector.ConnectorBase` class. For example:

    package myconnector;
    import com.autonomy.connector.*;

    public class HelloWorldConnector extends ConnectorBase
    {
        public HelloWorldConnector(Config config, Log log)
        {
            super("My Connector");
        }

        public void synchronize(SynchronizeTask task) throws Exception
        {
            String target = task.getTaskConfig().read("Target", "World");
            task.getLog().writeln(Log.NORMAL, "Hello " + target);
        }
    }

NOTE: As shown in the example above, any connector implementation must extend `ConnectorBase` and have a constructor that takes two arguments (a `Config` and a `Log`).

OpenText recommends that the `Config` instance provided to the constructor is used only from within the constructor and that a reference to this object is not kept. This configuration is generally only useful for global settings that change how the connector behaves as a whole. Configuration for tasks should be accessed using the configuration objects provided to each task implementation.

The instance of `Log` provided to the constructor can be used outside of the constructor, and writes to the connector's application log stream. It should not be used for logging that is specific to a task (such as `Synchronize`).

The implementation of `Synchronize` uses `task.``get` `TaskConfig``()` and `task.``get` `Log``()` which provide access to the configuration and log for the task.

The constructor of `ConnectorBase` is passed the string "My Connector". This is the name of the connector as it should be displayed to the user, and can be any string.

A Java source file with this sample code is provided in the SDK (`HelloWorldConnector.java`).

This very basic connector implements only the `synchronize` fetch action. Your class does not have to implement the `synchronize` action, and it could implement other actions such as `collect`, `view`, `update`, and `delete`.

The body of the `synchronize` method reads a configuration value and writes a log message. It reads the value of the `Target` configuration parameter (which has a default value of "World") and then writes it to the synchronize log at the normal log level.

Copyright 2025 Open Text
Version 25.2 | Last updated April 2025

Send documentation feedback

Close

Send documentation feedback

To send feedback using your default email client, open an email window.

Otherwise, send your feedback and the information below to MFI-swpdl.idoldocsfeedback@opentext.com.

We appreciate your feedback!

Product: Knowledge Discovery ConnectorLib Java 25.2

Topic Title: Extend ConnectorBase