001    /**
002     * Copyright (c) 2000-2011 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.region;
016    
017    import net.sf.ehcache.hibernate.regions.EhcacheTimestampsRegion;
018    
019    import org.hibernate.cache.CacheException;
020    import org.hibernate.cache.TimestampsRegion;
021    
022    /**
023     * @author Edward Han
024     */
025    public class TimestampsRegionWrapper
026            extends BaseRegionWrapper implements TimestampsRegion {
027    
028            public TimestampsRegionWrapper(
029                    EhcacheTimestampsRegion ehcacheTimestampsRegion) {
030    
031                    super(ehcacheTimestampsRegion);
032            }
033    
034            public void evict(Object key) throws CacheException {
035                    EhcacheTimestampsRegion ehcacheTimestampsRegion =
036                            getEhcacheTimestampsRegion();
037    
038                    ehcacheTimestampsRegion.evict(key);
039            }
040    
041            public void evictAll() throws CacheException {
042                    EhcacheTimestampsRegion ehcacheTimestampsRegion =
043                            getEhcacheTimestampsRegion();
044    
045                    ehcacheTimestampsRegion.evictAll();
046            }
047    
048            public Object get(Object key) throws CacheException {
049                    EhcacheTimestampsRegion ehcacheTimestampsRegion =
050                            getEhcacheTimestampsRegion();
051    
052                    return ehcacheTimestampsRegion.get(key);
053            }
054    
055            public void invalidate() {
056                    EhcacheTimestampsRegion ehcacheTimestampsRegion =
057                            getEhcacheTimestampsRegion();
058    
059                    ehcacheTimestampsRegion.evictAll();
060            }
061    
062            public void put(Object key, Object value) throws CacheException {
063                    EhcacheTimestampsRegion ehcacheTimestampsRegion =
064                            getEhcacheTimestampsRegion();
065    
066                    ehcacheTimestampsRegion.put(key, value);
067            }
068    
069            protected EhcacheTimestampsRegion getEhcacheTimestampsRegion() {
070                    return (EhcacheTimestampsRegion)getEhcacheDataRegion();
071            }
072    
073    }