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
Nested ClassesModifier and TypeClassDescriptionstatic interfacestatic enumstatic class -
Field Summary
Fields -
Constructor Summary
Constructors -
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.ResultaddXmppAdminAccount(SchemaManager.SchemaInfo schemaInfo) Method attempts to add XMPP admin user account to the database usingAuthRepository.abstract Pabstract SchemaLoader.Resultabstract voidexecute(SchemaLoader.Parameters params) static List<SchemaLoader.TypeInfo> static Stream<SchemaLoader.TypeInfo> abstract List<CommandlineParameter> getComponentVersionFromDb(String component) protected Stringprotected <DS extends DataSource>
Stream<Class<DataSourceAware<DS>>> getDataSourceAwareClassesForSchemaInfo(SchemaManager.SchemaInfo schema, Class<DS> dataSourceIfc) abstract StringgetDBUri()static Optional<SchemaLoader.TypeInfo> 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> static Optional<SchemaLoader.TypeInfo> abstract List<SchemaLoader.TypeInfo> protected StringgetType()voidabstract voidinit(P props, Optional<SchemaManager.RootCredentialsCache> rootCredentialsCache) protected AuthRepositoryinitializeAuthRepository(AuthRepository authRepository) protected <T extends DataSource>
Function<DataSourceAware<T>, DataSourceAware<T>> initializeDataSourceAwareFunction(T dataSource, Logger log) protected <T> TinstantiateClass(Class<T> clazz) booleanisSupported(String dbType) abstract SchemaLoader.ResultloadSchema(SchemaManager.SchemaInfo schemaInfo, String version) abstract SchemaLoader.ResultloadSchemaFile(String fileName) Method checks whether the connection to the database is possible and that database of specified name exists.static voidMain method allowing pass arguments to the class and setting all logging to be printed to console.static SchemaLoadernewInstance(String type) static SchemaLoadernewInstanceForURI(String uri) abstract SchemaLoader.Resultabstract SchemaLoader.ResultsetComponentVersion(String component, String version) Methods attempt to write to database loaded schema version for particular componentabstract SchemaLoader.Resultshutdown()abstract SchemaLoader.ResultMethod validates whether the connection can at least be eI stablished.abstract SchemaLoader.ResultMethod, if the connection is validated byvalidateDBConnection, checks whether desired database exists.
-
Field Details
-
log
-
-
Constructor Details
-
SchemaLoader
public SchemaLoader()
-
-
Method Details
-
getMainCommandlineParameters
-
getAllSupportedTypesStream
-
getAllSupportedTypes
-
getSupportedTypeForName
-
getDefaultSupportedTypeForName
-
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.sqlschema 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.Resultobject 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 ofStringwith 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
-