public class SQLDataSourceManager extends AbstractDataSourceManager implements Disposable
AbstractDataSourceManager.DataSourceDefinition
Modifier and Type | Field and Description |
---|---|
private static I18nizableText |
__AMETYS_INTERNAL_DATASOURCE_DESCRIPTION |
private static I18nizableText |
__AMETYS_INTERNAL_DATASOURCE_NAME |
private static String |
__filename |
private AbstractDataSourceManager.DataSourceDefinition |
_internalDataSource |
private ServiceManager |
_manager |
private Map<String,org.apache.commons.pool2.ObjectPool> |
_pools |
private SQLDatabaseTypeExtensionPoint |
_sqlDatabaseTypeEP |
private Map<String,DataSource> |
_sqlDataSources |
static String |
AMETYS_INTERNAL_DATASOURCE_ID
The id of the internal DataSource
|
static String |
PARAM_DATABASE_PASSWORD
Name of parameter for user's password
|
static String |
PARAM_DATABASE_TYPE
Name of parameter for database type
|
static String |
PARAM_DATABASE_URL
Name of parameter for database url
|
static String |
PARAM_DATABASE_USER
Name of parameter for user's login
|
static String |
ROLE
Avalon Role
|
static String |
SQL_DATASOURCE_PREFIX
The id of the internal DataSource
|
_currentUserProvider, _dataSourcesDef, _observationManager, DEFAULT_DATASOURCE_SUFFIX
Constructor and Description |
---|
SQLDataSourceManager() |
Modifier and Type | Method and Description |
---|---|
private void |
_closePool(String id) |
private void |
_disposePool(String id)
Dispose of a connection pool
|
void |
checkParameters(Map<String,String> rawParameters)
Checks the parameters of a data source
|
protected void |
createDataSource(AbstractDataSourceManager.DataSourceDefinition dataSourceDef)
Creates a data source from its configuration
|
protected void |
deleteDataSource(AbstractDataSourceManager.DataSourceDefinition dataSource)
Deletes a data source
|
void |
dispose() |
protected void |
editDataSource(AbstractDataSourceManager.DataSourceDefinition dataSource)
Edit a data source from its configuration
|
AbstractDataSourceManager.DataSourceDefinition |
getDataSourceDefinition(String id)
Get the data source definition or null if not found
|
Map<String,AbstractDataSourceManager.DataSourceDefinition> |
getDataSourceDefinitions(boolean includePrivate,
boolean includeInternal,
boolean includeDefault)
Get the data source definitions
|
protected String |
getDataSourcePrefixId()
Get the prefix for data source identifier
|
AbstractDataSourceManager.DataSourceDefinition |
getDefaultDataSourceDefinition()
Get the default data source for this type
|
File |
getFileConfiguration()
Get the file configuration of data sources
|
static AbstractDataSourceManager.DataSourceDefinition |
getInternalDataSourceDefinition()
Get the datasource definition for internal database
|
Connection |
getInternalSQLDataSourceConnection()
Get a connection object the internal data source
|
private SQLDatabaseTypeExtensionPoint |
getSQLDatabaseTypeEP() |
DataSource |
getSQLDataSource(String id)
Get the SQL data source by its identifier
|
Map<String,DataSource> |
getSQLDataSources()
Get the existing SQL data sources
|
static File |
getStaticFileConfiguration()
Get the configuration file for SQL data sources
|
void |
initialize() |
protected void |
internalSetDefaultDataSource()
Set a default data source internally
|
void |
service(ServiceManager serviceManager) |
AbstractDataSourceManager.DataSourceDefinition |
setDefaultDataSource(String id)
Set the data source with the given id as the default data source
|
static void |
setFilename(String filename)
Set the config filename.
|
add, checkDataSources, delete, edit, getDefaultDataSourceId, readConfiguration, readDataSourceDefinition, saveConfiguration, saxDataSource
getLogger, setLogger
public static final String PARAM_DATABASE_TYPE
public static final String PARAM_DATABASE_URL
public static final String PARAM_DATABASE_USER
public static final String PARAM_DATABASE_PASSWORD
public static final String SQL_DATASOURCE_PREFIX
public static final String AMETYS_INTERNAL_DATASOURCE_ID
private static final I18nizableText __AMETYS_INTERNAL_DATASOURCE_NAME
private static final I18nizableText __AMETYS_INTERNAL_DATASOURCE_DESCRIPTION
private static String __filename
private Map<String,DataSource> _sqlDataSources
private AbstractDataSourceManager.DataSourceDefinition _internalDataSource
private SQLDatabaseTypeExtensionPoint _sqlDatabaseTypeEP
private ServiceManager _manager
public SQLDataSourceManager()
public void service(ServiceManager serviceManager) throws ServiceException
service
in interface Serviceable
service
in class AbstractDataSourceManager
ServiceException
private SQLDatabaseTypeExtensionPoint getSQLDatabaseTypeEP()
public static void setFilename(String filename)
filename
- Name with path of the config filepublic static File getStaticFileConfiguration()
public File getFileConfiguration()
AbstractDataSourceManager
getFileConfiguration
in class AbstractDataSourceManager
public void initialize() throws Exception
initialize
in interface Initializable
initialize
in class AbstractDataSourceManager
Exception
public AbstractDataSourceManager.DataSourceDefinition getDataSourceDefinition(String id)
AbstractDataSourceManager
getDataSourceDefinition
in class AbstractDataSourceManager
id
- the id of data sourcepublic Map<String,AbstractDataSourceManager.DataSourceDefinition> getDataSourceDefinitions(boolean includePrivate, boolean includeInternal, boolean includeDefault)
AbstractDataSourceManager
getDataSourceDefinitions
in class AbstractDataSourceManager
includePrivate
- true to include private data sourcesincludeInternal
- true to include internal data sources. Not used by default.includeDefault
- true to include an additional data source definition for each default data sourceprotected String getDataSourcePrefixId()
AbstractDataSourceManager
getDataSourcePrefixId
in class AbstractDataSourceManager
public static AbstractDataSourceManager.DataSourceDefinition getInternalDataSourceDefinition()
public Connection getInternalSQLDataSourceConnection()
public Map<String,DataSource> getSQLDataSources()
public DataSource getSQLDataSource(String id)
id
- The id of data sourcepublic AbstractDataSourceManager.DataSourceDefinition setDefaultDataSource(String id)
AbstractDataSourceManager
setDefaultDataSource
in class AbstractDataSourceManager
id
- the id of the data sourceAbstractDataSourceManager.DataSourceDefinition
of the data source set as defaultpublic AbstractDataSourceManager.DataSourceDefinition getDefaultDataSourceDefinition()
AbstractDataSourceManager
getDefaultDataSourceDefinition
in class AbstractDataSourceManager
protected void internalSetDefaultDataSource()
AbstractDataSourceManager
internalSetDefaultDataSource
in class AbstractDataSourceManager
public void checkParameters(Map<String,String> rawParameters) throws ParameterCheckerTestFailureException
AbstractDataSourceManager
checkParameters
in class AbstractDataSourceManager
rawParameters
- the parameters of the data sourceParameterCheckerTestFailureException
- if the test failedprotected void editDataSource(AbstractDataSourceManager.DataSourceDefinition dataSource)
AbstractDataSourceManager
editDataSource
in class AbstractDataSourceManager
dataSource
- the data source configurationprotected void createDataSource(AbstractDataSourceManager.DataSourceDefinition dataSourceDef)
AbstractDataSourceManager
createDataSource
in class AbstractDataSourceManager
dataSourceDef
- the data source configurationprotected void deleteDataSource(AbstractDataSourceManager.DataSourceDefinition dataSource)
AbstractDataSourceManager
deleteDataSource
in class AbstractDataSourceManager
dataSource
- the data source configurationpublic void dispose()
dispose
in interface Disposable
private void _disposePool(String id)
id
- the id of the connection pool to dispose ofprivate void _closePool(String id)