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.util.GetterUtil;
018    import com.liferay.portal.util.PropsUtil;
019    
020    import com.opensymphony.oscache.base.CacheEntry;
021    
022    import java.util.Properties;
023    
024    import org.hibernate.cache.Cache;
025    import org.hibernate.cache.CacheException;
026    import org.hibernate.cache.CacheProvider;
027    import org.hibernate.cache.Timestamper;
028    import org.hibernate.util.StringHelper;
029    
030    /**
031     * @author         Mathias Bogaert
032     * @author         Brian Wing Shun Chan
033     * @deprecated
034     */
035    public class OSCacheProvider implements CacheProvider {
036    
037            public static final String OSCACHE_REFRESH_PERIOD = "refresh.period";
038    
039            public static final String OSCACHE_CRON = "cron";
040    
041            public Cache buildCache(String region, Properties properties)
042                    throws CacheException {
043    
044                    int refreshPeriod = GetterUtil.getInteger(
045                            PropsUtil.get(StringHelper.qualify(region, OSCACHE_REFRESH_PERIOD)),
046                            CacheEntry.INDEFINITE_EXPIRY);
047    
048                    String cron = PropsUtil.get(StringHelper.qualify(region, OSCACHE_CRON));
049    
050                    return new CacheWrapper(new OSCache(refreshPeriod, cron, region));
051            }
052    
053            public boolean isMinimalPutsEnabledByDefault() {
054                    return false;
055            }
056    
057            public long nextTimestamp() {
058                    return Timestamper.next();
059            }
060    
061            public void start(Properties properties) throws CacheException {
062            }
063    
064            public void stop() {
065            }
066    
067    }