|
Keel 2.1RC2 | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectorg.apache.avalon.framework.logger.AbstractLogEnabled
org.apache.avalon.excalibur.datasource.ResourceLimitingJdbcDataSource
The ResourceLimiting implementation for DataSources in Avalon. This uses the normal java.sql.Connection object and java.sql.DriverManager.
This datasource pool implementation is designed to make as many database connections as are needed available without placing undo load on the database server.
If an application under normal load needs 3 database connections for example, then the max pool size should be set to a value like 10. This will allow the pool to grow to accomodate a sudden spike in load without allowing the pool to grow to such a large size as to place undo load on the database server. The pool's trimming features will keep track of how many connections are actually needed and close those connections which are no longer required.
Configuration Example:
<rl-jdbc>
<pool-controller max="10" max-strict="true"
blocking="true" timeout="-1"
trim-interval="60000" auto-commit="true"
connection-class="my.overrided.ConnectionClass">
<keep-alive disable="false" age="5000">select 1</keep-alive>
</pool-controller>
<driver>com.database.jdbc.JdbcDriver</driver>
<dburl>jdbc:driver://host/mydb</dburl>
<user>username</user>
<password>password</password>
</rl-jdbc>
Roles Example:
<role name="org.apache.avalon.excalibur.datasource.DataSourceComponentSelector"
shorthand="datasources"
default-class="org.apache.avalon.excalibur.component.ExcaliburComponentSelector">
<hint shorthand="rl-jdbc"
class="org.apache.avalon.excalibur.datasource.ResourceLimitingJdbcDataSource"/>
</role>
Configuration Attributes:
max attribute is used to set the maximum number of connections which will be opened. See the blocking attribute. (Defaults to "3")max-strict attribute is used to determine whether or not the maximum number of connections can be exceeded. If true, then an exception will be thrown if more than max connections are requested and blocking is false. (Defaults to "true")blocking attributes is used to specify the behavior of the DataSource pool when an attempt is made to allocate more than max concurrent connections. If true, the request will block until a connection is released, otherwise, a NoAvailableConnectionException will be thrown. Ignored if max-strict is false. (Defaults to "true")timeout attribute is used to specify the maximum amount of time in milliseconds that a request for a connection will be allowed to block before a NoAvailableConnectionException is thrown. A value of "0" specifies that the block will never timeout. (Defaults to "0")trim-interval attribute is used to specify how long idle connections will be maintained in the pool before being closed. For a complete explanation on how this works, see ResourceLimitingPool.trim() (Defaults to "60000", 1 minute)auto-commit attribute is used to determine the default auto-commit mode for the Connections returned by this DataSource.connection-class attribute is used to override the Connection class returned by the DataSource from calls to getConnection(). Set this to "org.apache.avalon.excalibur.datasource.Jdbc3Connection" to gain access to JDBC3 features. Jdbc3Connection does not exist if your JVM does not support JDBC3. (Defaults to "org.apache.avalon.excalibur.datasource.JdbcConnection")keep-alive element is used to override the query used to monitor the health of connections. If a connection has not been used for 5 seconds then before returning the connection from a call to getConnection(), the connection is first used to ping the database to make sure that it is still alive. Setting the disable attribute to true will disable this feature. Setting the age allows the 5 second age to be overridden. (Defaults to a query of "SELECT 1" and being enabled)driver element is used to specify the driver to use when connecting to the database. The specified class must be in the classpath. (Required)dburl element is the JDBC connection string which will be used to connect to the database. (Required)user and password attributes are used to specify the user and password for connections to the database. (Required)| Field Summary | |
private boolean |
m_configured |
private boolean |
m_disposed |
private java.lang.String |
m_instrumentableNameInstrumentable Name assigned to this Instrumentable |
protected InstrumentedResourceLimitingPool |
m_pool |
| Fields inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled |
|
| Fields inherited from interface org.apache.avalon.excalibur.datasource.DataSourceComponent |
ROLE |
| Fields inherited from interface org.apache.excalibur.instrument.Instrumentable |
EMPTY_INSTRUMENT_ARRAY, EMPTY_INSTRUMENTABLE_ARRAY |
| Constructor Summary | |
ResourceLimitingJdbcDataSource() |
|
| Method Summary | |
void |
configure(Configuration configuration)Pass the Configuration to the Configurable class. |
void |
dispose()The dispose operation is called at the end of a components lifecycle. |
Instrumentable[] |
getChildInstrumentables()Any Object which implements Instrumentable can also make use of other Instrumentable child objects. |
java.sql.Connection |
getConnection()Gets the Connection to the database |
java.lang.String |
getInstrumentableName()Gets the name of the Instrumentable. |
Instrument[] |
getInstruments()Obtain a reference to all the Instruments that the Instrumentable object wishes to expose. |
void |
setInstrumentableName(java.lang.String name)Sets the name for the Instrumentable. |
| Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled |
enableLogging, getLogger, setupLogger, setupLogger, setupLogger |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
private boolean m_configured
private boolean m_disposed
protected InstrumentedResourceLimitingPool m_pool
private java.lang.String m_instrumentableName
| Constructor Detail |
public ResourceLimitingJdbcDataSource()
| Method Detail |
public java.sql.Connection getConnection()
throws java.sql.SQLException
getConnection in interface DataSourceComponentNoValidConnectionException - when there is no valid Connection wrapper available in the classloader.NoAvailableConnectionException - when there are no more available Connections in the pool.java.sql.SQLException
public void configure(Configuration configuration)
throws ConfigurationException
Configuration to the Configurable class. This method must always be called after the constructor and before any other method.
configure in interface Configurableconfiguration - the class configurations.ConfigurationException - if an error occurspublic void setInstrumentableName(java.lang.String name)
This value may be set by a parent Instrumentable, or by the InstrumentManager using the value of the 'instrumentable' attribute in the configuration of the component.
setInstrumentableName in interface Instrumentablename - The name used to identify a Instrumentable.public java.lang.String getInstrumentableName()
getInstrumentableName in interface Instrumentablepublic Instrument[] getInstruments()
getInstruments in interface Instrumentablepublic Instrumentable[] getChildInstrumentables()
getChildInstrumentables in interface Instrumentablepublic void dispose()
dispose in interface Disposable
|
Keel 2.1RC2 | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||