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 java.io.Serializable;
018    
019    /**
020     * @author Brian Wing Shun Chan
021     */
022    public class EntityCacheUtil {
023    
024            public static void clearCache() {
025                    getEntityCache().clearCache();
026            }
027    
028            public static void clearCache(String className) {
029                    getEntityCache().clearCache(className);
030            }
031    
032            public static void clearLocalCache() {
033                    getEntityCache().clearLocalCache();
034            }
035    
036            public static EntityCache getEntityCache() {
037                    return _finderCache;
038            }
039    
040            public static Object getResult(
041                    boolean entityCacheEnabled, Class<?> classObj,
042                    Serializable primaryKeyObj, SessionFactory sessionFactory) {
043    
044                    return getEntityCache().getResult(
045                            entityCacheEnabled, classObj, primaryKeyObj, sessionFactory);
046            }
047    
048            public static void invalidate() {
049                    getEntityCache().invalidate();
050            }
051    
052            public static Object loadResult(
053                    boolean entityCacheEnabled, Class<?> classObj,
054                    Serializable primaryKeyObj, SessionFactory sessionFactory) {
055    
056                    return getEntityCache().loadResult(
057                            entityCacheEnabled, classObj, primaryKeyObj, sessionFactory);
058            }
059    
060            public static void putResult(
061                    boolean entityCacheEnabled, Class<?> classObj,
062                    Serializable primaryKeyObj, Object result) {
063    
064                    getEntityCache().putResult(
065                            entityCacheEnabled, classObj, primaryKeyObj, result);
066            }
067    
068            public static void removeCache(String className) {
069                    getEntityCache().removeCache(className);
070            }
071    
072            public static void removeResult(
073                    boolean entityCacheEnabled, Class<?> classObj,
074                    Serializable primaryKeyObj) {
075    
076                    getEntityCache().removeResult(
077                            entityCacheEnabled, classObj, primaryKeyObj);
078            }
079    
080            public void setEntityCache(EntityCache finderCache) {
081                    _finderCache = finderCache;
082            }
083    
084            private static EntityCache _finderCache;
085    
086    }