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