1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * This library is free software; you can redistribute it and/or modify it under
5    * the terms of the GNU Lesser General Public License as published by the Free
6    * Software Foundation; either version 2.1 of the License, or (at your option)
7    * any later version.
8    *
9    * This library is distributed in the hope that it will be useful, but WITHOUT
10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   * details.
13   */
14  
15  package com.liferay.portal.dao.orm.hibernate;
16  
17  import com.liferay.portal.kernel.log.Log;
18  import com.liferay.portal.kernel.log.LogFactoryUtil;
19  
20  import java.util.Properties;
21  
22  import org.hibernate.cache.Cache;
23  import org.hibernate.cache.CacheException;
24  import org.hibernate.cache.CacheProvider;
25  
26  /**
27   * <a href="CacheProviderWrapper.java.html"><b><i>View Source</i></b></a>
28   *
29   * @author     Brian Wing Shun Chan
30   * @deprecated
31   */
32  public class CacheProviderWrapper implements CacheProvider {
33  
34      public CacheProviderWrapper(CacheProvider cacheProvider) {
35          this.cacheProvider = cacheProvider;
36      }
37  
38      public CacheProviderWrapper(String cacheProviderClassName) {
39          try {
40              cacheProvider = (CacheProvider)Class.forName(
41                  cacheProviderClassName).newInstance();
42          }
43          catch (Exception e) {
44              _log.error(e, e);
45          }
46      }
47  
48      public Cache buildCache(String regionName, Properties properties)
49          throws CacheException {
50  
51          return new CacheWrapper(
52              cacheProvider.buildCache(regionName, properties));
53      }
54  
55      public boolean isMinimalPutsEnabledByDefault() {
56          return cacheProvider.isMinimalPutsEnabledByDefault();
57      }
58  
59      public long nextTimestamp() {
60          return cacheProvider.nextTimestamp();
61      }
62  
63      public void start(Properties properties) throws CacheException {
64          cacheProvider.start(properties);
65      }
66  
67      public void stop() {
68          cacheProvider.stop();
69      }
70  
71      protected CacheProvider cacheProvider;
72  
73      private static Log _log = LogFactoryUtil.getLog(CacheProviderWrapper.class);
74  
75  }