boolean isSecured = System.getSecurityManager() != null;
boolean isContextCL = true;
// try the context class loader first
GetClassLoader action = GetClassLoader.fromContext();
ClassLoader loader = isSecured ? AccessController.doPrivileged( action ) : action.run();
if (loader == null) {
log.debug( "No default context class loader, fallbacking to Bean Validation's loader" );
action = GetClassLoader.fromClass(ValidationXmlParser.class);
loader = isSecured ? AccessController.doPrivileged( action ) : action.run();
isContextCL = false;
}
InputStream inputStream = loader.getResourceAsStream( path );
// try the current class loader
if ( isContextCL && inputStream == null ) {
action = GetClassLoader.fromClass(ValidationXmlParser.class);
loader = isSecured ? AccessController.doPrivileged( action ) : action.run();
inputStream = loader.getResourceAsStream( path );
}
return inputStream;
}