|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.ibm.di.connector.Connector
public abstract class Connector
The Connector class provides a default implementation of the ConnectorInterface.
If the entry/search results in multiple candidates for modify, delete etc the connector should use the clearFindEntries and addFindEntry methods to signal that the connector was unable to identify a single target entry. For example, the getFindEntryCount method is used by the AssemblyLine to detect this condition and branch off to the Multiple Entries Found hook so the user can deal with those situations. You should also use the getMaxDuplicateEntries method to obtain the maximum number of entries the user wants back in this case.
Field Summary | |
---|---|
static java.lang.String[] |
ALL_MODES
String array containing all of the available modes. |
protected Log |
myLog
The log object for logging messages |
static java.lang.String |
PROPERTY_MESSAGE
|
static java.lang.String |
PROPERTY_READER
|
static java.lang.String |
PROPERTY_WRITER
|
Constructor Summary | |
---|---|
Connector()
Default constructor. |
Method Summary | |
---|---|
boolean |
addFindEntry(java.lang.Object entry)
Adds an entry to the list of duplicate entries found. |
static java.util.Vector<java.lang.String> |
allModes()
Returns all Modes |
void |
clearFindEntries()
Removes all entries from the duplicate entry list. |
void |
debug(java.lang.String msg)
Log a debug message to the connector's log |
boolean |
debugMode()
Returns whether debug mode is set or not. |
void |
deleteEntry(Entry entry,
SearchCriteria search)
Deletes an existing entry. |
Entry |
findEntry(java.lang.Object key,
java.lang.Object value)
Locates an entry based on a key/value pair. |
Entry |
findEntry(SearchCriteria search)
Finds an existing entry. |
java.lang.Boolean |
getBoolean(java.lang.Object p1)
Returns the value of a config parameter as a Boolean |
static java.lang.Object |
getClassInstance(java.lang.String className)
Returns a class instance of the specified class name |
java.lang.Object |
getConfiguration()
Returns the current configuration for this connector |
java.lang.Object |
getContext()
Returns the parent task of the connector - an AssemblyLine
object. |
int |
getFindEntryCount()
Returns the number of duplicate entries in the list. |
Entry |
getFirstFindEntry()
Returns the first entry from the list of duplicate entries found. |
Log |
getLog()
Returns the current Log object. |
int |
getMaxDuplicateEntries()
Returns the current maximum number of duplicate entries buffered up by the connector. |
java.util.Vector<java.lang.String> |
getModes()
Returns the connector's modes. |
java.util.Vector<java.lang.String> |
getModes(ConnectorConfig config)
Returns the connector's modes. |
java.lang.String |
getName()
Returns the name for this connector. |
ConnectorInterface |
getNextClient()
Server mode - return a clone of self that handles the next client instance when running in server mode. |
Entry |
getNextEntry()
Returns the next Entry from the connector. |
Entry |
getNextFindEntry()
Returns the next entry from the list of duplicate entries found. |
java.lang.String |
getParam(java.lang.String param)
Returns the value of a parameter as a java.lang.String object. |
ParserInterface |
getParser()
Returns the parser interface used by this connector. |
java.lang.Object |
getProperty(java.lang.Object p1)
Return a connector property. |
Entry |
getPushbackEntry()
Returns the pushed back entry for the connector. |
BaseConfiguration |
getRawConnectorConfiguration()
Returns the current configuration for the raw connector |
RSInterface |
getRSInterface()
Returns the current RSInterface object in use by this connector. |
javax.swing.JComponent |
getUI()
This method returns the user interface component presented to the user to configure the connector. |
boolean |
hasConfigValue(java.lang.Object p1)
Return true if we have a configuration value for configName. |
boolean |
hasParser()
Check if the configuration includes a parser. |
void |
initialize(java.lang.Object o)
Initialize the connector. |
void |
initParser(java.lang.Object is,
java.lang.Object os)
Initialize the connector's parser with input and output streams. |
boolean |
isDeltaSupported()
Returns true if this connector is able to perform delta updates |
boolean |
isExceptionFatal(java.lang.Exception e)
Returns true if the exception is considered to be fatal. |
boolean |
isIOException(java.lang.Throwable e)
Returns true if this connector considers the
Throwable to be an IOException . |
void |
logError(java.lang.String msg)
Log an error message to the connector's log |
void |
logmsg(java.lang.String msg)
Log a message to the connector's log. |
void |
modEntry(Entry entry,
SearchCriteria search)
Modifies an existing entry. |
void |
modEntry(Entry entry,
SearchCriteria search,
Entry old)
Modifies an existing entry. |
void |
pushback(Entry e)
Make an entry the next entry to be iterated from the connector. |
void |
putEntry(Entry entry)
Adds a new entry to the data source |
void |
queryOperations(ConnectorConfig config)
Discover the operations for a connection given the provided configuration. |
Entry |
queryReply(Entry entry)
Performs a query/reply operations. |
java.lang.Object |
querySchema(java.lang.Object source)
This function translates to whatever means a connector has to discover schema for a connection. |
java.util.Vector<java.lang.String> |
queryTables()
This function translates to whatever means a connector have to discover "tables" for a connection. |
void |
reconnect()
Reconnect to the underlying data source. |
void |
reconnect(java.lang.Object o)
Reconnect to the underlying data source |
void |
registerScriptBeans(ScriptEngine se)
This method is called to register specific objects in the script context. |
void |
replyEntry(Entry entry)
Send a reply to the connector. |
void |
selectEntries()
Prepare the Connector for sequential read. |
void |
setConfiguration(java.lang.Object config)
Sets the configuration for use by this connector. |
void |
setContext(java.lang.Object aContext)
Sets the parent task of the connector - an AssemblyLine object. |
void |
setCurrent(Entry entry,
SearchCriteria search)
Change the SearchCriteria search to find the entry sent as a parameter. |
void |
setDebugMode(boolean debug)
Modify the debug mode of the component. |
void |
setLog(Log logger)
Sets the Log object to use for logging messages |
void |
setMaxDuplicateEntries(int mde)
Sets the maximum number of duplicate entries to buffer up. |
void |
setModes(java.lang.String[] modes)
Sets the connector's modes. |
void |
setModes(java.util.Vector<java.lang.String> modes)
Sets the connector's modes. |
void |
setName(java.lang.String name)
Set the name for the connector. |
void |
setParam(java.lang.String param,
java.lang.String value)
Adds or replaces a connector configuration parameter. |
void |
setParser(ParserInterface parser)
Sets the connector's parser. |
void |
setProperty(java.lang.Object p1,
java.lang.Object p2)
Set connector property. |
void |
setRSInterface(RSInterface rsi)
Sets the RSInterface for this connector to use. |
void |
terminate()
Terminate the connector. |
void |
terminateServer()
Interrupts and shuts down the Connector if it runs in Server Mode. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface com.ibm.di.server.VersionInfoInterface |
---|
getVersion |
Field Detail |
---|
public static final java.lang.String PROPERTY_MESSAGE
public static final java.lang.String PROPERTY_READER
public static final java.lang.String PROPERTY_WRITER
public static final java.lang.String[] ALL_MODES
protected Log myLog
Constructor Detail |
---|
public Connector()
Method Detail |
---|
public void setLog(Log logger)
setLog
in interface ConnectorInterface
logger
- The Log
objectRSInterface.logmsg(String)
public Log getLog()
Log
public java.lang.Boolean getBoolean(java.lang.Object p1)
p1
- the key that boolean value is mapped under.
public boolean hasConfigValue(java.lang.Object p1)
p1
- the key name of the value
public void setMaxDuplicateEntries(int mde)
setMaxDuplicateEntries
in interface ConnectorInterface
mde
- The maximum number of entries to buffer uppublic int getMaxDuplicateEntries()
getMaxDuplicateEntries
in interface ConnectorInterface
public Entry getPushbackEntry()
getPushbackEntry
in interface ConnectorInterface
ConnectorInterface.pushback( Entry )
public void pushback(Entry e)
ConnectorInterface.getNextEntry()
call. The task
component first checks if there is a pushback entry available, and if so,
returns that entry as the next input entry.
pushback
in interface ConnectorInterface
e
- The entry to be returned at the next ConnectorInterface.getNextEntry()
callpublic void logmsg(java.lang.String msg)
msg
- The message to write to the logpublic void debug(java.lang.String msg)
msg
- The message to write to the logpublic void logError(java.lang.String msg)
msg
- The message to write to the logpublic void setName(java.lang.String name)
setName
in interface ConnectorInterface
name
- The name for the connectorpublic java.lang.String getName()
getName
in interface ConnectorInterface
public void setModes(java.util.Vector<java.lang.String> modes)
modes
- The connector's modespublic void setModes(java.lang.String[] modes)
modes
- The connector's modespublic java.util.Vector<java.lang.String> getModes()
public java.util.Vector<java.lang.String> getModes(ConnectorConfig config)
config
- return the modes given this configuration
public static java.util.Vector<java.lang.String> allModes()
public void setParam(java.lang.String param, java.lang.String value)
setParam
in interface ConnectorInterface
param
- The parameter namevalue
- The parameter valuepublic java.lang.String getParam(java.lang.String param)
getParam
in interface ConnectorInterface
param
- The connector configuration parameter name
public void setConfiguration(java.lang.Object config)
setConfiguration
in interface ConnectorInterface
config
- The configuration object (an instance of ConnectorConfig)public java.lang.Object getConfiguration()
getConfiguration
in interface ConnectorInterface
public BaseConfiguration getRawConnectorConfiguration()
getRawConnectorConfiguration
in interface ConnectorInterface
public void setRSInterface(RSInterface rsi)
setRSInterface
in interface ConnectorInterface
rsi
- The RSInterface objectpublic RSInterface getRSInterface()
com.ibm.di.server.RS.getServer()
public boolean debugMode()
public void setDebugMode(boolean debug)
Modify the debug mode of the component. Also modifies the debug mode of the associated Parser. May be accessed by different threads.
This method is for internal use only. Do not call it from user code.
debug
- the debug mode settingpublic boolean isExceptionFatal(java.lang.Exception e)
isExceptionFatal
in interface ConnectorInterface
e
- The exception object
public static java.lang.Object getClassInstance(java.lang.String className) throws java.lang.Exception
className
- The fully qualified Java class name
java.lang.Exception
- exception thrown by the class loaderpublic void initialize(java.lang.Object o) throws java.lang.Exception
initialize
in interface ConnectorInterface
o
- User provided parameter
java.lang.Exception
- if the initialization of this connector fails.public boolean hasParser()
public void initParser(java.lang.Object is, java.lang.Object os) throws java.lang.Exception
is
- The input object.os
- the output object.
java.lang.Exception
- if a parser is not configured or the exception is derived
from the parsergetParser()
public void setParser(ParserInterface parser) throws java.io.IOException
parser
- The parser interface to use
java.io.IOException
- if an error occurs.public ParserInterface getParser()
public void terminate() throws java.lang.Exception
terminate
in interface ConnectorInterface
java.lang.Exception
- if an error occurs.public void selectEntries() throws java.lang.Exception
selectEntries
in interface ConnectorInterface
java.lang.Exception
- if an error occurs.public Entry getNextEntry() throws java.lang.Exception
Example:
var ctor = input.getConnector(); var entry = ctor.getNextEntry(); for (; entry != null; entry = ctor.getNextEntry()) { main.logmsg("Read entry..."); main.dumpEntry(entry); }
getNextEntry
in interface ConnectorInterface
java.lang.Exception
- if an error occurs.ConnectorInterface.selectEntries()
public ConnectorInterface getNextClient() throws java.lang.Exception
getNextClient
in interface ConnectorInterface
java.lang.Exception
- if an error occurs.public void replyEntry(Entry entry) throws java.lang.Exception
replyEntry
in interface ConnectorInterface
entry
- the information as an Entry
java.lang.Exception
- if an error occurs.public void modEntry(Entry entry, SearchCriteria search) throws java.lang.Exception
modEntry
in interface ConnectorInterface
entry
- The entry datasearch
- The search criteria used to locate the entry to be modified
java.lang.Exception
- if an error occurs.public void modEntry(Entry entry, SearchCriteria search, Entry old) throws java.lang.Exception
modEntry
in interface ConnectorInterface
entry
- The entry datasearch
- The search criteria used to locate the entry to be modifiedold
- The old entry found by the search criteria
java.lang.Exception
- if an error occurs.public void deleteEntry(Entry entry, SearchCriteria search) throws java.lang.Exception
deleteEntry
in interface ConnectorInterface
entry
- The entry datasearch
- The search criteria used to locate the entry to be deleted
java.lang.Exception
- if an error occurs.public Entry findEntry(SearchCriteria search) throws java.lang.Exception
Here is an example of how to find all people with names starting with 'J' which are from IBM organization in US.
Example:
var ctor = input.getConnector(); var crit = new com.ibm.di.SearchCriteria("$dn", com.ibm.di.SearchCriteria.SUBSTRING, "c=US,o=IBM"); crit.addCriteria("name", com.ibm.di.SearchCriteria.INITIAL_STRING, "J"); crit.addCriteria("objectclass", com.ibm.di.SearchCriteria.SUBSTRING, "person"); var res = ctor.findEntry(crit); if (res != null) { main.logmsg("Found entry:"); main.dumpEntry(res); } else { if( getFindEntryCount()> 1 ){ main.logmsg("Found these entries:"); while ( (entry = ctor.getNextFindEntry()) != null ) { main.dumpEntry(entry); } } else { main.logmsg("Entry not found!"); } }
findEntry
in interface ConnectorInterface
search
- The search criteria used to locate the entry to be modified
java.lang.Exception
- if an error occurs.public void putEntry(Entry entry) throws java.lang.Exception
Example:
var ctor = write.getConnector(); for (i = 0; i < 10; i++) { var entry = system.newEntry(); entry.setAttribute("linenumber", i); entry.setAttribute("line", i + " line of text..."); main.logmsg("Writes entry to output..."); main.dumpEntry(entry); ctor.putEntry(entry); }
putEntry
in interface ConnectorInterface
entry
- The entry data to add
java.lang.Exception
- if an error occurs.public Entry queryReply(Entry entry) throws java.lang.Exception
queryReply
in interface ConnectorInterface
entry
- The data used in outgoing call
java.lang.Exception
- if an error occurs.public Entry getFirstFindEntry() throws java.lang.Exception
getFirstFindEntry
in interface ConnectorInterface
java.lang.Exception
- if an error occurs.public Entry getNextFindEntry() throws java.lang.Exception
getNextFindEntry
in interface ConnectorInterface
java.lang.Exception
- if an error occurs.public Entry findEntry(java.lang.Object key, java.lang.Object value)
key
- The attribute namevalue
- The attribute value match
public int getFindEntryCount()
getFindEntryCount
in interface ConnectorInterface
public void clearFindEntries()
public boolean addFindEntry(java.lang.Object entry)
entry
- The entry object to add
null
or the found entries are more than
the maximumDuplicatEntriesReturned limit.public void setCurrent(Entry entry, SearchCriteria search)
setCurrent
in interface ConnectorInterface
entry
- The entry we want to find for modification/deletesearch
- The SearchCriteria we want to changepublic void queryOperations(ConnectorConfig config) throws java.lang.Exception
queryOperations
in interface ConnectorInterface
config
- The configuration
java.lang.Exception
- if an error occurs in the derived class implementation.public java.lang.Object querySchema(java.lang.Object source) throws java.lang.Exception
Each Entry in the Vector returned should contain the following attributes:
Name | Value |
---|---|
name | The name of the column/attribute/field .... |
syntax | The syntax or expected value type |
size | If specified this will give the user a hint as to how long the field may be |
querySchema
in interface ConnectorInterface
source
- The object on which to discover schema. This may be an Entry
or a string value
java.lang.Exception
- if an error while retrieving the schema occurs.Entry
,
Vector
public java.util.Vector<java.lang.String> queryTables() throws java.lang.Exception
java.lang.Exception
- if an error occurs.Vector
public java.lang.Object getProperty(java.lang.Object p1)
p1
- The property name
public void setProperty(java.lang.Object p1, java.lang.Object p2)
p1
- The property namep2
- The property valuepublic void registerScriptBeans(ScriptEngine se) throws java.lang.Exception
registerScriptBeans
in interface ConnectorInterface
se
- The script engine context
java.lang.Exception
- if an error occurs.public void reconnect(java.lang.Object o) throws java.lang.Exception
reconnect
in interface ConnectorInterface
o
- User provided parameter, which is sent to initialize()
java.lang.Exception
- if an error occurs.ConnectorInterface.initialize(Object)
public void reconnect() throws java.lang.Exception
The following code could be placed in the 'On Connection lost' hook to
change the connector's ldapUrl
to another server in case
the connection is lost.
Example:
thisConnector.setParam("ldapURL", "ldap://backupserver.acme.com:389"); // reconnect to backup server thisConnector.reconnect();
java.lang.Exception
- if an error occurs.initialize(Object)
public boolean isDeltaSupported()
isDeltaSupported
in interface ConnectorInterface
public boolean isIOException(java.lang.Throwable e)
true
if this connector considers the
Throwable
to be an IOException
. This is needed because
we only try reconnection for IO Exceptions, and some Connectors do not
return an IOException for an IO Exception.
isIOException
in interface ConnectorInterface
e
- The Throwable
to be determined
public void terminateServer() throws java.lang.Exception
terminateServer
in interface ConnectorInterface
java.lang.Exception
- if an error occurspublic java.lang.Object getContext()
AssemblyLine
object.
Here is an example hook of how to print the names of all enabled or passive components in the current running assembly line.
Example:
var ctx = thisConnector.getConnector().getContext(); var clist = ctx.getConnectors(); for (i = 0; i < clist.size(); i++) main.logmsg(clist.get(i).getName());
getContext
in interface ConnectorInterface
public void setContext(java.lang.Object aContext)
AssemblyLine
object.
setContext
in interface ConnectorInterface
aContext
- the new context to which the connector will belong.public javax.swing.JComponent getUI()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |