excalibur-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From l...@apache.org
Subject svn commit: r330745 - in /excalibur/trunk/components/datasource: ./ src/java/org/apache/avalon/excalibur/datasource/
Date Fri, 04 Nov 2005 08:15:39 GMT
Author: leif
Date: Fri Nov  4 00:15:34 2005
New Revision: 330745

URL: http://svn.apache.org/viewcvs?rev=330745&view=rev
Log:
Make it possible to trace who checked out outstanding pool elements.

Added:
    excalibur/trunk/components/datasource/src/java/org/apache/avalon/excalibur/datasource/TraceableDataSourceComponent.java
Modified:
    excalibur/trunk/components/datasource/project.xml
    excalibur/trunk/components/datasource/src/java/org/apache/avalon/excalibur/datasource/ResourceLimitingJdbcConnectionPool.java
    excalibur/trunk/components/datasource/src/java/org/apache/avalon/excalibur/datasource/ResourceLimitingJdbcDataSource.java

Modified: excalibur/trunk/components/datasource/project.xml
URL: http://svn.apache.org/viewcvs/excalibur/trunk/components/datasource/project.xml?rev=330745&r1=330744&r2=330745&view=diff
==============================================================================
--- excalibur/trunk/components/datasource/project.xml (original)
+++ excalibur/trunk/components/datasource/project.xml Fri Nov  4 00:15:34 2005
@@ -16,6 +16,8 @@
  limitations under the License.
 -->
 <project>
+    <currentVersion>2.2-dev</currentVersion>
+
     <extend>${basedir}/../project-common.xml</extend>
 
     <name>Excalibur Datasource</name>
@@ -86,7 +88,7 @@
         <dependency>
             <groupId>excalibur-pool</groupId>
             <artifactId>excalibur-pool-instrumented</artifactId>
-            <version>2.1</version>
+            <version>2.2-dev</version>
         </dependency>
         <dependency>
             <id>commons-collections</id>

Modified: excalibur/trunk/components/datasource/src/java/org/apache/avalon/excalibur/datasource/ResourceLimitingJdbcConnectionPool.java
URL: http://svn.apache.org/viewcvs/excalibur/trunk/components/datasource/src/java/org/apache/avalon/excalibur/datasource/ResourceLimitingJdbcConnectionPool.java?rev=330745&r1=330744&r2=330745&view=diff
==============================================================================
--- excalibur/trunk/components/datasource/src/java/org/apache/avalon/excalibur/datasource/ResourceLimitingJdbcConnectionPool.java
(original)
+++ excalibur/trunk/components/datasource/src/java/org/apache/avalon/excalibur/datasource/ResourceLimitingJdbcConnectionPool.java
Fri Nov  4 00:15:34 2005
@@ -60,6 +60,7 @@
      *  block before an exception is thrown.  A value of 0 implies an indefinate wait.
      * @param trimInterval The minimum interval with which old unused connections will be
removed
      *  from the pool.  A value of 0 will cause the pool to never trim old connections.
+     * @param trace True if tracing of gets is enabled for the pool.
      * @param autoCommit true if connections created by this pool should have autoCommit
enabled.
      */
     public ResourceLimitingJdbcConnectionPool( final ObjectFactory factory,
@@ -68,12 +69,43 @@
                                                boolean blocking,
                                                long blockTimeout,
                                                long trimInterval,
+                                               boolean trace,
                                                boolean autoCommit )
     {
 
-        super( factory, max, maxStrict, blocking, blockTimeout, trimInterval );
+        super( factory, max, maxStrict, blocking, blockTimeout, trimInterval, trace );
 
         m_autoCommit = autoCommit;
+    }
+
+    /**
+     * Creates a new ResourceLimitingJdbcConnectionPool
+     *
+     * @param factory The ObjectFactory which will be used to create new connections as needed
+     *  by the pool.
+     * @param max Maximum number of connections which can be stored in the pool, 0 implies
+     *  no limit.
+     * @param maxStrict true if the pool should never allow more than max connections to
be
+     *  created.  Will cause an exception to be thrown if more than max connections are
+     *  requested and blocking is false.
+     * @param blocking true if the pool should cause a thread calling get() to block when
+     *  connections are not currently available in the pool.
+     * @param blockTimeout The maximum amount of time, in milliseconds, that a call to get()
will
+     *  block before an exception is thrown.  A value of 0 implies an indefinate wait.
+     * @param trimInterval The minimum interval with which old unused connections will be
removed
+     *  from the pool.  A value of 0 will cause the pool to never trim old connections.
+     * @param autoCommit true if connections created by this pool should have autoCommit
enabled.
+     */
+    public ResourceLimitingJdbcConnectionPool( final ObjectFactory factory,
+                                               int max,
+                                               boolean maxStrict,
+                                               boolean blocking,
+                                               long blockTimeout,
+                                               long trimInterval,
+                                               boolean autoCommit )
+    {
+
+        this( factory, max, maxStrict, blocking, blockTimeout, trimInterval, false, autoCommit
);
     }
 
     /*---------------------------------------------------------------

Modified: excalibur/trunk/components/datasource/src/java/org/apache/avalon/excalibur/datasource/ResourceLimitingJdbcDataSource.java
URL: http://svn.apache.org/viewcvs/excalibur/trunk/components/datasource/src/java/org/apache/avalon/excalibur/datasource/ResourceLimitingJdbcDataSource.java?rev=330745&r1=330744&r2=330745&view=diff
==============================================================================
--- excalibur/trunk/components/datasource/src/java/org/apache/avalon/excalibur/datasource/ResourceLimitingJdbcDataSource.java
(original)
+++ excalibur/trunk/components/datasource/src/java/org/apache/avalon/excalibur/datasource/ResourceLimitingJdbcDataSource.java
Fri Nov  4 00:15:34 2005
@@ -26,7 +26,7 @@
 
 import org.apache.excalibur.instrument.AbstractLogEnabledInstrumentable;
 
-import org.apache.avalon.excalibur.pool.InstrumentedResourceLimitingPool;
+import org.apache.avalon.excalibur.pool.TraceableResourceLimitingPool;
 
 /**
  * The ResourceLimiting implementation for DataSources in Avalon.
@@ -142,6 +142,7 @@
  * 
  * @avalon.component
  * @avalon.service type=DataSourceComponent
+ * @avalon.service type=TraceableDataSourceComponent
  * @x-avalon.info name=rl-jdbc
  * @x-avalon.lifestyle type=singleton
  *
@@ -151,11 +152,11 @@
  */
 public class ResourceLimitingJdbcDataSource
     extends AbstractLogEnabledInstrumentable
-    implements DataSourceComponent, Disposable
+    implements TraceableDataSourceComponent, Disposable
 {
     private boolean m_configured;
     private boolean m_disposed;
-    protected InstrumentedResourceLimitingPool m_pool;
+    protected TraceableResourceLimitingPool m_pool;
 
     /*---------------------------------------------------------------
      * Constructors
@@ -213,6 +214,16 @@
         return (Connection)connection;
     }
 
+    /**
+     * Returns a snapshot of the current state of the pool.
+     *
+     * @return A snapshot of the current pool state.
+     */
+    public TraceableResourceLimitingPool.State getState()
+    {
+        return m_pool.getState();
+    }
+
     /*---------------------------------------------------------------
      * DataSourceComponent (Configurable) Methods
      *-------------------------------------------------------------*/
@@ -243,6 +254,7 @@
         final boolean blocking = controller.getAttributeAsBoolean( "blocking", true );
         final long timeout = controller.getAttributeAsLong( "timeout", 0 );
         final long trimInterval = controller.getAttributeAsLong( "trim-interval", 60000 );
+        final boolean trace = controller.getAttributeAsBoolean( "trace", false );
         final boolean oradb = controller.getAttributeAsBoolean( "oradb", false );
 
         final boolean autoCommit = configuration.getChild( "auto-commit" ).getValueAsBoolean(
true );
@@ -316,7 +328,7 @@
         try
         {
             m_pool = new ResourceLimitingJdbcConnectionPool(
-                factory, l_max, maxStrict, blocking, timeout, trimInterval, autoCommit );
+                factory, l_max, maxStrict, blocking, timeout, trimInterval, trace, autoCommit
);
 
             m_pool.enableLogging( getLogger() );
             

Added: excalibur/trunk/components/datasource/src/java/org/apache/avalon/excalibur/datasource/TraceableDataSourceComponent.java
URL: http://svn.apache.org/viewcvs/excalibur/trunk/components/datasource/src/java/org/apache/avalon/excalibur/datasource/TraceableDataSourceComponent.java?rev=330745&view=auto
==============================================================================
--- excalibur/trunk/components/datasource/src/java/org/apache/avalon/excalibur/datasource/TraceableDataSourceComponent.java
(added)
+++ excalibur/trunk/components/datasource/src/java/org/apache/avalon/excalibur/datasource/TraceableDataSourceComponent.java
Fri Nov  4 00:15:34 2005
@@ -0,0 +1,51 @@
+/* 
+ * Copyright 2002-2004 The Apache Software Foundation
+ * Licensed  under the  Apache License,  Version 2.0  (the "License");
+ * you may not use  this file  except in  compliance with the License.
+ * You may obtain a copy of the License at 
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed  under the  License is distributed on an "AS IS" BASIS,
+ * WITHOUT  WARRANTIES OR CONDITIONS  OF ANY KIND, either  express  or
+ * implied.
+ * 
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.avalon.excalibur.datasource;
+
+import java.sql.Connection;
+import java.sql.SQLException;
+
+import org.apache.avalon.excalibur.pool.TraceableResourceLimitingPool;
+
+import org.apache.avalon.framework.component.Component;
+import org.apache.avalon.framework.configuration.Configurable;
+import org.apache.avalon.framework.thread.ThreadSafe;
+
+/**
+ * The standard interface for DataSources in Avalon.
+ *
+ * @author <a href="mailto:dev@avalon.apache.org">Avalon Development Team</a>
+ * @version CVS $Revision: 1.4 $ $Date: 2004/02/28 11:47:14 $
+ * @since 4.0
+ */
+public interface TraceableDataSourceComponent
+    extends DataSourceComponent
+{
+    /**
+     * The name of the role for convenience
+     */
+    String ROLE = TraceableDataSourceComponent.class.getName();
+
+    /**
+     * Returns a snapshot of the current state of the pool.
+     *
+     * @return A snapshot of the current pool state.
+     */
+    TraceableResourceLimitingPool.State getState();
+}
+



---------------------------------------------------------------------
To unsubscribe, e-mail: scm-unsubscribe@excalibur.apache.org
For additional commands, e-mail: scm-help@excalibur.apache.org


Mime
View raw message