Example usage for org.springframework.web.context.support XmlWebApplicationContext setId

List of usage examples for org.springframework.web.context.support XmlWebApplicationContext setId

Introduction

In this page you can find the example usage for org.springframework.web.context.support XmlWebApplicationContext setId.

Prototype

@Override
    public void setId(String id) 

Source Link

Usage

From source file:br.com.caelum.vraptor.ioc.spring.DefaultSpringLocator.java

public ConfigurableWebApplicationContext getApplicationContext(ServletContext servletContext) {
    ConfigurableWebApplicationContext context = (ConfigurableWebApplicationContext) WebApplicationContextUtils
            .getWebApplicationContext(servletContext);
    if (context != null) {
        logger.info("Using a web application context: {}", context);
        return context;
    }/* ww  w.  j av  a 2  s  .  c  om*/
    if (DefaultSpringLocator.class.getResource("/applicationContext.xml") != null) {
        logger.info("Using an XmlWebApplicationContext, searching for applicationContext.xml");
        XmlWebApplicationContext ctx = new XmlWebApplicationContext();
        ctx.setConfigLocation("classpath:applicationContext.xml");
        servletContext.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, ctx);
        return ctx;
    }
    logger.info("No application context found");
    ConfigurableWebApplicationContext ctx = new AnnotationConfigWebApplicationContext();
    ctx.setId("VRaptor");
    servletContext.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, ctx);
    return ctx;
}