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