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.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            public EntityRegionAccessStrategy buildAccessStrategy(AccessType accessType)
036                    throws CacheException {
037    
038                    EhcacheEntityRegion ehcacheEntityRegion = getEhcacheEntityRegion();
039    
040                    return ehcacheEntityRegion.buildAccessStrategy(accessType);
041            }
042    
043            public CacheDataDescription getCacheDataDescription() {
044                    EhcacheEntityRegion ehcacheEntityRegion = getEhcacheEntityRegion();
045    
046                    return ehcacheEntityRegion.getCacheDataDescription();
047            }
048    
049            public void invalidate() {
050                    EhcacheEntityRegion ehcacheEntityRegion = getEhcacheEntityRegion();
051    
052                    ehcacheEntityRegion.clear();
053            }
054    
055            public boolean isTransactionAware() {
056                    EhcacheEntityRegion ehcacheEntityRegion = getEhcacheEntityRegion();
057    
058                    return ehcacheEntityRegion.isTransactionAware();
059            }
060    
061            protected EhcacheEntityRegion getEhcacheEntityRegion() {
062                    return (EhcacheEntityRegion)getEhcacheDataRegion();
063            }
064    
065    }