Java Code Examples for org.springframework.boot.WebApplicationType#SERVLET
The following examples show how to use
org.springframework.boot.WebApplicationType#SERVLET .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SpringBootLambdaContainerHandler.java From aws-serverless-java-container with Apache License 2.0 | 6 votes |
@Override public void initialize() throws ContainerInitializationException { Timer.start("SPRINGBOOT2_COLD_START"); SpringApplicationBuilder builder = new SpringApplicationBuilder(getEmbeddedContainerClasses()) .web(springWebApplicationType); // .REACTIVE, .SERVLET if (springProfiles != null) { builder.profiles(springProfiles); } applicationContext = builder.run(); if (springWebApplicationType == WebApplicationType.SERVLET) { ((AnnotationConfigServletWebServerApplicationContext)applicationContext).setServletContext(getServletContext()); AwsServletRegistration reg = (AwsServletRegistration)getServletContext().getServletRegistration(DISPATCHER_SERVLET_REGISTRATION_NAME); if (reg != null) { reg.setLoadOnStartup(1); } } super.initialize(); initialized = true; Timer.stop("SPRINGBOOT2_COLD_START"); }
Example 2
Source File: SpringBootLambdaContainerHandler.java From aws-serverless-java-container with Apache License 2.0 | 6 votes |
private Class<?>[] getEmbeddedContainerClasses() { Class<?>[] classes = new Class[2]; if (springWebApplicationType == WebApplicationType.REACTIVE) { try { // if HandlerAdapter is available we assume they are using WebFlux. Otherwise plain servlet. this.getClass().getClassLoader().loadClass("org.springframework.web.reactive.HandlerAdapter"); log.debug("Found WebFlux HandlerAdapter on classpath, using reactive server factory"); classes[0] = ServerlessReactiveServletEmbeddedServerFactory.class; } catch (ClassNotFoundException e) { springWebApplicationType = WebApplicationType.SERVLET; classes[0] = ServerlessServletEmbeddedServerFactory.class; } } else { classes[0] = ServerlessServletEmbeddedServerFactory.class; } classes[1] = springBootInitializer; return classes; }
Example 3
Source File: FunctionalInstallerListener.java From spring-init with Apache License 2.0 | 4 votes |
@Override public void onApplicationEvent(ApplicationEvent event) { if (event instanceof ApplicationContextInitializedEvent) { ApplicationContextInitializedEvent initialized = (ApplicationContextInitializedEvent) event; ConfigurableApplicationContext context = initialized.getApplicationContext(); if (!(context instanceof GenericApplicationContext)) { throw new IllegalStateException("ApplicationContext must be a GenericApplicationContext"); } if (!isEnabled(context.getEnvironment())) { return; } GenericApplicationContext generic = (GenericApplicationContext) context; ConditionService conditions = initialize(generic); functional(generic, conditions); apply(generic, initialized.getSpringApplication(), conditions); } else if (event instanceof ApplicationEnvironmentPreparedEvent) { ApplicationEnvironmentPreparedEvent prepared = (ApplicationEnvironmentPreparedEvent) event; if (!isEnabled(prepared.getEnvironment())) { return; } logger.info("Preparing application context"); SpringApplication application = prepared.getSpringApplication(); findInitializers(application); WebApplicationType type = getWebApplicationType(application, prepared.getEnvironment()); Class<?> contextType = getApplicationContextType(application); if (type == WebApplicationType.NONE) { if (contextType == AnnotationConfigApplicationContext.class || contextType == null) { application.setApplicationContextClass(GenericApplicationContext.class); } } else if (type == WebApplicationType.REACTIVE) { if (contextType == AnnotationConfigReactiveWebApplicationContext.class || contextType == null) { application.setApplicationContextClass(ReactiveWebServerApplicationContext.class); } } else if (type == WebApplicationType.SERVLET) { if (contextType == AnnotationConfigServletWebServerApplicationContext.class || contextType == null) { application.setApplicationContextClass(ServletWebServerApplicationContext.class); } } } }
Example 4
Source File: SpringBootProxyHandlerBuilder.java From aws-serverless-java-container with Apache License 2.0 | 4 votes |
public SpringBootProxyHandlerBuilder<RequestType> servletApplication() { this.applicationType = WebApplicationType.SERVLET; return self(); }