Polish hint API calls
This commit is contained in:
parent
01c68a3dc8
commit
44f1949c5e
|
@ -86,7 +86,7 @@ public class CloudFoundryWebEndpointDiscoverer extends WebEndpointDiscoverer {
|
|||
@Override
|
||||
public void registerHints(RuntimeHints hints, ClassLoader classLoader) {
|
||||
hints.reflection().registerType(CloudFoundryEndpointFilter.class,
|
||||
(hint) -> hint.withMembers(MemberCategory.INVOKE_DECLARED_CONSTRUCTORS));
|
||||
MemberCategory.INVOKE_DECLARED_CONSTRUCTORS);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -79,8 +79,7 @@ public class JmxEndpointDiscoverer extends EndpointDiscoverer<ExposableJmxEndpoi
|
|||
|
||||
@Override
|
||||
public void registerHints(RuntimeHints hints, ClassLoader classLoader) {
|
||||
hints.reflection().registerType(JmxEndpointFilter.class,
|
||||
(hint) -> hint.withMembers(MemberCategory.INVOKE_DECLARED_CONSTRUCTORS));
|
||||
hints.reflection().registerType(JmxEndpointFilter.class, MemberCategory.INVOKE_DECLARED_CONSTRUCTORS);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -91,7 +91,7 @@ public class ControllerEndpointDiscoverer extends EndpointDiscoverer<ExposableCo
|
|||
@Override
|
||||
public void registerHints(RuntimeHints hints, ClassLoader classLoader) {
|
||||
hints.reflection().registerType(ControllerEndpointFilter.class,
|
||||
(hint) -> hint.withMembers(MemberCategory.INVOKE_DECLARED_CONSTRUCTORS));
|
||||
MemberCategory.INVOKE_DECLARED_CONSTRUCTORS);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -89,8 +89,7 @@ public class ServletEndpointDiscoverer extends EndpointDiscoverer<ExposableServl
|
|||
|
||||
@Override
|
||||
public void registerHints(RuntimeHints hints, ClassLoader classLoader) {
|
||||
hints.reflection().registerType(ServletEndpointFilter.class,
|
||||
(hint) -> hint.withMembers(MemberCategory.INVOKE_DECLARED_CONSTRUCTORS));
|
||||
hints.reflection().registerType(ServletEndpointFilter.class, MemberCategory.INVOKE_DECLARED_CONSTRUCTORS);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -97,8 +97,7 @@ public class WebEndpointDiscoverer extends EndpointDiscoverer<ExposableWebEndpoi
|
|||
|
||||
@Override
|
||||
public void registerHints(RuntimeHints hints, ClassLoader classLoader) {
|
||||
hints.reflection().registerType(WebEndpointFilter.class,
|
||||
(hint) -> hint.withMembers(MemberCategory.INVOKE_DECLARED_CONSTRUCTORS));
|
||||
hints.reflection().registerType(WebEndpointFilter.class, MemberCategory.INVOKE_DECLARED_CONSTRUCTORS);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -106,9 +106,9 @@ public class StartupEndpoint {
|
|||
|
||||
@Override
|
||||
public void registerHints(RuntimeHints hints, ClassLoader classLoader) {
|
||||
hints.reflection().registerType(DEFAULT_TAG, (hint) -> hint.onReachableType(BUFFERED_STARTUP_STEP)
|
||||
hints.reflection().registerType(DEFAULT_TAG, (typeHint) -> typeHint.onReachableType(BUFFERED_STARTUP_STEP)
|
||||
.withMembers(MemberCategory.INVOKE_PUBLIC_METHODS));
|
||||
hints.reflection().registerType(FLIGHT_RECORDER_TAG, (hint) -> hint
|
||||
hints.reflection().registerType(FLIGHT_RECORDER_TAG, (typeHint) -> typeHint
|
||||
.onReachableType(FLIGHT_RECORDER_STARTUP_STEP).withMembers(MemberCategory.INVOKE_PUBLIC_METHODS));
|
||||
}
|
||||
|
||||
|
|
|
@ -153,10 +153,9 @@ public class AotProcessor {
|
|||
TypeReference generatedType = TypeReference.of(generatedInitializerClassName.canonicalName());
|
||||
TypeReference applicationType = TypeReference.of(this.application);
|
||||
ReflectionHints reflection = generationContext.getRuntimeHints().reflection();
|
||||
reflection.registerType(applicationType, (hint) -> {
|
||||
});
|
||||
reflection.registerType(applicationType);
|
||||
reflection.registerType(generatedType,
|
||||
(hint) -> hint.onReachableType(applicationType).withConstructor(Collections.emptyList()));
|
||||
(typeHint) -> typeHint.onReachableType(applicationType).withConstructor(Collections.emptyList()));
|
||||
}
|
||||
|
||||
private Path getRoot(Kind kind) {
|
||||
|
|
|
@ -84,8 +84,7 @@ public enum WebApplicationType {
|
|||
|
||||
private void registerTypeIfPresent(String typeName, ClassLoader classLoader, RuntimeHints hints) {
|
||||
if (ClassUtils.isPresent(typeName, classLoader)) {
|
||||
hints.reflection().registerType(TypeReference.of(typeName), (hint) -> {
|
||||
});
|
||||
hints.reflection().registerType(TypeReference.of(typeName));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ class PropertySourceRuntimeHints implements RuntimeHintsRegistrar {
|
|||
@Override
|
||||
public void registerHints(RuntimeHints hints, ClassLoader classLoader) {
|
||||
hints.reflection().registerTypeIfPresent(classLoader, "org.yaml.snakeyaml.Yaml",
|
||||
(hint) -> hint.onReachableType(TypeReference.of(YamlPropertySourceLoader.class)));
|
||||
(typeHint) -> typeHint.onReachableType(TypeReference.of(YamlPropertySourceLoader.class)));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -16,8 +16,6 @@
|
|||
|
||||
package org.springframework.boot.json;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import com.fasterxml.jackson.databind.ser.std.ClassSerializer;
|
||||
import com.fasterxml.jackson.databind.ser.std.FileSerializer;
|
||||
import com.fasterxml.jackson.databind.ser.std.StdJdkSerializers.AtomicBooleanSerializer;
|
||||
|
@ -29,7 +27,7 @@ import org.springframework.aot.hint.MemberCategory;
|
|||
import org.springframework.aot.hint.ReflectionHints;
|
||||
import org.springframework.aot.hint.RuntimeHints;
|
||||
import org.springframework.aot.hint.RuntimeHintsRegistrar;
|
||||
import org.springframework.aot.hint.TypeHint.Builder;
|
||||
import org.springframework.aot.hint.TypeHint;
|
||||
import org.springframework.aot.hint.TypeReference;
|
||||
import org.springframework.util.ClassUtils;
|
||||
|
||||
|
@ -40,9 +38,6 @@ import org.springframework.util.ClassUtils;
|
|||
*/
|
||||
class JacksonRuntimeHints implements RuntimeHintsRegistrar {
|
||||
|
||||
private static final Consumer<Builder> INVOKE_PUBLIC_CONSTRUCTORS = (hint) -> hint
|
||||
.withMembers(MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS);
|
||||
|
||||
@Override
|
||||
public void registerHints(RuntimeHints hints, ClassLoader classLoader) {
|
||||
if (!ClassUtils.isPresent("com.fasterxml.jackson.databind.ser.BasicSerializerFactory", classLoader)) {
|
||||
|
@ -54,7 +49,7 @@ class JacksonRuntimeHints implements RuntimeHintsRegistrar {
|
|||
private void registerSerializers(ReflectionHints hints) {
|
||||
hints.registerTypes(TypeReference.listOf(AtomicBooleanSerializer.class, AtomicIntegerSerializer.class,
|
||||
AtomicLongSerializer.class, FileSerializer.class, ClassSerializer.class, TokenBufferSerializer.class),
|
||||
INVOKE_PUBLIC_CONSTRUCTORS);
|
||||
TypeHint.builtWith(MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -16,8 +16,6 @@
|
|||
|
||||
package org.springframework.boot.logging.logback;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import ch.qos.logback.classic.LoggerContext;
|
||||
import ch.qos.logback.classic.pattern.SyslogStartConverter;
|
||||
import ch.qos.logback.core.rolling.helper.DateTokenConverter;
|
||||
|
@ -27,7 +25,6 @@ import org.springframework.aot.hint.MemberCategory;
|
|||
import org.springframework.aot.hint.ReflectionHints;
|
||||
import org.springframework.aot.hint.RuntimeHints;
|
||||
import org.springframework.aot.hint.RuntimeHintsRegistrar;
|
||||
import org.springframework.aot.hint.TypeHint.Builder;
|
||||
import org.springframework.aot.hint.TypeReference;
|
||||
import org.springframework.util.ClassUtils;
|
||||
|
||||
|
@ -38,9 +35,6 @@ import org.springframework.util.ClassUtils;
|
|||
*/
|
||||
class LogbackRuntimeHints implements RuntimeHintsRegistrar {
|
||||
|
||||
private static final Consumer<Builder> DEFAULT_HINT = (hint) -> {
|
||||
};
|
||||
|
||||
@Override
|
||||
public void registerHints(RuntimeHints hints, ClassLoader classLoader) {
|
||||
if (!ClassUtils.isPresent("ch.qos.logback.classic.LoggerContext", classLoader)) {
|
||||
|
@ -53,8 +47,9 @@ class LogbackRuntimeHints implements RuntimeHintsRegistrar {
|
|||
}
|
||||
|
||||
private void registerHintsForLogbackLoggingSystemTypeChecks(ReflectionHints reflection, ClassLoader classLoader) {
|
||||
reflection.registerType(LoggerContext.class, DEFAULT_HINT);
|
||||
reflection.registerTypeIfPresent(classLoader, "org.slf4j.bridge.SLF4JBridgeHandler", DEFAULT_HINT);
|
||||
reflection.registerType(LoggerContext.class);
|
||||
reflection.registerTypeIfPresent(classLoader, "org.slf4j.bridge.SLF4JBridgeHandler", (typeHint) -> {
|
||||
});
|
||||
}
|
||||
|
||||
private void registerHintsForBuiltInLogbackConverters(ReflectionHints reflection) {
|
||||
|
|
|
@ -61,15 +61,15 @@ public class ClientHttpRequestFactorySupplier implements Supplier<ClientHttpRequ
|
|||
|
||||
static void registerHints(RuntimeHints hints, ClassLoader classLoader, Consumer<Builder> callback) {
|
||||
if (ClassUtils.isPresent(APACHE_HTTP_CLIENT_CLASS, classLoader)) {
|
||||
hints.reflection().registerType(HttpComponentsClientHttpRequestFactory.class,
|
||||
(hint) -> callback.accept(hint.onReachableType(TypeReference.of(APACHE_HTTP_CLIENT_CLASS))));
|
||||
hints.reflection().registerType(HttpComponentsClientHttpRequestFactory.class, (typeHint) -> callback
|
||||
.accept(typeHint.onReachableType(TypeReference.of(APACHE_HTTP_CLIENT_CLASS))));
|
||||
}
|
||||
if (ClassUtils.isPresent(OKHTTP_CLIENT_CLASS, classLoader)) {
|
||||
hints.reflection().registerType(OkHttp3ClientHttpRequestFactory.class,
|
||||
(hint) -> callback.accept(hint.onReachableType(TypeReference.of(OKHTTP_CLIENT_CLASS))));
|
||||
(typeHint) -> callback.accept(typeHint.onReachableType(TypeReference.of(OKHTTP_CLIENT_CLASS))));
|
||||
}
|
||||
hints.reflection().registerType(SimpleClientHttpRequestFactory.class, (hint) -> callback
|
||||
.accept(hint.onReachableType(TypeReference.of(SimpleClientHttpRequestFactory.class))));
|
||||
hints.reflection().registerType(SimpleClientHttpRequestFactory.class, (typeHint) -> callback
|
||||
.accept(typeHint.onReachableType(TypeReference.of(SimpleClientHttpRequestFactory.class))));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue