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.dao.orm.hibernate;
016    
017    import com.liferay.portal.kernel.log.Log;
018    import com.liferay.portal.kernel.log.LogFactoryUtil;
019    
020    import java.util.Properties;
021    
022    import org.hibernate.cache.Cache;
023    import org.hibernate.cache.CacheException;
024    import org.hibernate.cache.CacheProvider;
025    
026    /**
027     * @author         Brian Wing Shun Chan
028     * @deprecated
029     */
030    public class CacheProviderWrapper implements CacheProvider {
031    
032            public CacheProviderWrapper(CacheProvider cacheProvider) {
033                    this.cacheProvider = cacheProvider;
034            }
035    
036            public CacheProviderWrapper(String cacheProviderClassName) {
037                    try {
038                            cacheProvider = (CacheProvider)Class.forName(
039                                    cacheProviderClassName).newInstance();
040                    }
041                    catch (Exception e) {
042                            _log.error(e, e);
043                    }
044            }
045    
046            public Cache buildCache(String regionName, Properties properties)
047                    throws CacheException {
048    
049                    return new CacheWrapper(
050                            cacheProvider.buildCache(regionName, properties));
051            }
052    
053            public boolean isMinimalPutsEnabledByDefault() {
054                    return cacheProvider.isMinimalPutsEnabledByDefault();
055            }
056    
057            public long nextTimestamp() {
058                    return cacheProvider.nextTimestamp();
059            }
060    
061            public void start(Properties properties) throws CacheException {
062                    cacheProvider.start(properties);
063            }
064    
065            public void stop() {
066                    cacheProvider.stop();
067            }
068    
069            protected CacheProvider cacheProvider;
070    
071            private static Log _log = LogFactoryUtil.getLog(CacheProviderWrapper.class);
072    
073    }