public class DatabaseService extends MigrationService
DatabaseConnection
s of a SiteApplication
.MigrationService.MigrationStatus
Modifier and Type | Field and Description |
---|---|
protected DatabaseConnectionRepository |
databaseConnectionRepository |
APP_NG_ROOT_DATABASE, DATABASE_MAX_CONNECTIONS, DATABASE_MIN_CONNECTIONS, DATABASE_NAME, DATABASE_NAME_PREFIX, DATABASE_REPAIR, DATABASE_TYPE, DATABASE_VALIDATION_PERIOD, DATABASE_VALIDATION_QUERY, HIBERNATE_CONNECTION_DRIVER_CLASS, HIBERNATE_CONNECTION_PASSWORD, HIBERNATE_CONNECTION_URL, HIBERNATE_CONNECTION_USERNAME
Constructor and Description |
---|
DatabaseService() |
Modifier and Type | Method and Description |
---|---|
DatabaseConnection |
getRootConnectionOfType(DatabaseConnection.DatabaseType type) |
protected String |
getUserName(Site site,
Application application) |
DatabaseConnection |
initDatabase(Properties config,
boolean managed,
boolean setActive)
Configures and (optionally) migrates the appNG root
DatabaseConnection from the given
Properties . |
MigrationService.MigrationStatus |
manageApplicationConnection(SiteApplication siteApplication,
ApplicationInfo applicationInfo,
File sqlFolder,
String databasePrefix)
Migrates the database for the given
SiteApplication . |
void |
resetApplicationConnection(SiteApplication siteApplication,
String databasePrefix)
Resets the configuration for the
DatabaseConnection (if existing) of the given SiteApplication to
the default values. |
void |
save(DatabaseConnection databaseConnection)
Persists the given
DatabaseConnection . |
DatabaseConnection |
setActiveConnection(DatabaseConnection rootConnection,
boolean changeManagedState)
Configures the appNG root
DatabaseConnection s by either creating a new one or updating the existing
DatabaseConnection for each DatabaseConnection.DatabaseType . |
getDataSource, getDataSource, getPlatformConnection, initDatabase, initDatabase, migrate, status, status, statusComplete, statusComplete, statusComplete
@Autowired protected DatabaseConnectionRepository databaseConnectionRepository
public void resetApplicationConnection(SiteApplication siteApplication, String databasePrefix)
DatabaseConnection
(if existing) of the given SiteApplication
to
the default values.siteApplication
- a SiteApplication
protected String getUserName(Site site, Application application)
public DatabaseConnection initDatabase(Properties config, boolean managed, boolean setActive)
DatabaseConnection
from the given
Properties
.config
- the properties read from "/conf/appNG.properties"setActive
- if the connection should be set as he active root connection, creating a new
DatabaseConnection
if necessary. Only applied if MigrationService.status(DatabaseConnection)
returns a
non-null value.DatabaseConnection
@Transactional public DatabaseConnection setActiveConnection(DatabaseConnection rootConnection, boolean changeManagedState)
DatabaseConnection
s by either creating a new one or updating the existing
DatabaseConnection
for each DatabaseConnection.DatabaseType
. Also checks if the connections are working and calls
DatabaseConnection#setActive(false)
if this is not the case.rootConnection
- the current root connectionchangeManagedState
- if set to true
, the managed state for an existing connection is set to
rootConnection#isManaged()
public DatabaseConnection getRootConnectionOfType(DatabaseConnection.DatabaseType type)
public MigrationService.MigrationStatus manageApplicationConnection(SiteApplication siteApplication, ApplicationInfo applicationInfo, File sqlFolder, String databasePrefix)
SiteApplication
.siteApplication
- the SiteApplication
to migrate the database forapplicationInfo
- the Application
's ApplicationInfo
as read from
"application.xml".sqlFolder
- the root folder for the migration-scripts provided by the SiteApplication
MigrationService.MigrationStatus
@Transactional public void save(DatabaseConnection databaseConnection)
DatabaseConnection
.databaseConnection
- the connection to persist.Copyright © 2011–2019 aiticon GmbH. All rights reserved.