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.kernel.dao.orm;
16  
17  import java.io.Serializable;
18  
19  /**
20   * <a href="EntityCacheUtil.java.html"><b><i>View Source</i></b></a>
21   *
22   * @author Brian Wing Shun Chan
23   */
24  public class EntityCacheUtil {
25  
26      public static void clearCache() {
27          getEntityCache().clearCache();
28      }
29  
30      public static void clearCache(String className) {
31          getEntityCache().clearCache(className);
32      }
33  
34      public static void clearLocalCache() {
35          getEntityCache().clearLocalCache();
36      }
37  
38      public static EntityCache getEntityCache() {
39          return _finderCache;
40      }
41  
42      public static Object getResult(
43          boolean entityCacheEnabled, Class<?> classObj,
44          Serializable primaryKeyObj, SessionFactory sessionFactory) {
45  
46          return getEntityCache().getResult(
47              entityCacheEnabled, classObj, primaryKeyObj, sessionFactory);
48      }
49  
50      public static void invalidate() {
51          getEntityCache().invalidate();
52      }
53  
54      public static Object loadResult(
55          boolean entityCacheEnabled, Class<?> classObj,
56          Serializable primaryKeyObj, SessionFactory sessionFactory) {
57  
58          return getEntityCache().loadResult(
59              entityCacheEnabled, classObj, primaryKeyObj, sessionFactory);
60      }
61  
62      public static void putResult(
63          boolean entityCacheEnabled, Class<?> classObj,
64          Serializable primaryKeyObj, Object result) {
65  
66          getEntityCache().putResult(
67              entityCacheEnabled, classObj, primaryKeyObj, result);
68      }
69  
70      public static void removeResult(
71          boolean entityCacheEnabled, Class<?> classObj,
72          Serializable primaryKeyObj) {
73  
74          getEntityCache().removeResult(
75              entityCacheEnabled, classObj, primaryKeyObj);
76      }
77  
78      public void setEntityCache(EntityCache finderCache) {
79          _finderCache = finderCache;
80      }
81  
82      private static EntityCache _finderCache;
83  
84  }