Create an input connector by extending the AbstractInputConnector class.
Create an input connector when you want to listen for external events or receive data from external sources. Input connectors constitute the starting point of a message flow. Polling for input is a special case of an input connector that is supported in the connector framework.
The following example shows the Java™ classes that you need to create for an input connector:
Javadoc documentation
for the Connector Framework API is available
at Connector API.
package connector.database;
import java.util.Properties;
import com.ibm.connectors.AbstractInputConnector;
import com.ibm.connectors.ConnectorException;
public class myInputConnector extends AbstractInputConnector {
@Override
protected void onInitialise() throws Exception {
// TODO This method is called after the properties and container services have been
// saved.
// You can call getLogger() to get a Java logger named with your connector's assigned name
// You can call getProperty(<name>) to get a named property provided via the Toolkit
// You can create any resources you need here (and destroy them on terminate())
// or you can wait until start() (destroying them on stop())
getLogger().fine("Initialisation complete");
}
@Override
public void start() throws ConnectorException {
// TODO Implement the code here to start listening for input depending on the technology
// being used.
// You can call getCallback().processInboundData() to pass incoming input to the host application
// Input data should be a byte array. Properties may also be returned. These will form part of the
// ongoing message to be processed by the message flow.
byte[] data = null;
Properties props = new Properties();
getCallback().processInboundData(data, props);
}
@Override
public boolean isStarted() {
// TODO You need to track the state of the input connector since it varies depending on
// the technology being used.
return false;
}
@Override
public void stop() throws ConnectorException {
// TODO Close down any input listeners here.
}
@Override
public void terminate() throws ConnectorException {
// TODO Release any resources here
}
}