Java Code Examples for org.springframework.boot.WebApplicationType#REACTIVE

The following examples show how to use org.springframework.boot.WebApplicationType#REACTIVE . 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 vote down vote up
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 2
Source File: FunctionEndpointInitializer.java    From spring-cloud-function with Apache License 2.0 5 votes vote down vote up
@Override
public void initialize(GenericApplicationContext context) {
	if (ContextFunctionCatalogInitializer.enabled
			&& context.getEnvironment().getProperty(FunctionalSpringApplication.SPRING_WEB_APPLICATION_TYPE,
					WebApplicationType.class, WebApplicationType.REACTIVE) == WebApplicationType.REACTIVE
			&& context.getEnvironment().getProperty("spring.functional.enabled", Boolean.class, false)
			&& ClassUtils.isPresent("org.springframework.http.server.reactive.HttpHandler", null)) {
		registerEndpoint(context);
		registerWebFluxAutoConfiguration(context);
	}
}
 
Example 3
Source File: FunctionalInstallerListener.java    From spring-init with Apache License 2.0 4 votes vote down vote up
@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);
			}
		}
	}
}