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.velocity;
016    
017    import com.liferay.portal.kernel.cache.MultiVMPoolUtil;
018    import com.liferay.portal.kernel.cache.PortalCache;
019    
020    import org.apache.velocity.runtime.resource.Resource;
021    
022    /**
023     * @author Brian Wing Shun Chan
024     */
025    public class LiferayResourceCacheUtil {
026    
027            public static final String CACHE_NAME =
028                    LiferayResourceCacheUtil.class.getName();
029    
030            public static void clear() {
031                    _portalCache.removeAll();
032            }
033    
034            public static Resource get(String key) {
035                    Object resource = _portalCache.get(key);
036    
037                    if ((resource != null) && (resource instanceof Resource)) {
038                            return (Resource)resource;
039                    }
040    
041                    return null;
042            }
043    
044            public static void put(String key, Resource resource) {
045                    _portalCache.put(key, resource);
046            }
047    
048            public static void remove(String key) {
049                    _portalCache.remove(key);
050            }
051    
052            private static PortalCache _portalCache = MultiVMPoolUtil.getCache(
053                    CACHE_NAME);
054    
055    }