GH-3502: More refactoring to avoid reflection (#3532)

* GH-3502: More refactoring to avoid reflection

Fixes https://github.com/spring-projects/spring-integration/issues/3502

* Move `ChannelInitializer` bean registration into an `AbstractIntegrationNamespaceHandler` -
it was never used for annotations and Java DSL...
* Rework `IntegrationFlows.fromSupplier()` to call a provided `Supplier` directly -
not via reflection in the `MethodInvokingMessageSource`
* Resolve new Sonar smells
* Rework `EndpointSpec` to accept an expected factory bean instance via ctor arg
instead of reflection
* Rework `Jackson2JsonObjectMapper` to use well-known module instances directly -
not via reflection from their class names

* * Revert `DefaultMethodInvokingMethodInterceptor.methodHandleCache` property definition wrap
This commit is contained in:
Artem Bilan
2021-04-06 10:06:07 -04:00
committed by GitHub
parent 27e1f3a636
commit 3f0c57894b
21 changed files with 372 additions and 308 deletions

View File

@@ -14,10 +14,6 @@
<message-history tracked-components="publishedChannel,input,annotationTestService*"/>
<annotation-config>
<enable-publisher default-publisher-channel="publishedChannel" proxy-target-class="true" order="2147483646"/>
</annotation-config>
<channel-interceptor pattern="none">
<wire-tap channel="bar" />
</channel-interceptor>

View File

@@ -554,11 +554,11 @@ public class EnableIntegrationTests {
@Test
public void testIntegrationConverter() {
this.numberChannel.send(new GenericMessage<Integer>(10));
this.numberChannel.send(new GenericMessage<Boolean>(true));
this.numberChannel.send(new GenericMessage<>(10));
this.numberChannel.send(new GenericMessage<>(true));
assertThat(this.testConverter.getInvoked()).isGreaterThan(0);
assertThat(this.bytesChannel.send(new GenericMessage<byte[]>("foo".getBytes()))).isTrue();
assertThat(this.bytesChannel.send(new GenericMessage<>("foo".getBytes()))).isTrue();
assertThat(this.bytesChannel.send(new GenericMessage<>(MutableMessageBuilder.withPayload("").build())))
.isTrue();
@@ -1046,7 +1046,7 @@ public class EnableIntegrationTests {
@EnableIntegration
@ImportResource("classpath:org/springframework/integration/configuration/EnableIntegrationTests-context.xml")
@EnableMessageHistory("${message.history.tracked.components}")
@EnablePublisher(defaultChannel = "publishedChannel")
@EnablePublisher(defaultChannel = "publishedChannel", proxyTargetClass = true, order = 2147483646)
@EnableAsync
public static class ContextConfiguration2 {
@@ -1069,7 +1069,7 @@ public class EnableIntegrationTests {
@Bean
public AtomicReference<Thread> asyncAnnotationProcessThread() {
return new AtomicReference<Thread>();
return new AtomicReference<>();
}
@Bean