Skip to content

Commit

Permalink
Improve AOT hints code
Browse files Browse the repository at this point in the history
  • Loading branch information
artembilan committed Sep 12, 2022
1 parent 47cfae9 commit e2a5b7d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@
import java.util.function.Supplier;
import java.util.stream.Stream;

import org.springframework.aop.SpringProxy;
import org.springframework.aop.framework.Advised;
import org.springframework.aop.framework.AopProxyUtils;
import org.springframework.aot.hint.MemberCategory;
import org.springframework.aot.hint.ProxyHints;
import org.springframework.aot.hint.ReflectionHints;
Expand All @@ -37,9 +36,9 @@
import org.springframework.aot.hint.TypeReference;
import org.springframework.beans.factory.config.BeanExpressionContext;
import org.springframework.context.SmartLifecycle;
import org.springframework.core.DecoratingProxy;
import org.springframework.integration.aggregator.MessageGroupProcessor;
import org.springframework.integration.context.IntegrationContextUtils;
import org.springframework.integration.context.IntegrationProperties;
import org.springframework.integration.core.GenericSelector;
import org.springframework.integration.core.MessageSource;
import org.springframework.integration.dsl.IntegrationFlow;
Expand Down Expand Up @@ -84,12 +83,11 @@ public void registerHints(RuntimeHints hints, ClassLoader classLoader) {
Supplier.class,
BeanExpressionContext.class,
IntegrationContextUtils.class,
IntegrationProperties.class,
MethodArgsHolder.class,
AbstractReplyProducingMessageHandler.RequestHandler.class,
ExpressionEvaluatingRoutingSlipRouteStrategy.RequestAndReply.class)
.forEach(type ->
reflectionHints.registerType(type,
builder -> builder.withMembers(MemberCategory.INVOKE_PUBLIC_METHODS)));
.forEach(type -> reflectionHints.registerType(type, MemberCategory.INVOKE_PUBLIC_METHODS));

reflectionHints.registerType(JsonPathUtils.class,
builder ->
Expand All @@ -98,15 +96,14 @@ public void registerHints(RuntimeHints hints, ClassLoader classLoader) {

// For #xpath() SpEL function
reflectionHints.registerTypeIfPresent(classLoader, "org.springframework.integration.xml.xpath.XPathUtils",
builder -> builder.withMembers(MemberCategory.INVOKE_PUBLIC_METHODS));
MemberCategory.INVOKE_PUBLIC_METHODS);

Stream.of(
"kotlin.jvm.functions.Function0",
"kotlin.jvm.functions.Function1",
"kotlin.Unit")
.forEach(type ->
reflectionHints.registerTypeIfPresent(classLoader, type,
builder -> builder.withMembers(MemberCategory.INVOKE_PUBLIC_METHODS)));
reflectionHints.registerTypeIfPresent(classLoader, type, MemberCategory.INVOKE_PUBLIC_METHODS));

hints.resources().registerPattern("META-INF/spring.integration.properties");

Expand Down Expand Up @@ -148,10 +145,7 @@ public void registerHints(RuntimeHints hints, ClassLoader classLoader) {
}

private static void registerSpringJdkProxy(ProxyHints proxyHints, Class<?>... proxiedInterfaces) {
proxyHints
.registerJdkProxy(builder ->
builder.proxiedInterfaces(proxiedInterfaces)
.proxiedInterfaces(SpringProxy.class, Advised.class, DecoratingProxy.class));
proxyHints.registerJdkProxy(AopProxyUtils.completeJdkProxyInterfaces(proxiedInterfaces));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ class HttpRuntimeHints implements RuntimeHintsRegistrar {
@Override
public void registerHints(RuntimeHints hints, ClassLoader classLoader) {
ReflectionHints reflectionHints = hints.reflection();
reflectionHints.registerType(WebHandler.class, builder ->
builder.withMembers(MemberCategory.INVOKE_PUBLIC_METHODS));
reflectionHints.registerType(WebHandler.class, MemberCategory.INVOKE_PUBLIC_METHODS);

reflectionHints.registerType(HttpRequestHandler.class, builder ->
builder.onReachableType(TypeReference.of("jakarta.servlet.http.HttpServletRequest"))
Expand Down

0 comments on commit e2a5b7d

Please sign in to comment.