001    /**
002     * Copyright (c) 2000-2011 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.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    }