HHH-12702: Make JCacheRegionFactory easier to subclass
This commit is contained in:
parent
39cd150ae5
commit
3c0d043313
|
@ -130,17 +130,9 @@ public class JCacheRegionFactory extends RegionFactoryTemplate {
|
||||||
|
|
||||||
final CachingProvider cachingProvider = getCachingProvider( properties );
|
final CachingProvider cachingProvider = getCachingProvider( properties );
|
||||||
final CacheManager cacheManager;
|
final CacheManager cacheManager;
|
||||||
final String cacheManagerUri = getProp( properties, ConfigSettings.CONFIG_URI );
|
final URI cacheManagerUri = getUri( properties );
|
||||||
if ( cacheManagerUri != null ) {
|
if ( cacheManagerUri != null ) {
|
||||||
URI uri;
|
cacheManager = cachingProvider.getCacheManager( cacheManagerUri, getClassLoader( cachingProvider ));
|
||||||
try {
|
|
||||||
uri = new URI( cacheManagerUri );
|
|
||||||
}
|
|
||||||
catch ( URISyntaxException e ) {
|
|
||||||
throw new CacheException( "Couldn't create URI from " + cacheManagerUri, e );
|
|
||||||
}
|
|
||||||
// todo (5.3) : shouldn't this use Hibernate's AggregatedClassLoader?
|
|
||||||
cacheManager = cachingProvider.getCacheManager( uri, cachingProvider.getDefaultClassLoader() );
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
cacheManager = cachingProvider.getCacheManager();
|
cacheManager = cachingProvider.getCacheManager();
|
||||||
|
@ -148,6 +140,27 @@ public class JCacheRegionFactory extends RegionFactoryTemplate {
|
||||||
return cacheManager;
|
return cacheManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("WeakerAccess")
|
||||||
|
protected ClassLoader getClassLoader(CachingProvider cachingProvider) {
|
||||||
|
// todo (5.3) : shouldn't this use Hibernate's AggregatedClassLoader?
|
||||||
|
return cachingProvider.getDefaultClassLoader();
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("WeakerAccess")
|
||||||
|
protected URI getUri(Map properties) {
|
||||||
|
String cacheManagerUri = getProp( properties, ConfigSettings.CONFIG_URI );
|
||||||
|
if ( cacheManagerUri == null ) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
return new URI( cacheManagerUri );
|
||||||
|
}
|
||||||
|
catch ( URISyntaxException e ) {
|
||||||
|
throw new CacheException( "Couldn't create URI from " + cacheManagerUri, e );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private String getProp(Map properties, String prop) {
|
private String getProp(Map properties, String prop) {
|
||||||
return properties != null ? (String) properties.get( prop ) : null;
|
return properties != null ? (String) properties.get( prop ) : null;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue