Package tigase.db.util
Class SchemaLoader<P extends SchemaLoader.Parameters>
java.lang.Object
tigase.db.util.SchemaLoader<P>
- Direct Known Subclasses:
DBSchemaLoader
- Author:
- andrzej
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
static enum
static class
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected <T extends DataSource>
SchemaLoader.ResultaddUsersToRepository
(SchemaManager.SchemaInfo schemaInfo, T dataSource, Class<T> dataSourceClass, List<BareJID> jids, String password, Logger log) protected Function<AuthRepository,
SchemaLoader.Result> addUsersToRepositoryFunction
(List<BareJID> jids, String pwd, Logger log) abstract SchemaLoader.Result
addXmppAdminAccount
(SchemaManager.SchemaInfo schemaInfo) Method attempts to add XMPP admin user account to the database usingAuthRepository
.abstract P
abstract SchemaLoader.Result
abstract void
execute
(SchemaLoader.Parameters params) static List<SchemaLoader.TypeInfo>
static Stream<SchemaLoader.TypeInfo>
abstract List<CommandlineParameter>
getComponentVersionFromDb
(String component) protected String
protected <DS extends DataSource>
Stream<Class<DataSourceAware<DS>>>getDataSourceAwareClassesForSchemaInfo
(SchemaManager.SchemaInfo schema, Class<DS> dataSourceIfc) abstract String
getDBUri()
protected <DSIFC extends DataSource,
DS extends DSIFC>
Stream<DataSourceAware>getInitializedDataSourceAwareForSchemaInfo
(SchemaManager.SchemaInfo schema, Class<DSIFC> dataSourceIfc, DS dataSource, Logger log) static List<CommandlineParameter>
getMainCommandlineParameters
(boolean forceNotRequired) abstract List<CommandlineParameter>
abstract List<SchemaLoader.TypeInfo>
protected String
getType()
void
abstract void
init
(P props, Optional<SchemaManager.RootCredentialsCache> rootCredentialsCache) protected AuthRepository
initializeAuthRepository
(AuthRepository authRepository) protected <T extends DataSource>
Function<DataSourceAware<T>,DataSourceAware<T>> initializeDataSourceAwareFunction
(T dataSource, Logger log) protected <T> T
instantiateClass
(Class<T> clazz) boolean
isSupported
(String dbType) abstract SchemaLoader.Result
loadSchema
(SchemaManager.SchemaInfo schemaInfo, String version) abstract SchemaLoader.Result
loadSchemaFile
(String fileName) Method checks whether the connection to the database is possible and that database of specified name exists.static void
Main method allowing pass arguments to the class and setting all logging to be printed to console.static SchemaLoader
newInstance
(String type) static SchemaLoader
newInstanceForURI
(String uri) abstract SchemaLoader.Result
abstract SchemaLoader.Result
setComponentVersion
(String component, String version) Methods attempt to write to database loaded schema version for particular componentabstract SchemaLoader.Result
shutdown()
abstract SchemaLoader.Result
Method validates whether the connection can at least be eI stablished.abstract SchemaLoader.Result
Method, if the connection is validated byvalidateDBConnection
, checks whether desired database exists.
-
Field Details
-
log
-
-
Constructor Details
-
SchemaLoader
public SchemaLoader()
-
-
Method Details
-
getMainCommandlineParameters
-
getAllSupportedTypesStream
-
getAllSupportedTypes
-
main
Main method allowing pass arguments to the class and setting all logging to be printed to console.- Parameters:
args
- key-value (in the form of"-<variable> value"
) parameters.
-
newInstance
-
newInstanceForURI
-
createParameters
-
execute
-
init
public abstract void init(P props, Optional<SchemaManager.RootCredentialsCache> rootCredentialsCache) -
init
-
getSupportedTypes
-
isSupported
-
getDBUri
-
getSetupOptions
-
getCommandlineParameters
-
validateDBConnection
Method validates whether the connection can at least be eI stablished. If yes then appropriate flag is set. -
validateDBExists
Method, if the connection is validated byvalidateDBConnection
, checks whether desired database exists. If not it creates such database using*-installer-create-db.sql
schema file substituting it's variables with ones provided. -
postInstallation
-
getConfigString
- Throws:
IOException
-
printInfo
-
addXmppAdminAccount
Method attempts to add XMPP admin user account to the database usingAuthRepository
. -
setComponentVersion
Methods attempt to write to database loaded schema version for particular component- Parameters:
component
- name of the component for which version should be setversion
- value which should be associated with the component- Returns:
- a
SchemaLoader.Result
object indicating whether the call was successful
-
getComponentVersionFromDb
-
loadSchemaFile
Method checks whether the connection to the database is possible and that database of specified name exists. If yes then a schema file from properties is loaded.- Parameters:
fileName
- set ofString
with path to file
-
shutdown
-
loadCommonSchema
-
loadSchema
-
getMinimalRequiredComponentVersionForUpgrade
public abstract Optional<Version> getMinimalRequiredComponentVersionForUpgrade(SchemaManager.SchemaInfo schema) -
destroyDataSource
-
addUsersToRepository
protected <T extends DataSource> SchemaLoader.Result addUsersToRepository(SchemaManager.SchemaInfo schemaInfo, T dataSource, Class<T> dataSourceClass, List<BareJID> jids, String password, Logger log) -
getDataSourceAwareClassesForSchemaInfo
protected <DS extends DataSource> Stream<Class<DataSourceAware<DS>>> getDataSourceAwareClassesForSchemaInfo(SchemaManager.SchemaInfo schema, Class<DS> dataSourceIfc) -
getInitializedDataSourceAwareForSchemaInfo
protected <DSIFC extends DataSource,DS extends DSIFC> Stream<DataSourceAware> getInitializedDataSourceAwareForSchemaInfo(SchemaManager.SchemaInfo schema, Class<DSIFC> dataSourceIfc, DS dataSource, Logger log) -
initializeAuthRepository
-
initializeDataSourceAwareFunction
protected <T extends DataSource> Function<DataSourceAware<T>,DataSourceAware<T>> initializeDataSourceAwareFunction(T dataSource, Logger log) -
addUsersToRepositoryFunction
protected Function<AuthRepository,SchemaLoader.Result> addUsersToRepositoryFunction(List<BareJID> jids, String pwd, Logger log) -
instantiateClass
-
getType
-