PL-5961 Allow to pack DB scripts to WAR

#PL-5961
This commit is contained in:
Eugeny Degtyarjov 2015-09-11 15:17:03 +00:00
parent 194cebd168
commit d4275caaa7
4 changed files with 27 additions and 13 deletions

View File

@ -6,6 +6,7 @@
package com.haulmont.cuba.core.sys.dbupdate;
import com.haulmont.cuba.core.sys.AppContext;
import com.haulmont.cuba.core.sys.ServletContextHolder;
import org.apache.commons.lang.StringUtils;
import org.springframework.core.io.Resource;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
@ -124,7 +125,7 @@ public class ScriptScanner {
protected ResourcePatternResolver createAppropriateResourceResolver() {
if (dbScriptsDirectory.startsWith(WEB_INF_LABEL)) {
return new ServletContextResourcePatternResolver(AppContext.getServletContext());
return new ServletContextResourcePatternResolver(ServletContextHolder.getServletContext());
} else {
return new PathMatchingResourcePatternResolver();
}

View File

@ -41,7 +41,7 @@ public abstract class AbstractWebAppContextLoader extends AbstractAppContextLoad
public void contextInitialized(ServletContextEvent servletContextEvent) {
try {
ServletContext sc = servletContextEvent.getServletContext();
AppContext.setServletContext(sc);
ServletContextHolder.setServletContext(sc);
initAppProperties(sc);
afterInitAppProperties();

View File

@ -11,7 +11,6 @@ import org.springframework.context.ApplicationContext;
import org.springframework.context.ConfigurableApplicationContext;
import javax.annotation.Nullable;
import javax.servlet.ServletContext;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
@ -50,8 +49,6 @@ public class AppContext {
private static ApplicationContext context;
private static ServletContext servletContext;
private static Map<String, String> properties = new ConcurrentHashMap<>();
private static SecurityContextHolder securityContextHolder = new ThreadLocalSecurityContextHolder();
@ -209,12 +206,4 @@ public class AppContext {
((ConfigurableApplicationContext) context).close();
}
}
public static ServletContext getServletContext() {
return servletContext;
}
public static void setServletContext(ServletContext servletContext) {
AppContext.servletContext = servletContext;
}
}

View File

@ -0,0 +1,24 @@
/*
* Copyright (c) 2008-2015 Haulmont. All rights reserved.
* Use is subject to license terms, see http://www.cuba-platform.com/license for details.
*/
package com.haulmont.cuba.core.sys;
import javax.servlet.ServletContext;
/**
* @author degtyarjov
* @version $Id$
*/
public class ServletContextHolder {
private static volatile ServletContext servletContext;
public static ServletContext getServletContext() {
return servletContext;
}
public static void setServletContext(ServletContext servletContext) {
ServletContextHolder.servletContext = servletContext;
}
}