|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.ibm.di.connector.Connector
com.ibm.di.connector.ScriptConnector
public class ScriptConnector
The Script Connector enables you to write your own Connector in JavaScript. A Script Connector must implement a few functions to operate. If you plan to use it for iteration purposes only (for example, reading, not searching or updating), you can operate with two functions only. If you plan to use it as a fully qualified Connector, you must implement all functions. The functions do not use parameters. Passing data between the hosting Connector and the script is enabled by using predefined objects. One of these predefined objects is the result object, which is used to communicate status information. Upon entry in either function, the status field is set to normal, which causes the hosting Connector to continue calls. Signaling end-of-input or error is done by setting the status and message fields in this object. Two other script objects are defined upon function entry, the entry object and the search object.
Field Summary |
---|
Fields inherited from class com.ibm.di.connector.Connector |
---|
ALL_MODES, myLog, PROPERTY_MESSAGE, PROPERTY_READER, PROPERTY_WRITER |
Constructor Summary | |
---|---|
ScriptConnector()
Class constructor. |
Method Summary | |
---|---|
void |
deleteEntry(Entry entry,
SearchCriteria search)
Deletes an existing entry. |
Entry |
findEntry(SearchCriteria search)
Finds an existing entry. |
Entry |
getNextEntry()
Returns the next Entry from the connector. |
String |
getVersion()
Return version information |
void |
initialize(Object obj)
Initialize the connector. |
void |
modEntry(Entry entry,
SearchCriteria search)
Modifies an existing entry. |
void |
modEntry(Entry entry,
SearchCriteria search,
Entry old)
Modifies an existing entry. |
void |
putEntry(Entry entry)
Adds a new entry to the data source |
Entry |
queryReply(Entry entry)
Performs a query/reply operations. |
Object |
querySchema(Object source)
This function translates to whatever means a connector has to discover schema for a connection. |
void |
selectEntries()
Prepare the Connector for sequential read. |
void |
terminate()
Terminate the connector. |
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.connector.ConnectorInterface |
---|
getConfiguration, getContext, getFindEntryCount, getFirstFindEntry, getMaxDuplicateEntries, getName, getNextClient, getNextFindEntry, getParam, getPushbackEntry, getRawConnectorConfiguration, isDeltaSupported, isExceptionFatal, isIOException, pushback, queryOperations, reconnect, registerScriptBeans, replyEntry, setConfiguration, setContext, setCurrent, setLog, setMaxDuplicateEntries, setName, setParam, setRSInterface, terminateServer |
Constructor Detail |
---|
public ScriptConnector()
Method Detail |
---|
public void initialize(Object obj) throws Exception
initialize
in interface ConnectorInterface
initialize
in class Connector
obj
- User provided parameter
Exception
- if the initialization of this connector fails.public void selectEntries() throws Exception
selectEntries
in interface ConnectorInterface
selectEntries
in class Connector
Exception
- if an error occurs.public Entry getNextEntry() throws 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
getNextEntry
in class Connector
Exception
- if an error occurs.ConnectorInterface.selectEntries()
public void modEntry(Entry entry, SearchCriteria search) throws Exception
modEntry
in interface ConnectorInterface
modEntry
in class Connector
entry
- The entry datasearch
- The search criteria used to locate the entry to be modified
Exception
- if an error occurs.public void modEntry(Entry entry, SearchCriteria search, Entry old) throws Exception
modEntry
in interface ConnectorInterface
modEntry
in class Connector
entry
- The entry datasearch
- The search criteria used to locate the entry to be modifiedold
- The old entry found by the search criteria
Exception
- if an error occurs.public void deleteEntry(Entry entry, SearchCriteria search) throws Exception
deleteEntry
in interface ConnectorInterface
deleteEntry
in class Connector
entry
- The entry datasearch
- The search criteria used to locate the entry to be deleted
Exception
- if an error occurs.public Entry findEntry(SearchCriteria search) throws 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
findEntry
in class Connector
search
- The search criteria used to locate the entry to be modified
Exception
- if an error occurs.public void putEntry(Entry entry) throws 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
putEntry
in class Connector
entry
- The entry data to add
Exception
- if an error occurs.public Entry queryReply(Entry entry) throws Exception
queryReply
in interface ConnectorInterface
queryReply
in class Connector
entry
- The data used in outgoing call
Exception
- if an error occurs.public void terminate() throws Exception
terminate
in interface ConnectorInterface
terminate
in class Connector
Exception
- if an error occurs.public Object querySchema(Object source) throws 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
querySchema
in class Connector
source
- The object on which to discover schema. This may be an Entry
or a string value
Exception
- if an error while retrieving the schema occurs.Entry
,
Vector
public String getVersion()
getVersion
in interface VersionInfoInterface
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |