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 CacheManager cacheManager;
|
||||
final String cacheManagerUri = getProp( properties, ConfigSettings.CONFIG_URI );
|
||||
final URI cacheManagerUri = getUri( properties );
|
||||
if ( cacheManagerUri != null ) {
|
||||
URI uri;
|
||||
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() );
|
||||
cacheManager = cachingProvider.getCacheManager( cacheManagerUri, getClassLoader( cachingProvider ));
|
||||
}
|
||||
else {
|
||||
cacheManager = cachingProvider.getCacheManager();
|
||||
|
@ -148,6 +140,27 @@ public class JCacheRegionFactory extends RegionFactoryTemplate {
|
|||
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) {
|
||||
return properties != null ? (String) properties.get( prop ) : null;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue