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.EhcacheEntityRegion;
018    
019    import org.hibernate.cache.CacheDataDescription;
020    import org.hibernate.cache.CacheException;
021    import org.hibernate.cache.EntityRegion;
022    import org.hibernate.cache.access.AccessType;
023    import org.hibernate.cache.access.EntityRegionAccessStrategy;
024    
025    /**
026     * @author Edward Han
027     */
028    public class EntityRegionWrapper
029            extends BaseRegionWrapper implements EntityRegion {
030    
031            public EntityRegionWrapper(EhcacheEntityRegion ehcacheEntityRegion) {
032                    super(ehcacheEntityRegion);
033            }
034    
035            @Override
036            public EntityRegionAccessStrategy buildAccessStrategy(AccessType accessType)
037                    throws CacheException {
038    
039                    EhcacheEntityRegion ehcacheEntityRegion = getEhcacheEntityRegion();
040    
041                    return ehcacheEntityRegion.buildAccessStrategy(accessType);
042            }
043    
044            @Override
045            public CacheDataDescription getCacheDataDescription() {
046                    EhcacheEntityRegion ehcacheEntityRegion = getEhcacheEntityRegion();
047    
048                    return ehcacheEntityRegion.getCacheDataDescription();
049            }
050    
051            @Override
052            public void invalidate() {
053                    EhcacheEntityRegion ehcacheEntityRegion = getEhcacheEntityRegion();
054    
055                    ehcacheEntityRegion.clear();
056            }
057    
058            @Override
059            public boolean isTransactionAware() {
060                    EhcacheEntityRegion ehcacheEntityRegion = getEhcacheEntityRegion();
061    
062                    return ehcacheEntityRegion.isTransactionAware();
063            }
064    
065            protected EhcacheEntityRegion getEhcacheEntityRegion() {
066                    return (EhcacheEntityRegion)getEhcacheDataRegion();
067            }
068    
069    }