use of com.webobjects.appserver.WOApplication in project wonder-slim by undur.
the class ERXProperties method pathForResourceNamed.
/**
* Determines the path of the specified Resource. This is done to get a
* single entry point due to the deprecation of pathForResourceNamed
*
* @param fileName name of the file
* @param frameworkName name of the framework, <code>null</code> or "app" for the application bundle
* @param languages array of languages to get localized resource or <code>null</code>
* @return the absolutePath method off of the file object
*/
private static String pathForResourceNamed(String fileName, String frameworkName, NSArray<String> languages) {
String path = null;
NSBundle bundle = "app".equals(frameworkName) ? NSBundle.mainBundle() : NSBundle.bundleForName(frameworkName);
if (bundle != null && bundle.isJar()) {
// FIXME: Changed log level to debug
// This was emitting at every application startup, seemingly without purpose.
// Since property loading seems to work fine anyway, I turned it to debug
// and we're going to have to have a look at property loading in general later.
log.debug("Can't get path when run as jar: {} - {}", frameworkName, fileName);
} else {
WOApplication application = WOApplication.application();
if (application != null) {
URL url = application.resourceManager().pathURLForResourceNamed(fileName, frameworkName, languages);
if (url != null) {
path = url.getFile();
}
} else if (bundle != null) {
URL url = bundle.pathURLForResourcePath(fileName);
if (url != null) {
path = url.getFile();
}
}
}
return path;
}
Aggregations