Author: jacopoc
Date: Wed Sep 23 14:01:17 2009 New Revision: 818106 URL: http://svn.apache.org/viewvc?rev=818106&view=rev Log: New class to make it easier to test the usage of connections in the DBCP pool. Added: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/connection/DebugManagedDataSource.java (with props) Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/connection/DBCPConnectionFactory.java Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/connection/DBCPConnectionFactory.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/connection/DBCPConnectionFactory.java?rev=818106&r1=818105&r2=818106&view=diff ============================================================================== --- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/connection/DBCPConnectionFactory.java (original) +++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/connection/DBCPConnectionFactory.java Wed Sep 23 14:01:17 2009 @@ -151,6 +151,7 @@ pool.setFactory(factory); mds = new ManagedDataSource(pool, xacf.getTransactionRegistry()); + //mds = new DebugManagedDataSource(pool, xacf.getTransactionRegistry()); // Useful to debug the usage of connections in the pool mds.setAccessToUnderlyingConnectionAllowed(true); // cache the pool Added: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/connection/DebugManagedDataSource.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/connection/DebugManagedDataSource.java?rev=818106&view=auto ============================================================================== --- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/connection/DebugManagedDataSource.java (added) +++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/connection/DebugManagedDataSource.java Wed Sep 23 14:01:17 2009 @@ -0,0 +1,47 @@ +/******************************************************************************* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.ofbiz.entity.connection; + +import org.apache.commons.dbcp.managed.ManagedDataSource; +import org.apache.commons.dbcp.managed.TransactionRegistry; +import org.apache.commons.pool.ObjectPool; + +import org.ofbiz.base.util.Debug; + +import java.sql.Connection; +import java.sql.SQLException; + +public class DebugManagedDataSource extends ManagedDataSource { + + public static final String module = DebugManagedDataSource.class.getName(); + + public DebugManagedDataSource() { + super(); + } + public DebugManagedDataSource(ObjectPool pool, TransactionRegistry transactionRegistry) { + super(pool, transactionRegistry); + } + + @Override + public Connection getConnection() throws SQLException { + Debug.logInfo("Borrowing a connection from the pool; used/total: " + super._pool.getNumActive() + "/" + (super._pool.getNumActive() + super._pool.getNumIdle()), module); + return super.getConnection(); + } +} Propchange: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/connection/DebugManagedDataSource.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/connection/DebugManagedDataSource.java ------------------------------------------------------------------------------ svn:keywords = Date Rev Author URL Id Propchange: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/connection/DebugManagedDataSource.java ------------------------------------------------------------------------------ svn:mime-type = text/plain |
Free forum by Nabble | Edit this page |