public abstract class StoreDataSource
extends Object
Modifier and Type | Field and Description |
---|---|
static String |
CUSTOM_PROPERTIES
Custom properties.
|
static String |
DRIVER_CLASS_PROPERTY
The JDBC driver class.
|
static String |
PASSWORD_PROPERTY
The password for connection to the database.
|
static String |
SHARED_PROPERTY
Indicates that a single connection will be shared.
|
static String |
URL_PROPERTY
The URL for connection to the database.
|
static String |
USER_PROPERTY
The user for connection to the database.
|
Constructor and Description |
---|
StoreDataSource() |
Modifier and Type | Method and Description |
---|---|
StoreConnection |
getConnection()
Gets a connection.
|
protected abstract String |
getDefaultConnectionOptions()
Gets the default connection options.
|
protected abstract Optional<String> |
getDefaultConnectionPassword()
Gets the default connection password.
|
protected abstract boolean |
getDefaultConnectionShared()
Gets the default connection shared indicator.
|
protected abstract String |
getDefaultConnectionURL(File storeDataDir,
String storeEntityName)
Gets the default connection URL.
|
protected abstract String |
getDefaultConnectionUser()
Gets the default connection user.
|
protected Logger |
getThisLogger()
Gets the logger.
|
protected StoreConnection |
newStoreConnection(Connection connection,
boolean shared)
Creates a new store connection.
|
protected void |
onFirstConnection(StoreConnection storeConnection)
Called on the first connection.
|
protected abstract Class<? extends Driver> |
registerDriver(ClassDef driverClassDef)
Registers the JDBC driver.
|
boolean |
setUp(KeyedGroups connectionProperties,
File storeDataDir,
String storeEntityName)
Sets up the data source.
|
void |
tearDown()
Tears down what has been set up.
|
public static final String CUSTOM_PROPERTIES
public static final String DRIVER_CLASS_PROPERTY
public static final String PASSWORD_PROPERTY
public static final String SHARED_PROPERTY
public static final String URL_PROPERTY
public static final String USER_PROPERTY
@Nonnull @CheckReturnValue public StoreConnection getConnection() throws SQLException
SQLException
- From the actual data source.@CheckReturnValue public final boolean setUp(@Nonnull KeyedGroups connectionProperties, @Nonnull File storeDataDir, @Nonnull String storeEntityName)
connectionProperties
- The connection properties.storeDataDir
- The store data directory.storeEntityName
- The store entity name.public final void tearDown()
@Nonnull @CheckReturnValue protected abstract String getDefaultConnectionOptions()
@Nonnull @CheckReturnValue protected abstract Optional<String> getDefaultConnectionPassword()
@CheckReturnValue protected abstract boolean getDefaultConnectionShared()
@Nonnull protected abstract String getDefaultConnectionURL(@Nonnull File storeDataDir, @Nonnull String storeEntityName)
storeDataDir
- The store data directory.storeEntityName
- The store entity name.@Nonnull @CheckReturnValue protected abstract String getDefaultConnectionUser()
@Nonnull @CheckReturnValue protected final Logger getThisLogger()
@Nonnull @CheckReturnValue protected StoreConnection newStoreConnection(@Nonnull Connection connection, boolean shared)
connection
- The wrapped Connection
.shared
- Specifies if the Connection
is shared.protected void onFirstConnection(@Nonnull StoreConnection storeConnection)
storeConnection
- The newly established connection.@Nullable @CheckReturnValue protected abstract Class<? extends Driver> registerDriver(@Nonnull ClassDef driverClassDef)
driverClassDef
- The driver class definition.Copyright © 2003-2019 Serge Brisson. All Rights Reserved.