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
KVImplementation
s that create SQLKVDatabase
instances.-
Nested Class Summary
-
Field Summary
-
Constructor Summary
ModifierConstructorDescriptionprotected
SQLDriverKVImplementation
(String driverClassName) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract void
addJdbcUriOption
(joptsimple.OptionParser parser) protected void
addJdbcUriOption
(joptsimple.OptionParser parser, String option, String description) void
addOptions
(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 C
buildConfig
(joptsimple.OptionSet options, URI uri) createKVDatabase
(C config, KVDatabase kvdb, AtomicKVStore kvstore) Create anKVDatabase
using the specified configuration.protected abstract SQLKVDatabase
createSQLKVDatabase
(C config) Instantiate aSQLKVDatabase
.boolean
Determine whether thisKVImplementation
includes an implementation of theKVDatabase
interface.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.permazen.kv.KVImplementation
createAtomicKVStore, getConfigType, getDescription, providesAtomicKVStore, requiresAtomicKVStore, requiresKVDatabase
-
Field Details
-
jdbcUriOption
-
-
Constructor Details
-
SQLDriverKVImplementation
Constructor.- Parameters:
driverClassName
-Driver
implementation class name
-
-
Method Details
-
addOptions
public void addOptions(joptsimple.OptionParser parser) Description copied from interface:KVImplementation
Add 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:
addOptions
in 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:KVImplementation
Build 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:
buildConfig
in 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:KVImplementation
Create anKVDatabase
using the specified configuration.The implementation in
KVImplementation
always throwsUnsupportedOperationException
.- Specified by:
createKVDatabase
in 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
KVDatabase
instance
-
providesKVDatabase
Description copied from interface:KVImplementation
Determine whether thisKVImplementation
includes an implementation of theKVDatabase
interface.The implementation in
KVImplementation
return false.- Specified by:
providesKVDatabase
in 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
-