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

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

Introduction

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

Prototype

public void register(Class<?>... annotatedClasses) 

Source Link

Document

Register one or more annotated classes to be processed.

Usage

From source file:http2.Main.java

public static void main(String[] args) throws Exception {

    AnnotationConfigWebApplicationContext cxt = new AnnotationConfigWebApplicationContext();
    cxt.register(WebConfig.class);
    DispatcherServlet dispatcherServlet = new DispatcherServlet(cxt);

    Server server = new Server();

    ServletContextHandler context = new ServletContextHandler();
    context.setResourceBase("src/main/webapp");
    context.addServlet(new ServletHolder("default", DefaultServlet.class), "");
    context.addServlet(new ServletHolder(dispatcherServlet), "/");
    context.addFilter(new FilterHolder(new PushCacheFilter()), "/*", EnumSet.of(DispatcherType.REQUEST));
    server.setHandler(context);//from  ww  w  .j a  va 2  s  . com

    HttpConfiguration httpConfig = new HttpConfiguration();
    httpConfig.setSecureScheme("https");
    httpConfig.setSecurePort(8443);
    httpConfig.setSendXPoweredBy(true);
    httpConfig.setSendServerVersion(true);

    HttpConfiguration httpsConfig = new HttpConfiguration(httpConfig);
    httpsConfig.addCustomizer(new SecureRequestCustomizer());

    ServerConnector httpConnector = new ServerConnector(server, new HttpConnectionFactory(httpConfig));
    httpConnector.setPort(8080);
    server.addConnector(httpConnector);

    ServerConnector http2Connector = createHttp2Connector(server, httpsConfig);
    http2Connector.setPort(8443);
    server.addConnector(http2Connector);

    ALPN.debug = true;

    server.start();
    server.dumpStdErr();
    server.join();
}

From source file:com.amazonaws.serverless.proxy.spring.SpringLambdaContainerHandler.java

/**
 * Creates a default SpringLambdaContainerHandler initialized with the `AwsProxyRequest` and `AwsProxyResponse` objects
 * @param config A set of classes annotated with the Spring @Configuration annotation
 * @return An initialized instance of the `SpringLambdaContainerHandler`
 * @throws ContainerInitializationException
 *///www . ja va  2 s . c  o m
public static SpringLambdaContainerHandler<AwsProxyRequest, AwsProxyResponse> getAwsProxyHandler(
        Class... config) throws ContainerInitializationException {
    AnnotationConfigWebApplicationContext applicationContext = new AnnotationConfigWebApplicationContext();
    applicationContext.register(config);

    return new SpringLambdaContainerHandler<>(new AwsProxyHttpServletRequestReader(),
            new AwsProxyHttpServletResponseWriter(), new AwsProxySecurityContextWriter(),
            new AwsProxyExceptionHandler(), applicationContext);
}

From source file:org.lightadmin.core.config.LightAdminContextInitializer.java

@Override
public void initialize(AnnotationConfigWebApplicationContext applicationContext) {
    applicationContext.register(LightAdminContextConfiguration.class);
}

From source file:ip.ip.rest.config.WebAppInitializer.java

public void onStartup(javax.servlet.ServletContext sc) throws javax.servlet.ServletException {
    AnnotationConfigWebApplicationContext ctx = new AnnotationConfigWebApplicationContext();
    ctx.register(ApplicationConfig.class);
    ctx.setServletContext(sc);/*from  w  w  w. j a  v a 2  s.  c o m*/
    ServletRegistration.Dynamic dynamic = sc.addServlet("dispatcher", new DispatcherServlet(ctx));
    dynamic.addMapping("/");
    dynamic.setLoadOnStartup(1);
}

From source file:com.shadows.liquiblq.webapi.config.WebAppInitializer.java

@Override
public void onStartup(ServletContext servletContext) throws ServletException {
    AnnotationConfigWebApplicationContext ctx = new AnnotationConfigWebApplicationContext();
    ctx.register(AppConfig.class);
    ctx.setServletContext(servletContext);
    Dynamic dynamic = servletContext.addServlet("dispatcher", new DispatcherServlet(ctx));
    dynamic.addMapping("/");
    dynamic.setLoadOnStartup(1);//from w  ww .j  a  v  a2  s.  c  om
}

From source file:com.chevres.config.WebInitializer.java

@Override
public void onStartup(ServletContext servletContext) throws ServletException {
    AnnotationConfigWebApplicationContext ctx = new AnnotationConfigWebApplicationContext();
    ctx.register(Config.class);
    ctx.setServletContext(servletContext);
    Dynamic servlet = servletContext.addServlet("dispatcher", new DispatcherServlet(ctx));
    servlet.addMapping("/");
    servlet.setLoadOnStartup(1);// w ww.j  a  v a  2  s.  c  o m
}

From source file:com.mycompany.comerciobici.controlador.InicializadorRest.java

public void onStartup(ServletContext servletContext) throws ServletException {
    AnnotationConfigWebApplicationContext ctx = new AnnotationConfigWebApplicationContext();
    ctx.register(CargadorApplicacion.class);
    ctx.setServletContext(servletContext);
    ServletRegistration.Dynamic dynamic = servletContext.addServlet("dispatcher", new DispatcherServlet(ctx));
    dynamic.addMapping("/");
    dynamic.setLoadOnStartup(1);//from   www  .j  a va2 s . c o  m
}

From source file:com.chuangtc.config.SpringWebInitializer.java

public void onStartup(ServletContext servletContext) throws ServletException {

    AnnotationConfigWebApplicationContext ctx = new AnnotationConfigWebApplicationContext();
    ctx.register(AppConfig.class);
    ctx.setServletContext(servletContext);

    Dynamic servlet = servletContext.addServlet("dispatcher", new DispatcherServlet(ctx));
    servlet.addMapping("/");
    servlet.setLoadOnStartup(1);/*from w ww  .j a  v a  2s  .c  o  m*/

}

From source file:com.mycompany.config.WebInitializer.java

@Override
public void onStartup(ServletContext servletContext) throws ServletException {
    AnnotationConfigWebApplicationContext ctx = new AnnotationConfigWebApplicationContext();
    ctx.register(Config.class);
    ctx.setServletContext(servletContext);
    ServletRegistration.Dynamic servlet = servletContext.addServlet("dispatcher", new DispatcherServlet(ctx));
    servlet.addMapping("/");
    servlet.setLoadOnStartup(1);/*from  ww  w  .  ja  v a 2s .  c o  m*/
}

From source file:ui.config.WebAppInitializer.java

@Override
public void onStartup(ServletContext sc) throws ServletException {
    AnnotationConfigWebApplicationContext ctx = new AnnotationConfigWebApplicationContext();
    ctx.register(ApplicationConfig.class);
    ctx.setServletContext(sc);/*  w  w w  . j ava  2s.c o  m*/

    Dynamic dynamic = sc.addServlet("UserController", new DispatcherServlet(ctx));
    dynamic.addMapping("/");
    dynamic.setLoadOnStartup(1);
}