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