|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.opensubsystems.core.persist.db.DatabaseConnectionFactoryImpl
org.opensubsystems.core.persist.db.connectionpool.PooledDatabaseConnectionFactoryImpl
public abstract class PooledDatabaseConnectionFactoryImpl
Base class for implementation of factories for retrieving and returning of database connections, which are maintained in a pool of always ready connections.
| Field Summary | |
|---|---|
static java.lang.String |
DEFAULT_DATASOURCE_NAME
Name that will be used for default datasource when the connection factory is started and no default datasource is defined. |
protected org.opensubsystems.core.persist.db.connectionpool.PooledDatabaseConnectionFactoryImpl.ConnectionPoolDefinition |
m_defaultConnectionPool
Default connection pool used for all connections. |
protected java.util.Map |
m_mpConnectionPoolCrossRef
Map used to cross reference connection to their pool so that we can correctly manage counts of requested connections per pool |
protected java.util.Map |
m_mpConnectionPools
Registered connection pools. |
protected java.util.Map |
m_mpNotPooledConnections
Map of not pooled connections which needs to be closed explicitely. |
| Constructor Summary | |
|---|---|
PooledDatabaseConnectionFactoryImpl()
Default constructor. |
|
PooledDatabaseConnectionFactoryImpl(DatabaseTransactionFactoryImpl transactionFactory)
Default constructor. |
|
PooledDatabaseConnectionFactoryImpl(java.lang.String strDriver,
java.lang.String strURL,
java.lang.String strUser,
java.lang.String strPassword,
DatabaseTransactionFactoryImpl transactionFactory)
Constructor with explicitely specified JDBC driver. |
|
| Method Summary | |
|---|---|
void |
addDataSource(java.lang.String strDataSourceName,
java.lang.String strDriverName,
java.lang.String strUrl,
java.lang.String strUser,
java.lang.String strPassword)
Create new data source. |
protected abstract void |
closeConnectionPool(org.opensubsystems.core.persist.db.connectionpool.PooledDatabaseConnectionFactoryImpl.ConnectionPoolDefinition connectionpool)
Close the specified connection pool and all connections maintained to database by this connection pool. |
protected abstract java.lang.Object |
createConnectionPool(java.lang.String strConnectionPoolName,
java.lang.String strDriverName,
java.lang.String strUrl,
java.lang.String strUser,
java.lang.String strPassword)
Create new connection pool with specified parameters. |
java.lang.String |
debug()
Create string representing state of the factory so we can user it to debug connection related problems. |
java.lang.String |
getDefaultDataSourceName()
Get the name of the default data source. |
protected abstract java.sql.Connection |
getPooledConnection(org.opensubsystems.core.persist.db.connectionpool.PooledDatabaseConnectionFactoryImpl.ConnectionPoolDefinition connectionpool)
Get connection for given connection pool. |
protected abstract java.sql.Connection |
getPooledConnection(org.opensubsystems.core.persist.db.connectionpool.PooledDatabaseConnectionFactoryImpl.ConnectionPoolDefinition connectionpool,
java.lang.String strUser,
java.lang.String strPassword)
Get connection using the same settings as given connection pool but get the connection under different name and password. |
int |
getRequestedConnectionCount()
Get number for connections which are currently requested and were not returned for default data source. |
int |
getRequestedConnectionCount(java.lang.String strDataSourceName)
Get number for connections which are currently requested and were not returned. |
boolean |
isDataSourceDefined(java.lang.String strDataSourceName)
Check if the specified data has been already defined |
protected java.sql.Connection |
requestNonTransactionalConnection(boolean bAutoCommit)
This method is a delegation method for now final org.opensubsystems.core.persist.db.DatabaseConnectionFactory#requestConnection() to get connection which is not tied to the transactional manager. |
protected java.sql.Connection |
requestNonTransactionalConnection(boolean bAutoCommit,
java.lang.String strDataSourceName)
This method is a delegation method for now final org.opensubsystems.core.persist.db.DatabaseConnectionFactory #requestConnection(String) to get connection which is not tied to the transactional manager. |
protected java.sql.Connection |
requestNonTransactionalConnection(boolean bAutoCommit,
java.lang.String strUser,
java.lang.String strPassword)
This method is a delegation method for now final org.opensubsystems.core.persist.db.DatabaseConnectionFactory #requestConnection(String, String) to get connection which is not tied to the transactional manager. |
protected java.sql.Connection |
requestNonTransactionalConnection(boolean bAutoCommit,
java.lang.String strDataSourceName,
java.lang.String strUser,
java.lang.String strPassword)
This method is a delegation method for now final org.opensubsystems.core.persist.db.DatabaseConnectionFactory #requestConnection(String, String, String) to get connection which is not tied to the transactional manager. |
void |
returnNonTransactionalConnection(java.sql.Connection cntDBConnection)
This method is a delegation method for now final org.opensubsystems.core.persist.db.DatabaseConnectionFactory #returnConnection(java.sql.Connection) to return connection which is not tied to the transactional manager. |
protected void |
returnPooledConnection(java.sql.Connection cntDBConnection)
Return connection which was taken from the pool. |
void |
setDefaultDataSourceName(java.lang.String strDataSourceName)
Set the default data source. |
protected void |
start()
Start the connection factory. |
void |
stop()
Stop the connection factory. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final java.lang.String DEFAULT_DATASOURCE_NAME
protected org.opensubsystems.core.persist.db.connectionpool.PooledDatabaseConnectionFactoryImpl.ConnectionPoolDefinition m_defaultConnectionPool
protected java.util.Map m_mpConnectionPools
protected java.util.Map m_mpNotPooledConnections
protected java.util.Map m_mpConnectionPoolCrossRef
| Constructor Detail |
|---|
public PooledDatabaseConnectionFactoryImpl()
public PooledDatabaseConnectionFactoryImpl(DatabaseTransactionFactoryImpl transactionFactory)
transactionFactory - - transaction factory to use for this
connection factory, can be null
public PooledDatabaseConnectionFactoryImpl(java.lang.String strDriver,
java.lang.String strURL,
java.lang.String strUser,
java.lang.String strPassword,
DatabaseTransactionFactoryImpl transactionFactory)
throws OSSConfigException,
OSSDatabaseAccessException
strDriver - - JDBC driver to connect to the databasestrURL - - URL of database to connect tostrUser - - user name to connect to the databasestrPassword - - password to the databasetransactionFactory - - transaction factory to use for this
connection factory, can be null
OSSConfigException - - problem accessing or locating the config file.
OSSDatabaseAccessException - - an error has occured accessing
the database| Method Detail |
|---|
public final java.lang.String getDefaultDataSourceName()
public final void addDataSource(java.lang.String strDataSourceName,
java.lang.String strDriverName,
java.lang.String strUrl,
java.lang.String strUser,
java.lang.String strPassword)
throws OSSDatabaseAccessException
strDataSourceName - - data source namestrDriverName - - name of the JDBC driverstrUrl - - url by which data source connects to the databasestrUser - - user name to connects to the databasestrPassword - - password to connects to the database
OSSDatabaseAccessException - - data source with the same name already
existspublic final void setDefaultDataSourceName(java.lang.String strDataSourceName)
strDataSourceName - - data source which will be used to get connectionspublic boolean isDataSourceDefined(java.lang.String strDataSourceName)
strDataSourceName - - name of the data source to check for
public final void stop()
throws OSSException
OSSException - - problem stopping connection factory.public int getRequestedConnectionCount()
public int getRequestedConnectionCount(java.lang.String strDataSourceName)
strDataSourceName - - data source which will be used to get connections
public java.lang.String debug()
protected java.sql.Connection requestNonTransactionalConnection(boolean bAutoCommit)
throws OSSDatabaseAccessException
requestNonTransactionalConnection in class DatabaseConnectionFactoryImplbAutoCommit - - The desired autocommit state of the connection. If
this connection is invoked in global (JTA) transaction
then the autocommit is false regardless of what
value is specified here. Use true here if the client
only reads the data and false if the client also
modifies the data.
Use DatabaseTransactionFactory.commitTransaction
to commit the transaction.
OSSDatabaseAccessException - - if connection cannot be establishedDatabaseConnectionFactoryImpl.returnConnection(java.sql.Connection)
protected final java.sql.Connection requestNonTransactionalConnection(boolean bAutoCommit,
java.lang.String strUser,
java.lang.String strPassword)
throws OSSDatabaseAccessException
requestNonTransactionalConnection in class DatabaseConnectionFactoryImplbAutoCommit - - The desired autocommit state of the connection. If
this connection is invoked in global (JTA) transaction
then the autocommit is false regardless of what
value is specified here. Use true here if the client
only reads the data and false if the client also
modifies the data.
Use DatabaseTransactionFactory.commitTransaction
to commit the transaction.strUser - - user name to connect to the databasestrPassword - - password to the database
OSSDatabaseAccessException - - if connection cannot be establishedDatabaseConnectionFactoryImpl.returnConnection(java.sql.Connection)
protected final java.sql.Connection requestNonTransactionalConnection(boolean bAutoCommit,
java.lang.String strDataSourceName)
throws OSSDatabaseAccessException
requestNonTransactionalConnection in class DatabaseConnectionFactoryImplbAutoCommit - - The desired autocommit state of the connection. If
this connection is invoked in global (JTA) transaction
then the autocommit is false regardless of what
value is specified here. Use true here if the client
only reads the data and false if the client also
modifies the data.
Use DatabaseTransactionFactory.commitTransaction
to commit the transaction.strDataSourceName - - data source which will be used to get connections
OSSDatabaseAccessException - - if connection cannot be establishedDatabaseConnectionFactoryImpl.returnConnection(java.sql.Connection)
protected final java.sql.Connection requestNonTransactionalConnection(boolean bAutoCommit,
java.lang.String strDataSourceName,
java.lang.String strUser,
java.lang.String strPassword)
throws OSSDatabaseAccessException
requestNonTransactionalConnection in class DatabaseConnectionFactoryImplbAutoCommit - - The desired autocommit state of the connection. If
this connection is invoked in global (JTA) transaction
then the autocommit is false regardless of what
value is specified here. Use true here if the client
only reads the data and false if the client also
modifies the data.
Use DatabaseTransactionFactory.commitTransaction
to commit the transaction.strDataSourceName - - data source which will be used to get connectionsstrUser - - user name to connect to the databasestrPassword - - password to the database
OSSDatabaseAccessException - - if connection cannot be establishedDatabaseConnectionFactoryImpl.returnConnection(java.sql.Connection)public final void returnNonTransactionalConnection(java.sql.Connection cntDBConnection)
returnNonTransactionalConnection in class DatabaseConnectionFactoryImplcntDBConnection - - connection to return, can be null
protected void start()
throws OSSDatabaseAccessException
OSSDatabaseAccessException - - an error has occured
protected abstract java.sql.Connection getPooledConnection(org.opensubsystems.core.persist.db.connectionpool.PooledDatabaseConnectionFactoryImpl.ConnectionPoolDefinition connectionpool)
throws OSSDatabaseAccessException
connectionpool - - connection pool to get connection for
OSSDatabaseAccessException - - an error getting connection
protected abstract java.sql.Connection getPooledConnection(org.opensubsystems.core.persist.db.connectionpool.PooledDatabaseConnectionFactoryImpl.ConnectionPoolDefinition connectionpool,
java.lang.String strUser,
java.lang.String strPassword)
throws OSSDatabaseAccessException
connectionpool - - connection pool defining settings to get connection forstrUser - - user name to get the connection forstrPassword - - password to get the connection for
OSSDatabaseAccessException - - an error getting connectionprotected void returnPooledConnection(java.sql.Connection cntDBConnection)
cntDBConnection - - connection taked from the pool
protected abstract java.lang.Object createConnectionPool(java.lang.String strConnectionPoolName,
java.lang.String strDriverName,
java.lang.String strUrl,
java.lang.String strUser,
java.lang.String strPassword)
throws OSSException
strConnectionPoolName - - connection pool namestrDriverName - - name of the JDBC driverstrUrl - - url by which data source connects to the databasestrUser - - user name to connects to the databasestrPassword - - password to connects to the database
OSSException - - an error has occured during creation of connection pool
protected abstract void closeConnectionPool(org.opensubsystems.core.persist.db.connectionpool.PooledDatabaseConnectionFactoryImpl.ConnectionPoolDefinition connectionpool)
throws OSSException
connectionpool - - connection pool to close.
OSSException - - an error has occured during closing of the connection pool
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||