public static Resource findResource(final String cfgFile) {
try {
return AccessController.doPrivileged(new PrivilegedAction<Resource>() {
public Resource run() {
Resource cpr = new ClassPathResource(cfgFile);
if (cpr.exists()) {
return cpr;
}
try {
//see if it's a URL
URL url = new URL(cfgFile);
cpr = new UrlResource(url);
if (cpr.exists()) {
return cpr;
}
} catch (MalformedURLException e) {
//ignore
}
//try loading it our way
URL url = ClassLoaderUtils.getResource(cfgFile, BusApplicationContext.class);
if (url != null) {
cpr = new UrlResource(url);
if (cpr.exists()) {
return cpr;
}
}
cpr = new FileSystemResource(cfgFile);
if (cpr.exists()) {
return cpr;
}
return null;
}
});