Instantiate a connector
The following code snippet shows how to instantiate a connector
(
myConnector
).
package com.exalead.papi.datainteg.connectors; import org.apache.log4j.BasicConfigurator; import org.apache.log4j.Level; import org.apache.log4j.Logger; import com.exalead.mercury.plugin.simple.SimplePluginManager; import com.exalead.papi.datainteg.connectors.rscan.unmanaged.Runner; import com.exalead.papi.framework.connectors.Connector; import com.exalead.papi.framework.connectors.ConnectorConfig; import com.exalead.papi.helper.Document; import com.exalead.papi.helper.PushAPI; public class RScanServerSample { public static void main(final String[] args) throws Exception { BasicConfigurator.configure(); Logger.getRootLogger().setLevel(Level.INFO); SimplePluginManager.getCurrentInstance(); // Start a RSCAN server final Runner rscanRunner = new Runner(10005); // Add a new connector rscanRunner.registerConnector(MyConnectorClass.class, "myConnector"); try { // wait for input requests on RSCAN server indefinitely. Thread.sleep(Long.MAX_VALUE); } catch (final InterruptedException e) { /* do nothing */ } rscanRunner.stop(); } /** * Connector sample pushing one document. */ public static class MyConnectorClass extends Connector { public MyConnectorClass(final ConnectorConfig config) throws Exception { super(config); } @Override public void scan(final PushAPI papi, final String scanMode, final Object scanModeConfig) throws Exception { final Document doc = new Document("document1234"); doc.addMeta("author", "foo"); doc.addMeta("content", "Lorem ipsum dolor sit amet..."); papi.addDocument(doc); } } }