001/* 002 * Copyright 2002-2013 the original author or authors. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * https://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 017package org.springframework.orm.hibernate3; 018 019import java.util.Properties; 020 021import org.hibernate.cache.CacheDataDescription; 022import org.hibernate.cache.CacheException; 023import org.hibernate.cache.CollectionRegion; 024import org.hibernate.cache.EntityRegion; 025import org.hibernate.cache.QueryResultsRegion; 026import org.hibernate.cache.RegionFactory; 027import org.hibernate.cache.TimestampsRegion; 028import org.hibernate.cache.access.AccessType; 029import org.hibernate.cfg.Settings; 030 031/** 032 * Proxy for a Hibernate RegionFactory, delegating to a Spring-managed 033 * RegionFactory instance, determined by LocalSessionFactoryBean's 034 * "cacheRegionFactory" property. 035 * 036 * @author Juergen Hoeller 037 * @since 3.0 038 * @see LocalSessionFactoryBean#setCacheRegionFactory 039 * @deprecated as of Spring 4.3, in favor of Hibernate 4.x/5.x 040 */ 041@Deprecated 042public class LocalRegionFactoryProxy implements RegionFactory { 043 044 private final RegionFactory regionFactory; 045 046 047 /** 048 * Standard constructor. 049 */ 050 public LocalRegionFactoryProxy() { 051 RegionFactory rf = (RegionFactory) LocalSessionFactoryBean.getConfigTimeRegionFactory(); 052 // absolutely needs thread-bound RegionFactory to initialize 053 if (rf == null) { 054 throw new IllegalStateException("No Hibernate RegionFactory found - " + 055 "'cacheRegionFactory' property must be set on LocalSessionFactoryBean"); 056 } 057 this.regionFactory = rf; 058 } 059 060 /** 061 * Properties constructor: not used by this class or formally required, 062 * but enforced by Hibernate when reflectively instantiating a RegionFactory. 063 */ 064 public LocalRegionFactoryProxy(Properties properties) { 065 this(); 066 } 067 068 069 @Override 070 public void start(Settings settings, Properties properties) throws CacheException { 071 this.regionFactory.start(settings, properties); 072 } 073 074 @Override 075 public void stop() { 076 this.regionFactory.stop(); 077 } 078 079 @Override 080 public boolean isMinimalPutsEnabledByDefault() { 081 return this.regionFactory.isMinimalPutsEnabledByDefault(); 082 } 083 084 @Override 085 public AccessType getDefaultAccessType() { 086 return this.regionFactory.getDefaultAccessType(); 087 } 088 089 @Override 090 public long nextTimestamp() { 091 return this.regionFactory.nextTimestamp(); 092 } 093 094 @Override 095 public EntityRegion buildEntityRegion(String regionName, Properties properties, CacheDataDescription metadata) 096 throws CacheException { 097 098 return this.regionFactory.buildEntityRegion(regionName, properties, metadata); 099 } 100 101 @Override 102 public CollectionRegion buildCollectionRegion(String regionName, Properties properties, 103 CacheDataDescription metadata) throws CacheException { 104 105 return this.regionFactory.buildCollectionRegion(regionName, properties, metadata); 106 } 107 108 @Override 109 public QueryResultsRegion buildQueryResultsRegion(String regionName, Properties properties) 110 throws CacheException { 111 112 return this.regionFactory.buildQueryResultsRegion(regionName, properties); 113 } 114 115 @Override 116 public TimestampsRegion buildTimestampsRegion(String regionName, Properties properties) 117 throws CacheException { 118 119 return this.regionFactory.buildTimestampsRegion(regionName, properties); 120 } 121 122}