当前位置: 首页>>代码示例>>Java>>正文


Java XmlWebApplicationContext.setConfigLocation方法代码示例

本文整理汇总了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;
}
 
开发者ID:rsine,项目名称:rsine,代码行数:17,代码来源:Rsine.java

示例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;
}
 
开发者ID:awslabs,项目名称:aws-serverless-java-container,代码行数:17,代码来源:LambdaHandler.java

示例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("/");
  		
  	}

  }
 
开发者ID:thinking-github,项目名称:nbone,代码行数:21,代码来源:SpringWebApplicationInitializer.java

示例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;
}
 
开发者ID:Communote,项目名称:communote-server,代码行数:18,代码来源:DispatcherServletInitializer.java

示例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("/");
}
 
开发者ID:TomirKlos,项目名称:Webstore,代码行数:10,代码来源:AppInitializer.java

示例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));
      		}
	}
      }
      
    }
 
开发者ID:danidemi,项目名称:jlubricant,代码行数:28,代码来源:SpringDispatcherServletFeature.java

示例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;
	}
 
开发者ID:3pillarlabs,项目名称:spring-integration-aws,代码行数:16,代码来源:InterAccountSNSPermissionTest.java

示例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();
}
 
开发者ID:jirutka,项目名称:spring-modular,代码行数:11,代码来源:NestedControllerTest.java

示例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();
}
 
开发者ID:jirutka,项目名称:spring-modular,代码行数:11,代码来源:ScanningTest.java

示例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;
}
 
开发者ID:PacktPublishing,项目名称:DevOps-for-Web-Development,代码行数:7,代码来源:PetclinicInitializer.java

示例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.");
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:63,代码来源:KualiInitializeListener.java

示例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);
}
 
开发者ID:bullhorn,项目名称:starter-kit-spring-maven,代码行数:19,代码来源:ServletInitializer.java

示例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.");

}
 
开发者ID:kuali-mirror,项目名称:kpme,代码行数:64,代码来源:EdoInitializeListener.java

示例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.");
   }
 
开发者ID:aapotts,项目名称:kuali_rice,代码行数:54,代码来源:KualiInitializeListener.java


注:本文中的org.springframework.web.context.support.XmlWebApplicationContext.setConfigLocation方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。