001    /**
002     * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
013     */
014    
015    package com.liferay.portal.kernel.dao.orm;
016    
017    import com.liferay.portal.kernel.log.Log;
018    import com.liferay.portal.kernel.log.LogFactoryUtil;
019    
020    /**
021     * @author Brian Wing Shun Chan
022     */
023    public class FinderCacheUtil {
024    
025            public static void clearCache() {
026                    getFinderCache().clearCache();
027            }
028    
029            public static void clearCache(String className) {
030                    getFinderCache().clearCache(className);
031            }
032    
033            public static void clearLocalCache() {
034                    getFinderCache().clearLocalCache();
035            }
036    
037            public static FinderCache getFinderCache() {
038                    return _finderCache;
039            }
040    
041            /**
042             * @deprecated
043             */
044            public static Object getResult(
045                    String className, String methodName, String[] params, Object[] args,
046                    SessionFactory sessionFactory) {
047    
048                    _log.error(
049                            "Regenerate " + className +
050                                    " via \"ant build-service\" or else caching will not work");
051    
052                    return null;
053            }
054    
055            public static Object getResult(
056                    FinderPath finderPath, Object[] args, SessionFactory sessionFactory) {
057    
058                    return getFinderCache().getResult(finderPath, args, sessionFactory);
059            }
060    
061            public static void invalidate() {
062                    getFinderCache().invalidate();
063            }
064    
065            /**
066             * @deprecated
067             */
068            public static void putResult(
069                    boolean classNameCacheEnabled, String className, String methodName,
070                    String[] params, Object[] args, Object result) {
071    
072                    _log.error(
073                            "Regenerate " + className +
074                                    " via \"ant build-service\" or else caching will not work");
075            }
076    
077            public static void putResult(
078                    FinderPath finderPath, Object[] args, Object result) {
079    
080                    getFinderCache().putResult(finderPath, args, result);
081            }
082    
083            public static void removeCache(String className) {
084                    getFinderCache().removeCache(className);
085            }
086    
087            public static void removeResult(FinderPath finderPath, Object[] args) {
088                    getFinderCache().removeResult(finderPath, args);
089            }
090    
091            public void setFinderCache(FinderCache finderCache) {
092                    _finderCache = finderCache;
093            }
094    
095            private static Log _log = LogFactoryUtil.getLog(FinderCacheUtil.class);
096    
097            private static FinderCache _finderCache;
098    
099    }