public static void setUpApplicationContext(ServletContext sContext, HttpServletRequest req) { ApplicationContext context = ApplicationContext.getContext(); if (context == null) { context = new ApplicationContext(); ApplicationContext.setContext(context); } String webAppName = URLGenerator.generateServletBaseURL(req); int pos = webAppName.indexOf("/"); if (pos > -1) webAppName = webAppName.substring(0, pos); context.setAppDocumentRoot(sContext.getRealPath("/")); if (webAppName == null) webAppName = ""; context.setAppID(webAppName); context.setLogger(MessageLog.getLoggerForApplication(webAppName)); }
public static void setUpApplicationContext(ServletContext sContext) { ApplicationContext context = ApplicationContext.getContext(); if (context == null) { context = new ApplicationContext(); ApplicationContext.setContext(context); } context.setAppDocumentRoot(sContext.getRealPath("/")); String webAppName; try { webAppName = sContext.getResource("/").toString(); if (webAppName.endsWith("/")) webAppName = webAppName.substring(0, webAppName.length() - 1); int pos = webAppName.lastIndexOf("/"); if (pos > -1) webAppName = webAppName.substring(pos + 1); if (webAppName == null) webAppName = ""; context.setAppID(webAppName); context.setLogger(MessageLog.getLoggerForApplication(webAppName)); } catch (MalformedURLException e) { MessageLog.writeErrorMessage("setUpApplicationContext", e, null); } }