1   /**
2    * Copyright (c) 2000-2009 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   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
12   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
13   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
14   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
15   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
16   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
17   * SOFTWARE.
18   */
19  
20  package com.liferay.portal.kernel.dao.orm;
21  
22  import com.liferay.portal.kernel.log.Log;
23  import com.liferay.portal.kernel.log.LogFactoryUtil;
24  
25  /**
26   * <a href="FinderCacheUtil.java.html"><b><i>View Source</i></b></a>
27   *
28   * @author Brian Wing Shun Chan
29   *
30   */
31  public class FinderCacheUtil {
32  
33      public static void clearCache() {
34          getFinderCache().clearCache();
35      }
36  
37      public static void clearCache(String className) {
38          getFinderCache().clearCache(className);
39      }
40  
41      public static void clearLocalCache() {
42          getFinderCache().clearLocalCache();
43      }
44  
45      public static FinderCache getFinderCache() {
46          return _finderCache;
47      }
48  
49      /**
50       * @deprecated
51       */
52      public static Object getResult(
53          String className, String methodName, String[] params, Object[] args,
54          SessionFactory sessionFactory) {
55  
56          _log.error(
57              "Regenerate " + className +
58                  " via \"ant build-service\" or else caching will not work");
59  
60          return null;
61      }
62  
63      public static Object getResult(
64          FinderPath finderPath, Object[] args, SessionFactory sessionFactory) {
65  
66          return getFinderCache().getResult(finderPath, args, sessionFactory);
67      }
68  
69      public static void invalidate() {
70          getFinderCache().invalidate();
71      }
72  
73      /**
74       * @deprecated
75       */
76      public static void putResult(
77          boolean classNameCacheEnabled, String className, String methodName,
78          String[] params, Object[] args, Object result) {
79  
80          _log.error(
81              "Regenerate " + className +
82                  " via \"ant build-service\" or else caching will not work");
83      }
84  
85      public static void putResult(
86          FinderPath finderPath, Object[] args, Object result) {
87  
88          getFinderCache().putResult(finderPath, args, result);
89      }
90  
91      public static void removeResult(FinderPath finderPath, Object[] args) {
92          getFinderCache().removeResult(finderPath, args);
93      }
94  
95      public static void setLocalCacheEnabled(boolean localCacheEnabled) {
96          getFinderCache().setLocalCacheEnabled(localCacheEnabled);
97      }
98  
99      public void setFinderCache(FinderCache finderCache) {
100         _finderCache = finderCache;
101     }
102 
103     private static Log _log = LogFactoryUtil.getLog(FinderCacheUtil.class);
104 
105     private static FinderCache _finderCache;
106 
107 }