use of jodd.joy.exception.AppException in project jodd by oblac.
the class DefaultAppCore method resolveAppDir.
/**
* Resolves application root folders.
* <p>
* If application is started as web application, app folder is one below the WEB-INF folder.
* Otherwise, the root folder is equal to the working folder.
*/
protected void resolveAppDir(String classPathFileName) {
URL url = ClassLoaderUtil.getResourceUrl(classPathFileName);
if (url == null) {
throw new AppException("Failed to resolve app dir, missing: " + classPathFileName);
}
String protocol = url.getProtocol();
if (!protocol.equals("file")) {
try {
url = new URL(url.getFile());
} catch (MalformedURLException ignore) {
}
}
appDir = url.getFile();
int ndx = appDir.indexOf("WEB-INF");
isWebApplication = (ndx != -1);
appDir = isWebApplication ? appDir.substring(0, ndx) : SystemUtil.workingFolder();
}
Aggregations