001    /**
002     * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portal.kernel.dao.orm;
016    
017    import com.liferay.portal.kernel.model.BaseModel;
018    import com.liferay.portal.kernel.security.pacl.permission.PortalRuntimePermission;
019    import com.liferay.portal.kernel.service.persistence.impl.BasePersistenceImpl;
020    import com.liferay.portal.kernel.util.ProxyFactory;
021    
022    /**
023     * @author Brian Wing Shun Chan
024     */
025    public class FinderCacheUtil {
026    
027            public static void clearCache() {
028                    _finderCache.clearCache();
029            }
030    
031            public static void clearCache(String className) {
032                    _finderCache.clearCache(className);
033            }
034    
035            public static void clearLocalCache() {
036                    _finderCache.clearLocalCache();
037            }
038    
039            public static FinderCache getFinderCache() {
040                    PortalRuntimePermission.checkGetBeanProperty(FinderCacheUtil.class);
041    
042                    return _finderCache;
043            }
044    
045            public static Object getResult(
046                    FinderPath finderPath, Object[] args,
047                    BasePersistenceImpl<? extends BaseModel<?>> basePersistenceImpl) {
048    
049                    return _finderCache.getResult(finderPath, args, basePersistenceImpl);
050            }
051    
052            public static void invalidate() {
053                    getFinderCache().invalidate();
054            }
055    
056            public static void putResult(
057                    FinderPath finderPath, Object[] args, Object result) {
058    
059                    _finderCache.putResult(finderPath, args, result);
060            }
061    
062            public static void putResult(
063                    FinderPath finderPath, Object[] args, Object result, boolean quiet) {
064    
065                    _finderCache.putResult(finderPath, args, result, quiet);
066            }
067    
068            public static void removeCache(String className) {
069                    _finderCache.removeCache(className);
070            }
071    
072            public static void removeResult(FinderPath finderPath, Object[] args) {
073                    _finderCache.removeResult(finderPath, args);
074            }
075    
076            private static final FinderCache _finderCache =
077                    ProxyFactory.newServiceTrackedInstance(FinderCache.class);
078    
079    }