HHH-9874 Improve resource lookup for the Infinispan configuration resources
This commit is contained in:
parent
d0d0963c18
commit
3d27b29468
|
@ -6,7 +6,6 @@
|
||||||
*/
|
*/
|
||||||
package org.hibernate.cache.infinispan;
|
package org.hibernate.cache.infinispan;
|
||||||
|
|
||||||
import java.io.FileNotFoundException;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -47,6 +46,7 @@ import org.hibernate.service.ServiceRegistry;
|
||||||
|
|
||||||
import org.infinispan.AdvancedCache;
|
import org.infinispan.AdvancedCache;
|
||||||
import org.infinispan.commands.module.ModuleCommandFactory;
|
import org.infinispan.commands.module.ModuleCommandFactory;
|
||||||
|
import org.infinispan.commons.util.FileLookup;
|
||||||
import org.infinispan.commons.util.FileLookupFactory;
|
import org.infinispan.commons.util.FileLookupFactory;
|
||||||
import org.infinispan.configuration.cache.CacheMode;
|
import org.infinispan.configuration.cache.CacheMode;
|
||||||
import org.infinispan.configuration.cache.Configuration;
|
import org.infinispan.configuration.cache.Configuration;
|
||||||
|
@ -426,6 +426,7 @@ public class InfinispanRegionFactory implements RegionFactory {
|
||||||
properties,
|
properties,
|
||||||
DEF_INFINISPAN_CONFIG_RESOURCE
|
DEF_INFINISPAN_CONFIG_RESOURCE
|
||||||
);
|
);
|
||||||
|
final FileLookup fileLookup = FileLookupFactory.newInstance();
|
||||||
|
|
||||||
return serviceRegistry.getService( ClassLoaderService.class ).workWithClassLoader(
|
return serviceRegistry.getService( ClassLoaderService.class ).workWithClassLoader(
|
||||||
new ClassLoaderService.Work<EmbeddedCacheManager>() {
|
new ClassLoaderService.Work<EmbeddedCacheManager>() {
|
||||||
|
@ -433,13 +434,12 @@ public class InfinispanRegionFactory implements RegionFactory {
|
||||||
public EmbeddedCacheManager doWork(ClassLoader classLoader) {
|
public EmbeddedCacheManager doWork(ClassLoader classLoader) {
|
||||||
try {
|
try {
|
||||||
InputStream is;
|
InputStream is;
|
||||||
try {
|
is = fileLookup.lookupFile( configLoc, classLoader );
|
||||||
is = FileLookupFactory.newInstance().lookupFileStrict( configLoc, classLoader );
|
if ( is == null ) {
|
||||||
}
|
// when it's not a user-provided configuration file, it might be a default configuration file,
|
||||||
catch (FileNotFoundException e) {
|
// and if that's included in [this] module might not be visible to the ClassLoaderService:
|
||||||
// In some environments (ex: OSGi), hibernate-infinispan may not
|
|
||||||
// be in the app CL. It's important to also try this CL.
|
|
||||||
classLoader = this.getClass().getClassLoader();
|
classLoader = this.getClass().getClassLoader();
|
||||||
|
// This time use lookupFile*Strict* so to provide an exception if we can't find it yet:
|
||||||
is = FileLookupFactory.newInstance().lookupFileStrict( configLoc, classLoader );
|
is = FileLookupFactory.newInstance().lookupFileStrict( configLoc, classLoader );
|
||||||
}
|
}
|
||||||
final ParserRegistry parserRegistry = new ParserRegistry( classLoader );
|
final ParserRegistry parserRegistry = new ParserRegistry( classLoader );
|
||||||
|
|
Loading…
Reference in New Issue