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