GH-2358: Register IntGraphController for WebFlux
Fixes https://github.com/spring-projects/spring-integration/issues/2358 The WebFlux on the server side can deal with MVC `@Controllers` as well without any Servlet environment. * Enable `IntegrationGraphController` when we not only in the Servlet environment, but also in the WebFlux * Upgrade to SF-5.0.4 and fix WebFlux tests to meet the latest requirements (https://jira.spring.io/browse/SPR-16337) * Move `WEB_FLUX_PRESENT` to the `HttpContextUtils`; deprecate it in the `WebFluxContextUtils` * Mention WebFlux ability for the `IntegrationGraphController` in the `graph.adoc`
This commit is contained in:
committed by
Gary Russell
parent
a4130c9e59
commit
11240be555
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016 the original author or authors.
|
||||
* Copyright 2016-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -28,13 +28,15 @@ import org.springframework.integration.http.management.IntegrationGraphControlle
|
||||
import org.springframework.integration.http.support.HttpContextUtils;
|
||||
|
||||
/**
|
||||
* Enables the {@link IntegrationGraphController} if {@code DispatcherServlet} is present in the classpath.
|
||||
* Enables the {@link IntegrationGraphController} if
|
||||
* {@code org.springframework.web.servlet.DispatcherServlet} or
|
||||
* {@code org.springframework.web.reactive.DispatcherHandler} is present in the classpath.
|
||||
*
|
||||
* @author Artem Bilan
|
||||
*
|
||||
* @since 4.3
|
||||
*
|
||||
* @see IntegrationGraphController
|
||||
* @see IntegrationGraphController
|
||||
*/
|
||||
@Target(ElementType.TYPE)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@@ -64,6 +66,6 @@ public @interface EnableIntegrationGraphController {
|
||||
* @return the URLs.
|
||||
* @since 4.3.5
|
||||
*/
|
||||
String[] allowedOrigins() default {};
|
||||
String[] allowedOrigins() default { };
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016-2017 the original author or authors.
|
||||
* Copyright 2016-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -34,12 +34,13 @@ class IntegrationGraphControllerRegistrarImportSelector implements ImportSelecto
|
||||
|
||||
@Override
|
||||
public String[] selectImports(AnnotationMetadata importingClassMetadata) {
|
||||
if (HttpContextUtils.WEB_MVC_PRESENT) {
|
||||
if (HttpContextUtils.WEB_MVC_PRESENT || HttpContextUtils.WEB_FLUX_PRESENT) {
|
||||
return new String[] { IntegrationGraphControllerRegistrar.class.getName() };
|
||||
}
|
||||
else {
|
||||
logger.warn("The 'IntegrationGraphController' isn't registered with the application context because" +
|
||||
" there is no 'org.springframework.web.servlet.DispatcherServlet' in the classpath.");
|
||||
" there is no 'org.springframework.web.servlet.DispatcherServlet' or" +
|
||||
" 'org.springframework.web.reactive.DispatcherHandler' in the classpath.");
|
||||
return new String[0];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2017 the original author or authors.
|
||||
* Copyright 2013-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -39,15 +39,25 @@ public final class HttpContextUtils {
|
||||
}
|
||||
|
||||
/**
|
||||
* The {@code boolean} flag to indicate if the
|
||||
* {@code org.springframework.web.servlet.DispatcherServlet}
|
||||
* is present in the CLASSPATH to allow to register the Integration server components,
|
||||
* A {@code boolean} flag to indicate if the
|
||||
* {@code org.springframework.web.servlet.DispatcherServlet} is present in the
|
||||
* CLASSPATH to allow the registration of Integration server components,
|
||||
* e.g. {@code IntegrationGraphController}.
|
||||
*/
|
||||
public static final boolean WEB_MVC_PRESENT =
|
||||
ClassUtils.isPresent("org.springframework.web.servlet.DispatcherServlet",
|
||||
HttpContextUtils.class.getClassLoader());
|
||||
|
||||
/**
|
||||
* A {@code boolean} flag to indicate if the
|
||||
* {@code org.springframework.web.reactive.DispatcherHandler} is present in the
|
||||
* CLASSPATH to allow the registration of Integration server reactive components,
|
||||
* e.g. {@code IntegrationGraphController}.
|
||||
*/
|
||||
public static final boolean WEB_FLUX_PRESENT =
|
||||
ClassUtils.isPresent("org.springframework.web.reactive.DispatcherHandler",
|
||||
HttpContextUtils.class.getClassLoader());
|
||||
|
||||
/**
|
||||
* The name for the infrastructure
|
||||
* {@link org.springframework.integration.http.inbound.IntegrationRequestMappingHandlerMapping} bean.
|
||||
|
||||
Reference in New Issue
Block a user