Polish
This commit is contained in:
parent
9630f853be
commit
c41609d01d
|
@ -16,7 +16,7 @@
|
|||
|
||||
package org.springframework.boot.json;
|
||||
|
||||
import java.util.stream.Stream;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import com.fasterxml.jackson.databind.ser.std.ClassSerializer;
|
||||
import com.fasterxml.jackson.databind.ser.std.FileSerializer;
|
||||
|
@ -29,6 +29,8 @@ 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,6 +40,9 @@ 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)) {
|
||||
|
@ -47,10 +52,9 @@ class JacksonRuntimeHints implements RuntimeHintsRegistrar {
|
|||
}
|
||||
|
||||
private void registerSerializers(ReflectionHints hints) {
|
||||
Stream.of(AtomicBooleanSerializer.class, AtomicIntegerSerializer.class, AtomicLongSerializer.class,
|
||||
FileSerializer.class, ClassSerializer.class, TokenBufferSerializer.class)
|
||||
.forEach((type) -> hints.registerType(type,
|
||||
(hint) -> hint.withMembers(MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS)));
|
||||
hints.registerTypes(TypeReference.listOf(AtomicBooleanSerializer.class, AtomicIntegerSerializer.class,
|
||||
AtomicLongSerializer.class, FileSerializer.class, ClassSerializer.class, TokenBufferSerializer.class),
|
||||
INVOKE_PUBLIC_CONSTRUCTORS);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -17,8 +17,6 @@
|
|||
package org.springframework.boot.logging.logback;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import ch.qos.logback.classic.LoggerContext;
|
||||
import ch.qos.logback.classic.pattern.SyslogStartConverter;
|
||||
|
@ -73,12 +71,8 @@ class LogbackRuntimeHints implements RuntimeHintsRegistrar {
|
|||
}
|
||||
|
||||
private void registerForPublicConstructorInvocation(ReflectionHints reflection, Class<?>... classes) {
|
||||
reflection.registerTypes(typeReferences(classes),
|
||||
reflection.registerTypes(TypeReference.listOf(classes),
|
||||
(hint) -> hint.withMembers(MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS));
|
||||
}
|
||||
|
||||
private Iterable<TypeReference> typeReferences(Class<?>... classes) {
|
||||
return Stream.of(classes).map(TypeReference::of).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue