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