Search in sources :

Example 1 with AppException

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();
}
Also used : AppException(jodd.joy.exception.AppException) MalformedURLException(java.net.MalformedURLException) URL(java.net.URL)

Aggregations

MalformedURLException (java.net.MalformedURLException)1 URL (java.net.URL)1 AppException (jodd.joy.exception.AppException)1