Skip to content

Commit

Permalink
Expose more AOT hints
Browse files Browse the repository at this point in the history
* Add `@Reflective` to methods of `Pausable` and `ManageableLifecycle`
to give them access from Control Bus which uses SpEL invocation engine -
reflection, essentially
* Add proxy hint for the `RequestReplyExchanger`, which is used for
`gateway()` definition in Java DSL
  • Loading branch information
artembilan committed Sep 1, 2022
1 parent 5080fc2 commit 8c9662a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@
import org.springframework.core.DecoratingProxy;
import org.springframework.integration.context.IntegrationContextUtils;
import org.springframework.integration.core.GenericSelector;
import org.springframework.integration.core.Pausable;
import org.springframework.integration.dsl.IntegrationFlow;
import org.springframework.integration.gateway.MethodArgsHolder;
import org.springframework.integration.gateway.RequestReplyExchanger;
import org.springframework.integration.handler.AbstractReplyProducingMessageHandler;
import org.springframework.integration.handler.DelayHandler;
import org.springframework.integration.handler.GenericHandler;
Expand All @@ -55,7 +55,6 @@
import org.springframework.integration.store.MessageMetadata;
import org.springframework.integration.support.MutableMessage;
import org.springframework.integration.support.MutableMessageHeaders;
import org.springframework.integration.support.management.ManageableSmartLifecycle;
import org.springframework.integration.transformer.GenericTransformer;
import org.springframework.messaging.MessageHeaders;
import org.springframework.messaging.support.ErrorMessage;
Expand Down Expand Up @@ -83,9 +82,7 @@ public void registerHints(RuntimeHints hints, ClassLoader classLoader) {
IntegrationContextUtils.class,
MethodArgsHolder.class,
AbstractReplyProducingMessageHandler.RequestHandler.class,
ExpressionEvaluatingRoutingSlipRouteStrategy.RequestAndReply.class,
Pausable.class,
ManageableSmartLifecycle.class)
ExpressionEvaluatingRoutingSlipRouteStrategy.RequestAndReply.class)
.forEach(type ->
reflectionHints.registerType(type,
builder -> builder.withMembers(MemberCategory.INVOKE_PUBLIC_METHODS)));
Expand Down Expand Up @@ -137,6 +134,7 @@ public void registerHints(RuntimeHints hints, ClassLoader classLoader) {

ProxyHints proxyHints = hints.proxies();

registerSpringJdkProxy(proxyHints, RequestReplyExchanger.class);
registerSpringJdkProxy(proxyHints, AbstractReplyProducingMessageHandler.RequestHandler.class);
registerSpringJdkProxy(proxyHints, IntegrationFlow.class, SmartLifecycle.class);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package org.springframework.integration.core;

import org.springframework.aot.hint.annotation.Reflective;
import org.springframework.integration.support.management.ManageableLifecycle;
import org.springframework.jmx.export.annotation.ManagedAttribute;
import org.springframework.jmx.export.annotation.ManagedOperation;
Expand All @@ -26,6 +27,8 @@
* messages.
*
* @author Gary Russell
* @author Artem Bilan
*
* @since 5.0.3
*
*/
Expand All @@ -35,12 +38,14 @@ public interface Pausable extends ManageableLifecycle {
* Pause the endpoint.
*/
@ManagedOperation(description = "Pause the component")
@Reflective
void pause();

/**
* Resume the endpoint if paused.
*/
@ManagedOperation(description = "Resume the component")
@Reflective
void resume();

/**
Expand All @@ -49,6 +54,7 @@ public interface Pausable extends ManageableLifecycle {
* @since 5.4
*/
@ManagedAttribute(description = "Is the component paused?")
@Reflective
default boolean isPaused() {
throw new UnsupportedOperationException("This component does not implement this method");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package org.springframework.integration.support.management;

import org.springframework.aot.hint.annotation.Reflective;
import org.springframework.context.Lifecycle;
import org.springframework.jmx.export.annotation.ManagedAttribute;
import org.springframework.jmx.export.annotation.ManagedOperation;
Expand All @@ -24,20 +25,25 @@
* Makes {@link Lifecycle} methods manageable.
*
* @author Gary Russell
* @author Artem Bilan
*
* @since 5.4
*
*/
public interface ManageableLifecycle extends Lifecycle {

@ManagedOperation(description = "Start the component")
@Reflective
@Override
void start();

@ManagedOperation(description = "Stop the component")
@Reflective
@Override
void stop();

@ManagedAttribute(description = "Is the component running?")
@Reflective
@Override
boolean isRunning();

Expand Down

0 comments on commit 8c9662a

Please sign in to comment.