Example usage for org.springframework.web.context.support AnnotationConfigWebApplicationContext refresh

List of usage examples for org.springframework.web.context.support AnnotationConfigWebApplicationContext refresh

Introduction

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

Prototype

@Override
    public void refresh() throws BeansException, IllegalStateException 

Source Link

Usage

From source file:com.indoqa.osgi.embedded.sample.webapp.WebappIntiallizer.java

private static AnnotationConfigWebApplicationContext initializeSpringApplicationContext(
        ServletContext servletContext) {
    AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext();
    context.setServletContext(servletContext);
    context.scan("com.indoqa.osgi.embedded.sample");
    context.refresh();
    return context;
}

From source file:br.eti.danielcamargo.backend.common.config.WebAppInitializer.java

private WebApplicationContext createRootContext(ServletContext servletContext) {
    AnnotationConfigWebApplicationContext rootContext = new AnnotationConfigWebApplicationContext();
    rootContext.register(CoreConfig.class, SecurityConfig.class);
    rootContext.refresh();
    servletContext.addListener(new ContextLoaderListener(rootContext));
    servletContext.setInitParameter("defaultHtmlEscape", "true");
    return rootContext;
}

From source file:org.kew.rmf.reconciliation.config.WebAppInitializer.java

private WebApplicationContext createRootContext(ServletContext servletContext) {
    AnnotationConfigWebApplicationContext rootContext = new AnnotationConfigWebApplicationContext();
    rootContext.register(CoreConfig.class);
    rootContext.refresh();

    servletContext.addListener(new ContextLoaderListener(rootContext));
    servletContext.setInitParameter("defaultHtmlEscape", "true");

    return rootContext;
}

From source file:net.orpiske.tcs.service.config.WebAppInitializer.java

private WebApplicationContext createRootContext(ServletContext servletContext) {
    AnnotationConfigWebApplicationContext rootContext = new AnnotationConfigWebApplicationContext();

    rootContext.register(CoreConfig.class, SecurityConfig.class);
    rootContext.refresh();

    servletContext.addListener(new ContextLoaderListener(rootContext));
    servletContext.setInitParameter("defaultHtmlEscape", "true");

    return rootContext;
}

From source file:com.springsource.html5expense.web.ExpenseReportAppContextInitializer.java

@Override
public void initialize(AnnotationConfigWebApplicationContext applicationContext) {
    String profile = "local";
    if (isCloudFoundry()) {
        profile = "cloud";
    }/* ww w  . j a  v a 2  s  .c om*/
    applicationContext.getEnvironment().setActiveProfiles(profile);
    applicationContext.refresh();
}

From source file:config.JettyConfiguration.java

@Bean
public ServletContextHandler servletContext() throws IOException {
    ServletContextHandler handler = new ServletContextHandler(ServletContextHandler.SESSIONS);

    AnnotationConfigWebApplicationContext webApplicationContext = new AnnotationConfigWebApplicationContext();
    webApplicationContext.setParent(applicationContext);
    webApplicationContext.refresh();
    handler.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, webApplicationContext);

    handler.setContextPath("/");
    handler.setResourceBase(new ClassPathResource("webapp").getURI().toString());
    handler.addServlet(AdminServlet.class, "/metrics/*");
    handler.addServlet(dispatcherServlet(), "/");

    handler.addFilter(new FilterHolder(new DelegatingFilterProxy("springSecurityFilterChain")), "/*", null);

    return handler;
}

From source file:com.graphaware.server.foundation.context.BaseWebContextCreator.java

@Override
public WebApplicationContext createWebContext(ApplicationContext rootContext, ServletContextHandler handler,
        Config config) {/*from   w  w w. j  a  v  a 2s. c om*/
    AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext();
    context.setParent(rootContext);
    context.setServletContext(handler.getServletContext());

    registerConfigClasses(context, config);

    context.refresh();

    return context;
}

From source file:org.springsource.restbucks.ApplicationIntegrationTest.java

@Test
@Ignore// w w w  .  j  a  v  a  2s  .c o  m
public void initializesWebApplicationContext() {

    AnnotationConfigWebApplicationContext applicationContext = new AnnotationConfigWebApplicationContext();
    applicationContext.register(RepositoryRestMvcConfiguration.class);
    applicationContext.register(WebConfiguration.class);
    applicationContext.setParent(context);
    applicationContext.refresh();
}

From source file:com.dominion.salud.nomenclator.configuration.NOMENCLATORInitializer.java

@Override
public void onStartup(ServletContext servletContext) throws ServletException {
    AnnotationConfigWebApplicationContext ctx = new AnnotationConfigWebApplicationContext();
    ctx.scan("com.dominion.salud.nomenclator.configuration");
    ctx.setServletContext(servletContext);
    ctx.refresh();

    logger.info("     Registrando servlets de configuracion");
    ServletRegistration.Dynamic dispatcher = servletContext.addServlet("dispatcher",
            new DispatcherServlet(ctx));
    dispatcher.setInitParameter("contextClass", ctx.getClass().getName());
    dispatcher.setLoadOnStartup(1);/*from  www . ja  va 2 s .  c  o  m*/
    logger.info("          Agregando mapping: /");
    dispatcher.addMapping("/");
    logger.info("          Agregando mapping: /controller/*");
    dispatcher.addMapping("/controller/*");
    logger.info("          Agregando mapping: /services/*");
    dispatcher.addMapping("/services/*");
    servletContext.addListener(new ContextLoaderListener(ctx));
    logger.info("     Servlets de configuracion registrados correctamente");

    // Configuracion general
    logger.info("     Iniciando la configuracion del modulo");
    NOMENCLATORConstantes._HOME = StringUtils.endsWith(servletContext.getRealPath("/"), File.separator)
            ? servletContext.getRealPath("/")
            : servletContext.getRealPath("/") + File.separator;
    NOMENCLATORConstantes._TEMP = NOMENCLATORConstantes._HOME + "WEB-INF" + File.separator + "temp"
            + File.separator;
    NOMENCLATORConstantes._VERSION = ResourceBundle.getBundle("version").getString("version");
    NOMENCLATORConstantes._LOGS = NOMENCLATORConstantes._HOME + "WEB-INF" + File.separator + "classes"
            + File.separator + "logs";
    NOMENCLATORConstantes._CONTEXT_NAME = servletContext.getServletContextName();
    NOMENCLATORConstantes._CONTEXT_PATH = servletContext.getContextPath();
    NOMENCLATORConstantes._CONTEXT_SERVER = servletContext.getServerInfo();
    NOMENCLATORConstantes._ENABLE_TECHNICAL_INFORMATION = StringUtils.isNotBlank(
            ResourceBundle.getBundle("application").getString("nomenclator.enable.technical.information"))
                    ? Boolean.parseBoolean(ResourceBundle.getBundle("application")
                            .getString("nomenclator.enable.technical.information"))
                    : false;
    PropertyConfigurator.configureAndWatch("log4j");

    logger.info("          Configuracion general del sistema");
    logger.info("               nomenclator.home: " + NOMENCLATORConstantes._HOME);
    logger.info("               nomenclator.temp: " + NOMENCLATORConstantes._TEMP);
    logger.info("               nomenclator.version: " + NOMENCLATORConstantes._VERSION);
    logger.info("               nomenclator.logs: " + NOMENCLATORConstantes._LOGS);
    logger.info("               nomenclator.context.name: " + NOMENCLATORConstantes._CONTEXT_NAME);
    logger.info("               nomenclator.context.path: " + NOMENCLATORConstantes._CONTEXT_PATH);
    logger.info("               nomenclator.context.server: " + NOMENCLATORConstantes._CONTEXT_SERVER);
    logger.info("          Parametrizacion del sistema");
    logger.info("               nomenclator.enable.technical.information: "
            + NOMENCLATORConstantes._ENABLE_TECHNICAL_INFORMATION);
    logger.info("     Modulo configurado correctamente");
    logger.info("MODULO INICIADO CORRECTAMENTE");
}

From source file:docs.IndexDocTests.java

@Test
public void runSpringHttpSessionConfig() {
    AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext();
    context.register(SpringHttpSessionConfig.class);
    context.setServletContext(new MockServletContext());
    context.refresh();

    try {/*from w  w w. j  a va 2  s. c  om*/
        context.getBean(SessionRepositoryFilter.class);
    } finally {
        context.close();
    }
}