Hi devs,
I'd like to deprecate Util.getResourceAsStream():
public static InputStream getResourceAsStream(String resource)
{
File file = new File(resource);
try {
if (file.exists()) {
return new FileInputStream(file);
}
} catch (Exception e) {
// Probably running under -security, which prevents calling File.exists()
LOGGER.debug("Failed load resource [" + resource + "] using a
file path");
}
try {
Environment environment = Utils.getComponent(Environment.class);
InputStream res = environment.getResourceAsStream(resource);
if (res != null) {
return res;
}
} catch (Exception e) {
LOGGER.debug("Failed to load resource [" + resource + "] using
the application context");
}
return
Thread.currentThread().getContextClassLoader().getResourceAsStream(resource);
}
Instead I'd like to propose to use the new Environment.getResourceAsStream(). However
I'd also like to modify the ServletEnvironment.getResourceAsStream() implementation so
that it also looks in the classloader if not found in the resources directory (defaulting
to the current thread context class loader for the classloader to use since this is set in
a servlet container).
Thanks
-Vincent
Show replies by date