001    /**
002     * Copyright (c) 2000-2012 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 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<?> clazz, Serializable primaryKey) {
042    
043                    return getEntityCache().getResult(
044                            entityCacheEnabled, clazz, primaryKey);
045            }
046    
047            public static void invalidate() {
048                    getEntityCache().invalidate();
049            }
050    
051            public static Object loadResult(
052                    boolean entityCacheEnabled, Class<?> clazz, Serializable primaryKey,
053                    SessionFactory sessionFactory) {
054    
055                    return getEntityCache().loadResult(
056                            entityCacheEnabled, clazz, primaryKey, sessionFactory);
057            }
058    
059            public static void putResult(
060                    boolean entityCacheEnabled, Class<?> clazz, Serializable primaryKey,
061                    Object result) {
062    
063                    getEntityCache().putResult(
064                            entityCacheEnabled, clazz, primaryKey, result);
065            }
066    
067            public static void removeCache(String className) {
068                    getEntityCache().removeCache(className);
069            }
070    
071            public static void removeResult(
072                    boolean entityCacheEnabled, Class<?> clazz, Serializable primaryKey) {
073    
074                    getEntityCache().removeResult(entityCacheEnabled, clazz, primaryKey);
075            }
076    
077            public void setEntityCache(EntityCache finderCache) {
078                    _finderCache = finderCache;
079            }
080    
081            private static EntityCache _finderCache;
082    
083    }