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 2002-2020 the original author or authors.
* Copyright 2002-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.
@@ -58,17 +58,20 @@ import org.springframework.xml.transform.StringSource;
*/
public class UnmarshallingTransformer extends AbstractPayloadTransformer<Object, Object> {
private static final boolean MIME_MESSAGE_PRESENT =
ClassUtils.isPresent("org.springframework.ws.mime.MimeMessage", null);
private final Unmarshaller unmarshaller;
private volatile SourceFactory sourceFactory = new DomSourceFactory();
private SourceFactory sourceFactory = new DomSourceFactory();
private volatile boolean alwaysUseSourceFactory = false;
private boolean alwaysUseSourceFactory = false;
private MimeMessageUnmarshallerHelper mimeMessageUnmarshallerHelper;
public UnmarshallingTransformer(Unmarshaller unmarshaller) {
this.unmarshaller = unmarshaller;
if (ClassUtils.isPresent("org.springframework.ws.mime.MimeMessage", ClassUtils.getDefaultClassLoader())) {
if (MIME_MESSAGE_PRESENT) {
this.mimeMessageUnmarshallerHelper = new MimeMessageUnmarshallerHelper(unmarshaller);
}
}