public class JdbcPersistorImpl extends Object implements Persistor
A basic JDBC Implementation of a Persistor. This implementation expects the user to provide the following configuration in Transformers persistence.conf configuration file
persistence.conf
persistence-classid com/caplin/transformer/persistence/JdbcPersistorImpl
add-database-params
init-string <jdbc url>
driver-name <jdbc driver - must be explicitly added to transformers jvm-global-classpath>
username <db user>
password <db password>
table-name <name of the table to be used>
columns <key_column, value_column>
extra-params <SLF4J_log_level, num_pooled_connections>
end-database-params
java.conf
jvm-global-classpath <path_to_jdbc_driver>
end-database-params
Constructor and Description |
---|
JdbcPersistorImpl(PersistorConfiguration configuration) |
Modifier and Type | Method and Description |
---|---|
void |
onDelete(String key)
Delete a row with the provided key from the Database
|
PersistedValue |
onGet(String key)
Retrieve a row from the Database
|
void |
onInsert(PersistedValue persistedValue)
Implement this method to handle Insert/Put callbacks.
|
PersistedValue[] |
onQuery(String query)
A Query is a prefix match for all keys in the database.
|
void |
onShutdown()
When transformer unloads the module, usually a shutdown.
|
public JdbcPersistorImpl(PersistorConfiguration configuration) throws Exception
Exception
public void onInsert(PersistedValue persistedValue)
Persistor
Implement this method to handle Insert/Put callbacks. An insert is expected to overwrite the previously stored value associated with the provided key
onInsert
in interface Persistor
persistedValue
- The PersistedValue
to be storedpublic PersistedValue onGet(String key)
Persistor
Retrieve a row from the Database
onGet
in interface Persistor
key
- The key associated with the rowPersistedValue
representing the rowpublic PersistedValue[] onQuery(String query)
Persistor
A Query is a prefix match for all keys in the database.
onQuery
in interface Persistor
query
- an arbitrary String, can be empty tooPersistedValue
representing all rows whose key starts with the querypublic void onDelete(String key)
Persistor
Delete a row with the provided key from the Database
public void onShutdown()
Persistor
When transformer unloads the module, usually a shutdown. This callback is being called, so that open connections can be closed
onShutdown
in interface Persistor
Please send bug reports and comments to Caplin support