Package com.ibm.di.connector
Class PropertiesConnector
- java.lang.Object
-
- com.ibm.di.connector.Connector
-
- com.ibm.di.connector.PropertiesConnector
-
- All Implemented Interfaces:
ConnectorInterface,VersionInfoInterface
public class PropertiesConnector extends Connector implements ConnectorInterface
Properties Connector operates on a file or URL.
-
-
Field Summary
Fields Modifier and Type Field Description protected booleanisJavaPropertiesA flag that marks a collection of Java Properties.protected java.util.Iterator<java.lang.Object>jpIteratorIterator over the Java Properties' keys.protected java.util.Map<java.lang.String,java.lang.Object>mapIn-memory dataprotected java.util.Iterator<java.lang.String>mapIteratorIterator over the in-memory/sysStore/File properties' keys.protected booleanmodifiedA flag that marks a modified collection.static java.lang.StringPARAM_AUTOREWRITEConnector parameter name: "autorewrite"static java.lang.StringPARAM_CIPHERConnector parameter name: "cipher"static java.lang.StringPARAM_COLLECTIONConnector parameter name: "collection"static java.lang.StringPARAM_COLLECTION_TYPEConnector parameter name: "collectionType"static java.lang.StringPARAM_CREATE_FILEConnector parameter name: "createCollection"static java.lang.StringPARAM_ENCRYPTIONConnector parameter name: "encryption"static java.lang.StringPARAM_PASSWORDConnector parameter name: "secret"protected PropertiesFilepropsFileThePropertiesFileobject.protected CryptopropsFileCryptoTheCryptoobject used for decryption of the entire properties file.static java.lang.StringPROTECT_PREFIXPrefix used by encrypted property valuesstatic java.lang.StringPROTECT_VAL_PREFIXPrefix used in property value to indicate encrypted datastatic java.lang.String[]SUPPORTED_MODESSupported connector modesprotected PropertyStoresystemStoreThePropertyStoreobject.protected UserFunctionsufHelper object.-
Fields inherited from class com.ibm.di.connector.Connector
ALL_MODES, myLog, PROPERTY_MESSAGE, PROPERTY_READER, PROPERTY_WRITER
-
-
Constructor Summary
Constructors Constructor Description PropertiesConnector()Constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddeleteEntry(Entry entry, SearchCriteria search)Deletes the specified key/value pair from the configured property store.EntryfindEntry(SearchCriteria search)Looks for a key name in the configured store.EntrygetNextEntry()Iterates over the set of keys and returns an entry for each property.java.lang.StringgetVersion()Return version informationvoidinitialize(java.lang.Object o)Initialize the connector.protected voidloadProperties(java.lang.String path)Loads the data from path into a buffer where decryption is applied before parsing the properties into the map object.voidmodEntry(Entry entry, SearchCriteria search)Modifies an existing entry.voidputEntry(Entry entry)Adds a key/value pair in the specified property store.java.lang.ObjectquerySchema(java.lang.Object source)This function translates to whatever means a connector has to discover schema for a connection.voidsaveProperties(java.lang.String path)Saves the properties in the appropriate store.voidselectEntries()Initializes the helper iterators objects used for iterating over the keys of the configured property store.voidsetModified()Set the modified flag, to make sure that the values are saved even if no change has been madevoidsetProperty(java.lang.String key, java.lang.Object value, boolean encr)Sets the provided property in the JavaPropertiesMap/SystemStore/PropertyFile.voidsetProperty(java.lang.String key, java.lang.Object value, java.lang.Boolean encr)Sets the provided property in the JavaPropertiesMap/SystemStore/PropertyFile.voidterminate()Terminate the connector.-
Methods inherited from class com.ibm.di.connector.Connector
addFindEntry, allModes, clearFindEntries, debug, debugMode, extractExceptionInformation, findEntry, getBoolean, getClassInstance, getConfiguration, getContext, getFindEntryCount, getFirstFindEntry, getLog, getMaxDuplicateEntries, getModes, getModes, getName, getNextClient, getNextFindEntry, getParam, getParser, getProperty, getPushbackEntry, getRawConnectorConfiguration, getRSInterface, getUI, hasConfigValue, hasParser, initParser, isDeltaSupported, isExceptionFatal, isIOException, logError, logmsg, modEntry, pushback, queryOperations, queryReply, queryTables, reconnect, reconnect, registerScriptBeans, replyEntry, setConfiguration, setContext, setCurrent, setDebugMode, setLog, setMaxDuplicateEntries, setModes, setModes, setName, setParam, setParser, setProperty, setRSInterface, terminateServer
-
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, modEntry, pushback, queryOperations, queryReply, reconnect, registerScriptBeans, replyEntry, setConfiguration, setContext, setCurrent, setLog, setMaxDuplicateEntries, setName, setParam, setRSInterface, terminateServer
-
-
-
-
Field Detail
-
PARAM_COLLECTION
public static final java.lang.String PARAM_COLLECTION
Connector parameter name: "collection"- See Also:
- Constant Field Values
-
PARAM_COLLECTION_TYPE
public static final java.lang.String PARAM_COLLECTION_TYPE
Connector parameter name: "collectionType"- See Also:
- Constant Field Values
-
PARAM_ENCRYPTION
public static final java.lang.String PARAM_ENCRYPTION
Connector parameter name: "encryption"- See Also:
- Constant Field Values
-
PARAM_CIPHER
public static final java.lang.String PARAM_CIPHER
Connector parameter name: "cipher"- See Also:
- Constant Field Values
-
PARAM_PASSWORD
public static final java.lang.String PARAM_PASSWORD
Connector parameter name: "secret"- See Also:
- Constant Field Values
-
PARAM_AUTOREWRITE
public static final java.lang.String PARAM_AUTOREWRITE
Connector parameter name: "autorewrite"- See Also:
- Constant Field Values
-
PARAM_CREATE_FILE
public static final java.lang.String PARAM_CREATE_FILE
Connector parameter name: "createCollection"- See Also:
- Constant Field Values
-
PROTECT_PREFIX
public static final java.lang.String PROTECT_PREFIX
Prefix used by encrypted property values- See Also:
- Constant Field Values
-
PROTECT_VAL_PREFIX
public static final java.lang.String PROTECT_VAL_PREFIX
Prefix used in property value to indicate encrypted data- See Also:
- Constant Field Values
-
SUPPORTED_MODES
public static final java.lang.String[] SUPPORTED_MODES
Supported connector modes
-
map
protected java.util.Map<java.lang.String,java.lang.Object> map
In-memory data
-
modified
protected boolean modified
A flag that marks a modified collection.
-
isJavaProperties
protected boolean isJavaProperties
A flag that marks a collection of Java Properties.
-
systemStore
protected PropertyStore systemStore
ThePropertyStoreobject.
-
propsFile
protected PropertiesFile propsFile
ThePropertiesFileobject.
-
propsFileCrypto
protected Crypto propsFileCrypto
TheCryptoobject used for decryption of the entire properties file.
-
mapIterator
protected java.util.Iterator<java.lang.String> mapIterator
Iterator over the in-memory/sysStore/File properties' keys.
-
jpIterator
protected java.util.Iterator<java.lang.Object> jpIterator
Iterator over the Java Properties' keys.
-
uf
protected UserFunctions uf
Helper object.
-
-
Method Detail
-
initialize
public void initialize(java.lang.Object o) throws java.lang.ExceptionInitialize the connector. For file/url collections the contents is loaded at this point- Specified by:
initializein interfaceConnectorInterface- Overrides:
initializein classConnector- Parameters:
o- This parameter is ignored by this connector.- Throws:
java.lang.Exception- Any exception thrown by java.io/java.net classes when loading a file/url.
-
terminate
public void terminate() throws java.lang.ExceptionTerminate the connector. This function closes all connection and releases all resources used by the connector. This function also calls the parser's closeParser() method if a parser is active.- Specified by:
terminatein interfaceConnectorInterface- Overrides:
terminatein classConnector- Throws:
java.lang.Exception- if an error occurs.
-
loadProperties
protected void loadProperties(java.lang.String path) throws java.lang.ExceptionLoads the data from path into a buffer where decryption is applied before parsing the properties into the map object.- Parameters:
path- The filename or URL from which to read props- Throws:
java.lang.Exception- if an error occurs while loading properties
-
setProperty
public void setProperty(java.lang.String key, java.lang.Object value, boolean encr) throws java.lang.ExceptionSets the provided property in the JavaPropertiesMap/SystemStore/PropertyFile.- Parameters:
key- the key name to use.value- the value to set.encr- specify whether the value should be encrypted.- Throws:
java.lang.Exception- if an error occurs.
-
setProperty
public void setProperty(java.lang.String key, java.lang.Object value, java.lang.Boolean encr) throws java.lang.ExceptionSets the provided property in the JavaPropertiesMap/SystemStore/PropertyFile.- Parameters:
key- the key name to use.value- the value to set.encr- If not null, specify whether the value should be encrypted. If null, keep old encryption status if possible.- Throws:
java.lang.Exception- if an error occurs.- Since:
- 7.0
-
saveProperties
public void saveProperties(java.lang.String path) throws java.lang.ExceptionSaves the properties in the appropriate store. If the store is configured to be the SystemStore then this call is ignored.- Parameters:
path- this is the path to the file in which the properties will be saved. This parameter is ignored if the connector is configured to store properties in other than a File.- Throws:
java.lang.Exception- if an error occurs.
-
selectEntries
public void selectEntries() throws java.lang.ExceptionInitializes the helper iterators objects used for iterating over the keys of the configured property store.- Specified by:
selectEntriesin interfaceConnectorInterface- Overrides:
selectEntriesin classConnector- Throws:
java.lang.Exception- if an error occurs.
-
getNextEntry
public Entry getNextEntry() throws java.lang.Exception
Iterates over the set of keys and returns an entry for each property.- Specified by:
getNextEntryin interfaceConnectorInterface- Overrides:
getNextEntryin classConnector- Returns:
- an entry that represents the key/value pair in the specified store, or null if the store is exhausted.
- Throws:
java.lang.Exception- if an error occurs.- See Also:
ConnectorInterface.selectEntries()
-
findEntry
public Entry findEntry(SearchCriteria search) throws java.lang.Exception
Looks for a key name in the configured store. The key name is provided using the first value of aSearchCriteriaobject.- Specified by:
findEntryin interfaceConnectorInterface- Overrides:
findEntryin classConnector- Parameters:
search- the object used to find the specific property. Note: only the first criteria is used, the rest (if any) are ignored.- Returns:
- an entry that represents the key/value pair in the specified store, or null if a property with the specified key name could not be found.
- Throws:
java.lang.Exception- if an error occurs.
-
querySchema
public java.lang.Object querySchema(java.lang.Object source) throws java.lang.ExceptionThis function translates to whatever means a connector has to discover schema for a connection. The connector may implement this, in which case a Vector of Entry objects is returned for each column/attribute it discovered. For a database connector this would typically be column names and their attributes.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 - Specified by:
querySchemain interfaceConnectorInterface- Overrides:
querySchemain classConnector- Parameters:
source- The object on which to discover schema. This may be an Entry or a string value- Returns:
- A Vector of com.ibm.di.entry.Entry objects describing each entity
- Throws:
java.lang.Exception- if an error while retrieving the schema occurs.- See Also:
Entry,Vector
-
putEntry
public void putEntry(Entry entry) throws java.lang.Exception
Adds a key/value pair in the specified property store.- Specified by:
putEntryin interfaceConnectorInterface- Overrides:
putEntryin classConnector- Parameters:
entry- the entry containing the attributes "key" and "value".- Throws:
java.lang.Exception- if an error occurs.
-
modEntry
public void modEntry(Entry entry, SearchCriteria search) throws java.lang.Exception
Modifies an existing entry. The new entry data is given by the entry parameter and the search criteria specifies which entry to modify.- Specified by:
modEntryin interfaceConnectorInterface- Overrides:
modEntryin classConnector- Parameters:
entry- The entry datasearch- The search criteria used to locate the entry to be modified- Throws:
java.lang.Exception- Any exceptions thrown by the connector's underlying classes
-
deleteEntry
public void deleteEntry(Entry entry, SearchCriteria search) throws java.lang.Exception
Deletes the specified key/value pair from the configured property store.- Specified by:
deleteEntryin interfaceConnectorInterface- Overrides:
deleteEntryin classConnector- Parameters:
entry- - ignored.search- theSearchCriteriaobject which first criteria object is used to find the property to delete.- Throws:
java.lang.Exception- if an error occurs.
-
setModified
public void setModified()
Set the modified flag, to make sure that the values are saved even if no change has been made
-
getVersion
public java.lang.String getVersion()
Return version information- Specified by:
getVersionin interfaceVersionInfoInterface- Returns:
- The version value
-
-