本文整理汇总了Java中org.springframework.web.context.support.XmlWebApplicationContext.setConfigLocation方法的典型用法代码示例。如果您正苦于以下问题:Java XmlWebApplicationContext.setConfigLocation方法的具体用法?Java XmlWebApplicationContext.setConfigLocation怎么用?Java XmlWebApplicationContext.setConfigLocation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.web.context.support.XmlWebApplicationContext
的用法示例。
在下文中一共展示了XmlWebApplicationContext.setConfigLocation方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: startServer
import org.springframework.web.context.support.XmlWebApplicationContext; //导入方法依赖的package包/类
private static Server startServer() throws Exception {
Server server = new Server(cmdParams.port);
XmlWebApplicationContext context = new XmlWebApplicationContext();
context.setConfigLocation("classpath:application-context.xml");
ServletContextHandler contextHandler = new ServletContextHandler();
contextHandler.setContextPath("/");
contextHandler.addServlet(new ServletHolder(new DispatcherServlet(context)), "/*");
contextHandler.addEventListener(new ContextLoaderListener(context));
server.setHandler(contextHandler);
server.start();
return server;
}
示例2: handleRequest
import org.springframework.web.context.support.XmlWebApplicationContext; //导入方法依赖的package包/类
public AwsProxyResponse handleRequest(AwsProxyRequest awsProxyRequest, Context context)
{
if (!isinitialized) {
isinitialized = true;
try {
XmlWebApplicationContext wc = new XmlWebApplicationContext();
wc.setConfigLocation("classpath:/staticAppContext.xml");
handler = SpringLambdaContainerHandler.getAwsProxyHandler(wc);
} catch (ContainerInitializationException e) {
e.printStackTrace();
return null;
}
}
AwsProxyResponse res = handler.proxy(awsProxyRequest, context);
return res;
}
示例3: initDispatcherServlet
import org.springframework.web.context.support.XmlWebApplicationContext; //导入方法依赖的package包/类
/**
* <p>默认关闭<p>
* 加载spring mvc 统一调度器
* @param servletContext
*/
protected void initDispatcherServlet(ServletContext servletContext){
String enable = servletContext.getInitParameter("enableDispatcherServlet");
if(BooleanUtils.valueOf(enable)){
//classpath*:/spring-mvc*.xml,/WEB-INF/spring-mvc*.xml
XmlWebApplicationContext appContext = new XmlWebApplicationContext();
appContext.setConfigLocation("classpath*:/spring/spring-mvc*.xml,/WEB-INF/spring/spring-mvc*.xml");
ServletRegistration.Dynamic dispatcher = servletContext.addServlet("dispatcher", new DispatcherServlet(appContext));
dispatcher.setLoadOnStartup(1);
dispatcher.addMapping("/");
}
}
示例4: createMainDispatcherServlet
import org.springframework.web.context.support.XmlWebApplicationContext; //导入方法依赖的package包/类
private void createMainDispatcherServlet(ApplicationContext rootContext) {
mainWebApplicationContext = new XmlWebApplicationContext();
mainWebApplicationContext
.setConfigLocation(getRequiredInitParameter("communoteWebContextConfigLocation"));
mainWebApplicationContext.setParent(rootContext);
// add ContextLoaderListener with web-ApplicationContext which publishes it under a
// ServletContext attribute and closes it on shutdown. The former is required for
// WebApplicationContextUtils which are used by DelegatingFilterProxy (spring security).
// Closing is also done by dispatcher servlet's implementation of destroy method.
this.servletContext.addListener(new ContextLoaderListener(mainWebApplicationContext));
DispatcherServlet dispatcherServlet = new DispatcherServlet(mainWebApplicationContext);
ServletRegistration.Dynamic addedServlet = this.servletContext.addServlet(
getInitParameter("communoteServletName", "communote"), dispatcherServlet);
addedServlet.setLoadOnStartup(1);
addedServlet.addMapping(getRequiredInitParameter("communoteServletUrlPattern"));
this.mainDispatcherServlet = dispatcherServlet;
}
示例5: onStartup
import org.springframework.web.context.support.XmlWebApplicationContext; //导入方法依赖的package包/类
@Override
public void onStartup(ServletContext container) throws ServletException {
XmlWebApplicationContext appContext = new XmlWebApplicationContext();
appContext.setConfigLocation("/WEB-INF/spring/webcontext/DispatcherServlet-context.xml");
ServletRegistration.Dynamic dispatcher = container.addServlet("dispatcher", new DispatcherServlet(appContext));
dispatcher.setLoadOnStartup(1);
dispatcher.addMapping("/");
}
示例6: onStartup
import org.springframework.web.context.support.XmlWebApplicationContext; //导入方法依赖的package包/类
public void onStartup(ServletContext container) {
XmlWebApplicationContext appContext = new XmlWebApplicationContext();
appContext.setBeanName("fakeEmptyContext");
String fakeEmptyContext = SpringUtils.fakeEmptyContext();
appContext.setParent(springCtxInWhichJettyRuns);
appContext.setConfigLocation(fakeEmptyContext);
appContext.refresh();
DispatcherServlet dispatcherServlet = new DispatcherServlet(appContext);
ServletRegistration.Dynamic dispatcher = container.addServlet("dispatcher", dispatcherServlet);
dispatcher.setLoadOnStartup(1);
String[] dispatcherServletSubPath2 = SpringDispatcherServletFeature.this.dispatcherServletSubPath;
if(!ArrayUtils.isEmpty(dispatcherServletSubPath2)){
for (String string : dispatcherServletSubPath2) {
Set<String> alreadyExitingMappings = dispatcher.addMapping(string);
if(CollectionUtils.isNotEmpty(alreadyExitingMappings)){
throw new IllegalStateException(format("Mappings '%s' was already assigned to another servlet.", alreadyExitingMappings));
}
}
}
}
示例7: getServletContextHandler
import org.springframework.web.context.support.XmlWebApplicationContext; //导入方法依赖的package包/类
private ServletContextHandler getServletContextHandler() throws Exception {
context = new XmlWebApplicationContext();
context.setConfigLocation("src/main/webapp/WEB-INF/InterAccountSNSPermissionFlow.xml");
context.registerShutdownHook();
ServletContextHandler contextHandler = new ServletContextHandler();
contextHandler.setErrorHandler(null);
contextHandler.setResourceBase(".");
ServletHolder servletHolder = new ServletHolder(new DispatcherServlet(
context));
contextHandler.addServlet(servletHolder, "/*");
return contextHandler;
}
示例8: init
import org.springframework.web.context.support.XmlWebApplicationContext; //导入方法依赖的package包/类
@Before
public void init() throws Exception {
tester = new ServletTester();
XmlWebApplicationContext wac;
tester.setAttribute(Servlet.springCtxAttrName, wac = (XmlWebApplicationContext) FrameworkServlet.DEFAULT_CONTEXT_CLASS.newInstance());
wac.setConfigLocation("classpath:/com/griddynamics/banshun/controllers-test/parent-context.xml");
wac.refresh();
tester.addServlet(Servlet.class, "*.html");
tester.start();
}
示例9: init
import org.springframework.web.context.support.XmlWebApplicationContext; //导入方法依赖的package包/类
@Before
public void init() throws Exception {
tester = new ServletTester();
XmlWebApplicationContext wac;
tester.setAttribute(Servlet.springCtxAttrName, wac = (XmlWebApplicationContext) FrameworkServlet.DEFAULT_CONTEXT_CLASS.newInstance());
wac.setConfigLocation("classpath:/com/griddynamics/banshun/scan-test/parent-context.xml");
wac.refresh();
tester.addServlet(Servlet.class, "*.html");
tester.start();
}
示例10: createServletApplicationContext
import org.springframework.web.context.support.XmlWebApplicationContext; //导入方法依赖的package包/类
@Override
protected WebApplicationContext createServletApplicationContext() {
XmlWebApplicationContext webAppContext = new XmlWebApplicationContext();
webAppContext.setConfigLocation("classpath:spring/mvc-core-config.xml");
return webAppContext;
}
示例11: contextInitialized
import org.springframework.web.context.support.XmlWebApplicationContext; //导入方法依赖的package包/类
/**
* ServletContextListener interface implementation that schedules the start of the lifecycle
*/
@Override
public void contextInitialized(ServletContextEvent sce) {
long startInit = System.currentTimeMillis();
LOG.info("Initializing Kuali Rice Application...");
// Stop Quartz from "phoning home" on every startup
System.setProperty("org.terracotta.quartz.skipUpdateCheck", "true");
List<String> configLocations = new ArrayList<String>();
String additionalConfigLocations = System.getProperty(KewApiConstants.ADDITIONAL_CONFIG_LOCATIONS_PARAM);
if (!StringUtils.isBlank(additionalConfigLocations)) {
String[] additionalConfigLocationArray = additionalConfigLocations.split(",");
for (String additionalConfigLocation : additionalConfigLocationArray) {
configLocations.add(additionalConfigLocation);
}
}
String bootstrapSpringBeans = "";
if (!StringUtils.isBlank(System.getProperty(WEB_BOOTSTRAP_SPRING_FILE))) {
bootstrapSpringBeans = System.getProperty(WEB_BOOTSTRAP_SPRING_FILE);
} else if (!StringUtils.isBlank(sce.getServletContext().getInitParameter(WEB_BOOTSTRAP_SPRING_FILE))) {
String bootstrapSpringInitParam = sce.getServletContext().getInitParameter(WEB_BOOTSTRAP_SPRING_FILE);
// if the value comes through as ${bootstrap.spring.beans}, we ignore it
if (!DEFAULT_SPRING_BEANS_REPLACEMENT_VALUE.equals(bootstrapSpringInitParam)) {
bootstrapSpringBeans = bootstrapSpringInitParam;
LOG.info("Found bootstrap Spring Beans file defined in servlet context: " + bootstrapSpringBeans);
}
}
Properties baseProps = new Properties();
baseProps.putAll(getContextParameters(sce.getServletContext()));
baseProps.putAll(System.getProperties());
JAXBConfigImpl config = new JAXBConfigImpl(baseProps);
ConfigContext.init(config);
context = new XmlWebApplicationContext();
if (!StringUtils.isEmpty(bootstrapSpringBeans)) {
context.setConfigLocation(bootstrapSpringBeans);
}
context.setServletContext(sce.getServletContext());
// Provide an optional method for bootstrapping a Spring property source
Optional<PropertySource<?>> ps = PropertySources.getPropertySource(sce, "web.bootstrap.spring.psc");
if (ps.isPresent()) {
PropertySources.addFirst(context, ps.get());
}
try {
context.refresh();
} catch (RuntimeException e) {
LOG.error("problem during context.refresh()", e);
throw e;
}
context.start();
long endInit = System.currentTimeMillis();
LOG.info("...Kuali Rice Application successfully initialized, startup took " + (endInit - startInit) + " ms.");
}
示例12: addServlet
import org.springframework.web.context.support.XmlWebApplicationContext; //导入方法依赖的package包/类
private final void addServlet(ServletContext container, FilterRegistration.Dynamic sessionFilter, String name) {
XmlWebApplicationContext context = new XmlWebApplicationContext();
String servletFile = new StringBuilder("classpath:").append(name).append("-servlet.xml").toString();
context.setConfigLocation(servletFile);
DispatcherServlet dispatcherServlet = new DispatcherServlet(context);
ServletRegistration.Dynamic servlet = container.addServlet(name, dispatcherServlet);
String mapping = new StringBuilder("/").append(name).append("/*").toString();
sessionFilter.addMappingForUrlPatterns(null, false, mapping);
servlet.addMapping(mapping);
servlet.setLoadOnStartup(1);
}
示例13: contextInitialized
import org.springframework.web.context.support.XmlWebApplicationContext; //导入方法依赖的package包/类
@Override
public void contextInitialized(ServletContextEvent sce) {
configureInitialLogging();
// Set env.code from param, if present, dev if not.
// Add some settings to allow for dynamic environment prefix changes.
if (System.getProperty("env.code") == null) {
System.setProperty("env.code", "dev");
}
long startInit = System.currentTimeMillis();
LOG.info("Initializing Kuali Rice Application...");
List<String> configLocations = new ArrayList<String>();
String additionalConfigLocations = System.getProperty(KewApiConstants.ADDITIONAL_CONFIG_LOCATIONS_PARAM);
if (!StringUtils.isBlank(additionalConfigLocations)) {
String[] additionalConfigLocationArray = additionalConfigLocations.split(",");
for (String additionalConfigLocation : additionalConfigLocationArray) {
configLocations.add(additionalConfigLocation);
}
}
String bootstrapSpringBeans = "";
if (!StringUtils.isBlank(System.getProperty(WEB_BOOTSTRAP_SPRING_FILE))) {
bootstrapSpringBeans = System.getProperty(WEB_BOOTSTRAP_SPRING_FILE);
} else if (!StringUtils.isBlank(sce.getServletContext().getInitParameter(WEB_BOOTSTRAP_SPRING_FILE))) {
String bootstrapSpringInitParam = sce.getServletContext().getInitParameter(WEB_BOOTSTRAP_SPRING_FILE);
// if the value comes through as ${bootstrap.spring.beans}, we ignore it
if (!DEFAULT_SPRING_BEANS_REPLACEMENT_VALUE.equals(bootstrapSpringInitParam)) {
bootstrapSpringBeans = bootstrapSpringInitParam;
LOG.info("Found bootstrap Spring Beans file defined in servlet context: " + bootstrapSpringBeans);
}
}
Properties baseProps = new Properties();
try {
baseProps.putAll(getContextParameters(sce.getServletContext()));
baseProps.putAll(System.getProperties());
JAXBConfigImpl config = new JAXBConfigImpl(baseProps);
ConfigContext.init(config);
} catch (Throwable t){
LOG.error("Error caught in init "+t);
}
context = new XmlWebApplicationContext();
if (!StringUtils.isEmpty(bootstrapSpringBeans)) {
context.setConfigLocation(bootstrapSpringBeans);
}
context.setServletContext(sce.getServletContext());
try {
context.refresh();
} catch (RuntimeException e) {
LOG.error("problem during context.refresh()", e);
throw e;
}
context.start();
long endInit = System.currentTimeMillis();
LOG.info("...Kuali Rice Application successfully initialized, startup took " + (endInit - startInit) + " ms.");
}
示例14: contextInitialized
import org.springframework.web.context.support.XmlWebApplicationContext; //导入方法依赖的package包/类
/**
* ServletContextListener interface implementation that schedules the start of the lifecycle
*/
@Override
public void contextInitialized(ServletContextEvent sce) {
long startInit = System.currentTimeMillis();
LOG.info("Initializing Kuali Rice Application...");
List<String> configLocations = new ArrayList<String>();
String additionalConfigLocations = System.getProperty(KewApiConstants.ADDITIONAL_CONFIG_LOCATIONS_PARAM);
if (!StringUtils.isBlank(additionalConfigLocations)) {
String[] additionalConfigLocationArray = additionalConfigLocations.split(",");
for (String additionalConfigLocation : additionalConfigLocationArray) {
configLocations.add(additionalConfigLocation);
}
}
String bootstrapSpringBeans = "";
if (!StringUtils.isBlank(System.getProperty(WEB_BOOTSTRAP_SPRING_FILE))) {
bootstrapSpringBeans = System.getProperty(WEB_BOOTSTRAP_SPRING_FILE);
} else if (!StringUtils.isBlank(sce.getServletContext().getInitParameter(WEB_BOOTSTRAP_SPRING_FILE))) {
String bootstrapSpringInitParam = sce.getServletContext().getInitParameter(WEB_BOOTSTRAP_SPRING_FILE);
// if the value comes through as ${bootstrap.spring.beans}, we ignore it
if (!DEFAULT_SPRING_BEANS_REPLACEMENT_VALUE.equals(bootstrapSpringInitParam)) {
bootstrapSpringBeans = bootstrapSpringInitParam;
LOG.info("Found bootstrap Spring Beans file defined in servlet context: " + bootstrapSpringBeans);
}
}
Properties baseProps = new Properties();
baseProps.putAll(getContextParameters(sce.getServletContext()));
baseProps.putAll(System.getProperties());
JAXBConfigImpl config = new JAXBConfigImpl(baseProps);
ConfigContext.init(config);
context = new XmlWebApplicationContext();
if (!StringUtils.isEmpty(bootstrapSpringBeans)) {
context.setConfigLocation(bootstrapSpringBeans);
}
context.setServletContext(sce.getServletContext());
try {
context.refresh();
} catch (RuntimeException e) {
LOG.error("problem during context.refresh()", e);
throw e;
}
context.start();
long endInit = System.currentTimeMillis();
LOG.info("...Kuali Rice Application successfully initialized, startup took " + (endInit - startInit) + " ms.");
}