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.kernel.dao.orm;
16  
17  import com.liferay.portal.kernel.log.Log;
18  import com.liferay.portal.kernel.log.LogFactoryUtil;
19  
20  /**
21   * <a href="FinderCacheUtil.java.html"><b><i>View Source</i></b></a>
22   *
23   * @author Brian Wing Shun Chan
24   */
25  public class FinderCacheUtil {
26  
27      public static void clearCache() {
28          getFinderCache().clearCache();
29      }
30  
31      public static void clearCache(String className) {
32          getFinderCache().clearCache(className);
33      }
34  
35      public static void clearLocalCache() {
36          getFinderCache().clearLocalCache();
37      }
38  
39      public static FinderCache getFinderCache() {
40          return _finderCache;
41      }
42  
43      /**
44       * @deprecated
45       */
46      public static Object getResult(
47          String className, String methodName, String[] params, Object[] args,
48          SessionFactory sessionFactory) {
49  
50          _log.error(
51              "Regenerate " + className +
52                  " via \"ant build-service\" or else caching will not work");
53  
54          return null;
55      }
56  
57      public static Object getResult(
58          FinderPath finderPath, Object[] args, SessionFactory sessionFactory) {
59  
60          return getFinderCache().getResult(finderPath, args, sessionFactory);
61      }
62  
63      public static void invalidate() {
64          getFinderCache().invalidate();
65      }
66  
67      /**
68       * @deprecated
69       */
70      public static void putResult(
71          boolean classNameCacheEnabled, String className, String methodName,
72          String[] params, Object[] args, Object result) {
73  
74          _log.error(
75              "Regenerate " + className +
76                  " via \"ant build-service\" or else caching will not work");
77      }
78  
79      public static void putResult(
80          FinderPath finderPath, Object[] args, Object result) {
81  
82          getFinderCache().putResult(finderPath, args, result);
83      }
84  
85      public static void removeCache(String className) {
86          getFinderCache().removeCache(className);
87      }
88  
89      public static void removeResult(FinderPath finderPath, Object[] args) {
90          getFinderCache().removeResult(finderPath, args);
91      }
92  
93      public void setFinderCache(FinderCache finderCache) {
94          _finderCache = finderCache;
95      }
96  
97      private static Log _log = LogFactoryUtil.getLog(FinderCacheUtil.class);
98  
99      private static FinderCache _finderCache;
100 
101 }