1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * The contents of this file are subject to the terms of the Liferay Enterprise
5    * Subscription License ("License"). You may not use this file except in
6    * compliance with the License. You can obtain a copy of the License by
7    * contacting Liferay, Inc. See the License for the specific language governing
8    * permissions and limitations under the License, including but not limited to
9    * distribution rights of the Software.
10   *
11   *
12   *
13   */
14  
15  package com.liferay.portal.dao.jdbc.pool.c3p0;
16  
17  import com.liferay.portal.kernel.log.Log;
18  import com.liferay.portal.kernel.log.LogFactoryUtil;
19  import com.liferay.portal.kernel.util.GetterUtil;
20  import com.liferay.portal.util.PropsUtil;
21  
22  import com.mchange.v2.c3p0.ConnectionCustomizer;
23  
24  import java.sql.Connection;
25  
26  /**
27   * <a href="PortalConnectionCustomizer.java.html"><b><i>View Source</i></b></a>
28   *
29   * @author Brian Wing Shun Chan
30   */
31  public class PortalConnectionCustomizer implements ConnectionCustomizer {
32  
33      public void onAcquire(
34              Connection connection, String parentDataSourceIdentityToken)
35          throws Exception {
36  
37          if (_log.isDebugEnabled()) {
38              _log.debug("JDBC property prefix " + parentDataSourceIdentityToken);
39          }
40  
41          String transactionIsolation = PropsUtil.get(
42              parentDataSourceIdentityToken + "transactionIsolation");
43  
44          if (_log.isDebugEnabled()) {
45              _log.debug("Custom transaction isolation " + transactionIsolation);
46          }
47  
48          if (transactionIsolation != null) {
49              connection.setTransactionIsolation(
50                  GetterUtil.getInteger(transactionIsolation));
51          }
52      }
53  
54      public void onCheckIn(
55          Connection connection, String parentDataSourceIdentityToken) {
56      }
57  
58      public void onCheckOut(
59          Connection connection, String parentDataSourceIdentityToken) {
60      }
61  
62      public void onDestroy(
63          Connection connection, String parentDataSourceIdentityToken) {
64      }
65  
66      private static Log _log = LogFactoryUtil.getLog(
67          PortalConnectionCustomizer.class);
68  
69  }