Make @IntegrationConverter Native compatible (#3551)

* Make `@IntegrationConverter` Native compatible

* Add `BASE_PACKAGE` into an `IntegrationContextUtils`;
deprecate similar in the `IntegrationConfigUtils`.
This fixes a package tangle between `config` and `context`
* Move `ConverterRegistrar` and `CustomConversionServiceFactoryBean`
into a `config` package since they are package protected and
created their instances in the `IntegrationConverterInitializer`
functional way instead of reflection
* Use new `IntegrationContextUtils.BASE_PACKAGE` constant instead of
deprecated one
* Make `DefaultConfiguringBeanFactoryPostProcessor` `public` to
make it available for Spring Native `trigger` option in the `@NativeHint`
declaration
* Simplify logic around `JsonPath` to just a `ClassUtils.isPresent()`
* Move the `@IntegrationConverter` processing logic into the `ConverterRegistrar`
to avoid reflection via `BeanDefinition` ctor arg manipulation
* Move the reflection logic into a `ConverterParser` which, being a part of XML
configuration, is not going to be compatible with native any way
* Mark `JsonNodeWrapperToJsonNodeConverter` with an `@IntegrationConverter`
since it is not registered via reflection any more
* Expose `MicrometerMetricsCaptorRegistrar.METER_REGISTRY_PRESENT` and use
it in the `IntegrationGraphServer`
* Extract `UnmarshallingTransformer.MIME_MESSAGE_PRESENT` for less
reflection at runtime
* Use `null` for a `ClassLoader` arg in the `ClassUtils.isPresent()`
relying on the default one internally

* * Fix Checkstyle violations
This commit is contained in:
Artem Bilan
2021-04-21 11:01:05 -04:00
committed by GitHub
parent fc941e6a19
commit 3c541c52b4
24 changed files with 193 additions and 197 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2013-2019 the original author or authors.
* Copyright 2013-2021 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.
@@ -45,8 +45,7 @@ public final class HttpContextUtils {
* e.g. {@code IntegrationGraphController}.
*/
public static final boolean WEB_MVC_PRESENT =
ClassUtils.isPresent("org.springframework.web.servlet.DispatcherServlet",
HttpContextUtils.class.getClassLoader());
ClassUtils.isPresent("org.springframework.web.servlet.DispatcherServlet", null);
/**
* A {@code boolean} flag to indicate if the
@@ -55,8 +54,7 @@ public final class HttpContextUtils {
* e.g. {@code IntegrationGraphController}.
*/
public static final boolean WEB_FLUX_PRESENT =
ClassUtils.isPresent("org.springframework.web.reactive.DispatcherHandler",
HttpContextUtils.class.getClassLoader());
ClassUtils.isPresent("org.springframework.web.reactive.DispatcherHandler", null);
/**
* The name for the infrastructure
@@ -89,6 +87,7 @@ public final class HttpContextUtils {
*/
public static RequestMapping convertRequestMappingToAnnotation(
org.springframework.integration.http.inbound.RequestMapping requestMapping) {
if (ObjectUtils.isEmpty(requestMapping.getPathPatterns())) {
return null;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2017-2020 the original author or authors.
* Copyright 2017-2021 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.
@@ -56,13 +56,9 @@ import org.springframework.validation.Validator;
*/
public class BaseHttpInboundEndpoint extends MessagingGatewaySupport implements OrderlyShutdownCapable {
protected static final boolean JAXB_PRESENT =
ClassUtils.isPresent("javax.xml.bind.Binder",
BaseHttpInboundEndpoint.class.getClassLoader());
protected static final boolean JAXB_PRESENT = ClassUtils.isPresent("javax.xml.bind.Binder", null);
protected static final boolean ROME_TOOLS_PRESENT =
ClassUtils.isPresent("com.rometools.rome.feed.atom.Feed",
BaseHttpInboundEndpoint.class.getClassLoader());
protected static final boolean ROME_TOOLS_PRESENT = ClassUtils.isPresent("com.rometools.rome.feed.atom.Feed", null);
protected static final List<HttpMethod> NON_READABLE_BODY_HTTP_METHODS =
Arrays.asList(HttpMethod.GET, HttpMethod.HEAD, HttpMethod.OPTIONS);