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, toStringcheckPermission, getServerConfig, getServerContext, getStatisticManagergetApplicationContext, getLogChannel, isLogDebug, isLogVerbose, logDebug, logDump, logError, logError, logFatal, logInfo, logVerbose, logWarning, setLogChannelconfigureDumpHeadlineLength, configureDumpMaxElementsPrinted, copyDumpStringValues, copyToStringValues, createDumpHeader, toDumpString, toDumpString, toStringpublic DatabaseManager(ServerContext serverCtx)
public void init()
throws java.lang.Exception
Initializableinit in interface Initializablejava.lang.Exceptionpublic PermissionDefinition getPermissionDefinition()
PermissionControlledPermissionControlled object with a unique name
and provides a list of supported assignable permissions.getPermissionDefinition in interface PermissionControlledpublic 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.Exceptionpublic ResourceLock lockExclusive(SessionId sessId) throws java.lang.Exception
java.lang.Exceptionpublic void releaseLock(SessionId sessId, ResourceLock lock) throws NotLockOwnerException
NotLockOwnerExceptionpublic int connect()
throws java.lang.Exception
java.lang.Exceptionpublic int getSize()
public void close()
close in interface java.lang.AutoCloseablepublic boolean close(java.lang.String dataSourceName)
public DatabaseConnection[] getDataSourceEntries()
public DBConnectionPool[] getDataSources()
public DBConnectionPool getDataSource(java.lang.String dataSourceName) throws InvalidDataSourceException
InvalidDataSourceExceptionpublic DatabaseConnection selectDataSource(SessionId sessId, java.lang.String dataSourceName) throws InvalidDataSourceException, ResourceLockedException, PermissionException
InvalidDataSourceException - if the data source name does not existResourceLockedExceptionPermissionExceptionpublic DatabaseConnection getCurrentDataSource()
public java.sql.Connection getCurrentConnection()
public DatabaseConnection resetToDefaultDataSource(SessionId sessId) throws InvalidDataSourceException, ResourceLockedException, PermissionException
InvalidDataSourceExceptionResourceLockedExceptionPermissionExceptionpublic DatabaseConnection resetToPreviousDataSource(SessionId sessId) throws InvalidDataSourceException, ResourceLockedException, PermissionException
InvalidDataSourceExceptionResourceLockedExceptionPermissionExceptionCopyright © 2014 EsprIT-Systems. All Rights Reserved.