Skip to content

Commit 18a87ea

Browse files
committed
Register Lifecycle methods for AbstractEndpoint
* Also register `Pausable` explicitly and remove its `@Reflective`. This type is needed for Control Bus SpEL execution, but it might not be available at runtime because not all endpoints implement it
1 parent 264cc3c commit 18a87ea

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

spring-integration-core/src/main/java/org/springframework/integration/aot/CoreRuntimeHints.java

+10-5
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import java.util.stream.Stream;
2828

2929
import org.springframework.aop.framework.AopProxyUtils;
30+
import org.springframework.aot.hint.ExecutableMode;
3031
import org.springframework.aot.hint.MemberCategory;
3132
import org.springframework.aot.hint.ProxyHints;
3233
import org.springframework.aot.hint.ReflectionHints;
@@ -35,7 +36,6 @@
3536
import org.springframework.aot.hint.SerializationHints;
3637
import org.springframework.aot.hint.TypeReference;
3738
import org.springframework.beans.factory.config.BeanExpressionContext;
38-
import org.springframework.context.Lifecycle;
3939
import org.springframework.context.SmartLifecycle;
4040
import org.springframework.integration.aggregator.MessageGroupProcessor;
4141
import org.springframework.integration.context.IntegrationContextUtils;
@@ -44,7 +44,9 @@
4444
import org.springframework.integration.core.GenericSelector;
4545
import org.springframework.integration.core.GenericTransformer;
4646
import org.springframework.integration.core.MessageSource;
47+
import org.springframework.integration.core.Pausable;
4748
import org.springframework.integration.dsl.IntegrationFlow;
49+
import org.springframework.integration.endpoint.AbstractEndpoint;
4850
import org.springframework.integration.gateway.MethodArgsHolder;
4951
import org.springframework.integration.gateway.RequestReplyExchanger;
5052
import org.springframework.integration.handler.AbstractReplyProducingMessageHandler;
@@ -63,6 +65,7 @@
6365
import org.springframework.messaging.PollableChannel;
6466
import org.springframework.messaging.support.ErrorMessage;
6567
import org.springframework.messaging.support.GenericMessage;
68+
import org.springframework.util.ReflectionUtils;
6669

6770
/**
6871
* {@link RuntimeHintsRegistrar} for Spring Integration core module.
@@ -88,7 +91,7 @@ public void registerHints(RuntimeHints hints, ClassLoader classLoader) {
8891
MethodArgsHolder.class,
8992
AbstractReplyProducingMessageHandler.RequestHandler.class,
9093
ExpressionEvaluatingRoutingSlipRouteStrategy.RequestAndReply.class,
91-
Lifecycle.class)
94+
Pausable.class)
9295
.forEach(type -> reflectionHints.registerType(type, MemberCategory.INVOKE_PUBLIC_METHODS));
9396

9497
reflectionHints.registerType(JsonPathUtils.class,
@@ -100,12 +103,14 @@ public void registerHints(RuntimeHints hints, ClassLoader classLoader) {
100103
reflectionHints.registerTypeIfPresent(classLoader, "org.springframework.integration.xml.xpath.XPathUtils",
101104
MemberCategory.INVOKE_PUBLIC_METHODS);
102105

103-
Stream.of(
104-
"kotlin.jvm.functions.Function0",
105-
"kotlin.jvm.functions.Function1")
106+
Stream.of("kotlin.jvm.functions.Function0", "kotlin.jvm.functions.Function1")
106107
.forEach(type ->
107108
reflectionHints.registerTypeIfPresent(classLoader, type, MemberCategory.INVOKE_PUBLIC_METHODS));
108109

110+
Stream.of("start", "stop", "isRunning")
111+
.flatMap((name) -> Stream.ofNullable(ReflectionUtils.findMethod(AbstractEndpoint.class, name)))
112+
.forEach(method -> reflectionHints.registerMethod(method, ExecutableMode.INVOKE));
113+
109114
hints.resources().registerPattern("META-INF/spring.integration.properties");
110115

111116
SerializationHints serializationHints = hints.serialization();

spring-integration-core/src/main/java/org/springframework/integration/core/Pausable.java

-4
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
package org.springframework.integration.core;
1818

19-
import org.springframework.aot.hint.annotation.Reflective;
2019
import org.springframework.integration.support.management.ManageableLifecycle;
2120
import org.springframework.jmx.export.annotation.ManagedAttribute;
2221
import org.springframework.jmx.export.annotation.ManagedOperation;
@@ -38,14 +37,12 @@ public interface Pausable extends ManageableLifecycle {
3837
* Pause the endpoint.
3938
*/
4039
@ManagedOperation(description = "Pause the component")
41-
@Reflective
4240
void pause();
4341

4442
/**
4543
* Resume the endpoint if paused.
4644
*/
4745
@ManagedOperation(description = "Resume the component")
48-
@Reflective
4946
void resume();
5047

5148
/**
@@ -54,7 +51,6 @@ public interface Pausable extends ManageableLifecycle {
5451
* @since 5.4
5552
*/
5653
@ManagedAttribute(description = "Is the component paused?")
57-
@Reflective
5854
default boolean isPaused() {
5955
throw new UnsupportedOperationException("This component does not implement this method");
6056
}

0 commit comments

Comments
 (0)