public class DatabaseManager extends AbstractInitializableServerObject<ServerContext> implements CloseableComponent, PermissionControlled
Constructor and Description |
---|
DatabaseManager(ServerContext serverCtx) |
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes and removes all DataSources in the pool
|
boolean |
close(java.lang.String dataSourceName)
Closes and removes the given DataSource by name
|
int |
connect()
Reads the srv_datasource.cfg file and fills the pool with according connected DataSource Objects.
|
DatabaseConnection |
findDataSourceEntry(java.lang.String dsName)
Finds the DatabaseConnection by name
|
java.sql.Connection |
getCurrentConnection()
Returns a connection of the currently selected connection pool.
|
DatabaseConnection |
getCurrentDataSource() |
DBConnectionPool |
getDataSource(java.lang.String dataSourceName)
Returns the corresponding DBConnectionPool or null if not found
|
DatabaseConnection[] |
getDataSourceEntries()
Returns the list of currently configured DataSourceEntries
|
DBConnectionPool[] |
getDataSources() |
java.util.List<ServerCredential> |
getDefinedCredentials() |
PermissionDefinition |
getPermissionDefinition()
Returns an object that identifies a
PermissionControlled object with a unique name
and provides a list of supported assignable permissions. |
int |
getSize()
Returns the number of configured DataSources
|
boolean |
hasDefinedCredentials() |
void |
init()
Performs the initialization of this class.
|
ResourceLock |
lockExclusive(SessionId sessId) |
ResourceLock |
lockShared(SessionId sessId) |
void |
releaseLock(SessionId sessId,
ResourceLock lock) |
DatabaseConnection |
resetToDefaultDataSource(SessionId sessId)
Resets to the default DataSource which is the first one configured in the config file.
|
DatabaseConnection |
resetToPreviousDataSource(SessionId sessId)
Resets to the previously selected DataSource.
|
DatabaseConnection |
selectDataSource(SessionId sessId,
java.lang.String dataSourceName)
Selects the DataSource by name.
|
checkInitialized, isInitialized, setInitialized, toString
checkPermission, getServerConfig, getServerContext, getStatisticManager
getApplicationContext, getLogChannel, isLogDebug, isLogVerbose, logDebug, logDump, logError, logError, logFatal, logInfo, logVerbose, logWarning, setLogChannel
configureDumpHeadlineLength, configureDumpMaxElementsPrinted, copyDumpStringValues, copyToStringValues, createDumpHeader, toDumpString, toDumpString, toString
public DatabaseManager(ServerContext serverCtx)
public void init() throws java.lang.Exception
Initializable
init
in interface Initializable
java.lang.Exception
public PermissionDefinition getPermissionDefinition()
PermissionControlled
PermissionControlled
object with a unique name
and provides a list of supported assignable permissions.getPermissionDefinition
in interface PermissionControlled
public java.util.List<ServerCredential> getDefinedCredentials()
public boolean hasDefinedCredentials()
public DatabaseConnection findDataSourceEntry(java.lang.String dsName)
public ResourceLock lockShared(SessionId sessId) throws java.lang.Exception
java.lang.Exception
public ResourceLock lockExclusive(SessionId sessId) throws java.lang.Exception
java.lang.Exception
public void releaseLock(SessionId sessId, ResourceLock lock) throws NotLockOwnerException
NotLockOwnerException
public int connect() throws java.lang.Exception
java.lang.Exception
public int getSize()
public void close()
close
in interface java.lang.AutoCloseable
public boolean close(java.lang.String dataSourceName)
public DatabaseConnection[] getDataSourceEntries()
public DBConnectionPool[] getDataSources()
public DBConnectionPool getDataSource(java.lang.String dataSourceName) throws InvalidDataSourceException
InvalidDataSourceException
public DatabaseConnection selectDataSource(SessionId sessId, java.lang.String dataSourceName) throws InvalidDataSourceException, ResourceLockedException, PermissionException
InvalidDataSourceException
- if the data source name does not existResourceLockedException
PermissionException
public DatabaseConnection getCurrentDataSource()
public java.sql.Connection getCurrentConnection()
public DatabaseConnection resetToDefaultDataSource(SessionId sessId) throws InvalidDataSourceException, ResourceLockedException, PermissionException
InvalidDataSourceException
ResourceLockedException
PermissionException
public DatabaseConnection resetToPreviousDataSource(SessionId sessId) throws InvalidDataSourceException, ResourceLockedException, PermissionException
InvalidDataSourceException
ResourceLockedException
PermissionException
Copyright © 2014 EsprIT-Systems. All Rights Reserved.