001    /**
002     * Copyright (c) 2000-2013 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.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            @Override
035            public void evict(Object key) throws CacheException {
036                    EhcacheTimestampsRegion ehcacheTimestampsRegion =
037                            getEhcacheTimestampsRegion();
038    
039                    ehcacheTimestampsRegion.evict(key);
040            }
041    
042            @Override
043            public void evictAll() throws CacheException {
044                    EhcacheTimestampsRegion ehcacheTimestampsRegion =
045                            getEhcacheTimestampsRegion();
046    
047                    ehcacheTimestampsRegion.evictAll();
048            }
049    
050            @Override
051            public Object get(Object key) throws CacheException {
052                    EhcacheTimestampsRegion ehcacheTimestampsRegion =
053                            getEhcacheTimestampsRegion();
054    
055                    return ehcacheTimestampsRegion.get(key);
056            }
057    
058            @Override
059            public void invalidate() {
060                    EhcacheTimestampsRegion ehcacheTimestampsRegion =
061                            getEhcacheTimestampsRegion();
062    
063                    ehcacheTimestampsRegion.evictAll();
064            }
065    
066            @Override
067            public void put(Object key, Object value) throws CacheException {
068                    EhcacheTimestampsRegion ehcacheTimestampsRegion =
069                            getEhcacheTimestampsRegion();
070    
071                    ehcacheTimestampsRegion.put(key, value);
072            }
073    
074            protected EhcacheTimestampsRegion getEhcacheTimestampsRegion() {
075                    return (EhcacheTimestampsRegion)getEhcacheDataRegion();
076            }
077    
078    }