Package io.permazen.kv.sql
Class SQLDriverKVImplementation<C extends SQLDriverKVImplementation.Config>
java.lang.Object
io.permazen.kv.sql.SQLDriverKVImplementation<C>
- Type Parameters:
C- configuration object type
- All Implemented Interfaces:
KVImplementation<C>
- Direct Known Subclasses:
CockroachKVImplementation,MSSQLKVImplementation,MySQLKVImplementation
public abstract class SQLDriverKVImplementation<C extends SQLDriverKVImplementation.Config>
extends Object
implements KVImplementation<C>
Support superclass for
KVImplementations that create SQLKVDatabase instances.-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedSQLDriverKVImplementation(String driverClassName) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract voidaddJdbcUriOption(joptsimple.OptionParser parser) protected voidaddJdbcUriOption(joptsimple.OptionParser parser, String option, String description) voidaddOptions(joptsimple.OptionParser parser) Add implementation-specific command line options.buildConfig(joptsimple.OptionSet options) Build a configuration from implementation-specific command line options, if any were given.protected abstract CbuildConfig(joptsimple.OptionSet options, URI uri) createKVDatabase(C config, KVDatabase kvdb, AtomicKVStore kvstore) Create anKVDatabaseusing the specified configuration.protected abstract SQLKVDatabasecreateSQLKVDatabase(C config) Instantiate aSQLKVDatabase.booleanDetermine whether thisKVImplementationincludes an implementation of theKVDatabaseinterface.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.permazen.kv.KVImplementation
createAtomicKVStore, getConfigType, getDescription, providesAtomicKVStore, requiresAtomicKVStore, requiresKVDatabase
-
Field Details
-
jdbcUriOption
-
-
Constructor Details
-
SQLDriverKVImplementation
Constructor.- Parameters:
driverClassName-Driverimplementation class name
-
-
Method Details
-
addOptions
public void addOptions(joptsimple.OptionParser parser) Description copied from interface:KVImplementationAdd implementation-specific command line options.All of the added options must be optional, because multiple key/value implementations will be available when the command line is parsed, and the presence of implementation-specific options determines which one(s) are chosen.
- Specified by:
addOptionsin interfaceKVImplementation<C extends SQLDriverKVImplementation.Config>- Parameters:
parser- command line flag parser
-
addJdbcUriOption
protected abstract void addJdbcUriOption(joptsimple.OptionParser parser) -
addJdbcUriOption
-
buildConfig
Description copied from interface:KVImplementationBuild a configuration from implementation-specific command line options, if any were given.If none of this implementation's options were provided, then this method must return null.
- Specified by:
buildConfigin interfaceKVImplementation<C extends SQLDriverKVImplementation.Config>- Parameters:
options- parsed command line options- Returns:
- corresponding configuration, or null if this implementation was not configured
-
buildConfig
-
createKVDatabase
Description copied from interface:KVImplementationCreate anKVDatabaseusing the specified configuration.The implementation in
KVImplementationalways throwsUnsupportedOperationException.- Specified by:
createKVDatabasein interfaceKVImplementation<C extends SQLDriverKVImplementation.Config>- Parameters:
config- implementation configuration returned bybuildConfig()kvdb- requiredKVDatabase; will be null unlessKVImplementation.requiresKVDatabase(C)returned truekvstore- requiredAtomicKVStore; will be null unlessKVImplementation.requiresAtomicKVStore(C)returned true- Returns:
- new
KVDatabaseinstance
-
providesKVDatabase
Description copied from interface:KVImplementationDetermine whether thisKVImplementationincludes an implementation of theKVDatabaseinterface.The implementation in
KVImplementationreturn false.- Specified by:
providesKVDatabasein interfaceKVImplementation<C extends SQLDriverKVImplementation.Config>- Parameters:
config- implementation configuration returned bybuildConfig()- Returns:
- true if this instance can create an
KVDatabase
-
createSQLKVDatabase
Instantiate aSQLKVDatabase.This method does not need to configure the
DataSource(viaSQLKVDatabase.setDataSource()); the calling method will do that.- Parameters:
config- implementation configuration returned bybuildConfig()- Returns:
- new key/value database
-