Polishing
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -121,16 +121,16 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto
|
||||
implements ConfigurableListableBeanFactory, BeanDefinitionRegistry, Serializable {
|
||||
|
||||
@Nullable
|
||||
private static Class<?> javaxInjectProviderClass;
|
||||
private static Class<?> jakartaInjectProviderClass;
|
||||
|
||||
static {
|
||||
try {
|
||||
javaxInjectProviderClass =
|
||||
jakartaInjectProviderClass =
|
||||
ClassUtils.forName("jakarta.inject.Provider", DefaultListableBeanFactory.class.getClassLoader());
|
||||
}
|
||||
catch (ClassNotFoundException ex) {
|
||||
// JSR-330 API not available - Provider interface simply not supported then.
|
||||
javaxInjectProviderClass = null;
|
||||
jakartaInjectProviderClass = null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1327,7 +1327,7 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto
|
||||
ObjectProvider.class == descriptor.getDependencyType()) {
|
||||
return new DependencyObjectProvider(descriptor, requestingBeanName);
|
||||
}
|
||||
else if (javaxInjectProviderClass == descriptor.getDependencyType()) {
|
||||
else if (jakartaInjectProviderClass == descriptor.getDependencyType()) {
|
||||
return new Jsr330Factory().createDependencyProvider(descriptor, requestingBeanName);
|
||||
}
|
||||
else {
|
||||
@@ -1757,7 +1757,7 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto
|
||||
* Return whether the bean definition for the given bean name has been
|
||||
* marked as a primary bean.
|
||||
* @param beanName the name of the bean
|
||||
* @param beanInstance the corresponding bean instance (can be null)
|
||||
* @param beanInstance the corresponding bean instance (can be {@code null})
|
||||
* @return whether the given bean qualifies as primary
|
||||
*/
|
||||
protected boolean isPrimary(String beanName, Object beanInstance) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -40,7 +40,7 @@ import org.springframework.util.ReflectionUtils;
|
||||
|
||||
/**
|
||||
* Register the necessary reflection hints so that the specified type can be
|
||||
* bound at runtime. Fields, constructors, properties and record components
|
||||
* bound at runtime. Fields, constructors, properties, and record components
|
||||
* are registered, except for a set of types like those in the {@code java.}
|
||||
* package where just the type is registered. Types are discovered transitively
|
||||
* on properties and record components, and generic types are registered as well.
|
||||
@@ -54,8 +54,9 @@ public class BindingReflectionHintsRegistrar {
|
||||
|
||||
private static final String JACKSON_ANNOTATION = "com.fasterxml.jackson.annotation.JacksonAnnotation";
|
||||
|
||||
private static final boolean jacksonAnnotationPresent = ClassUtils.isPresent(JACKSON_ANNOTATION,
|
||||
BindingReflectionHintsRegistrar.class.getClassLoader());
|
||||
private static final boolean jacksonAnnotationPresent =
|
||||
ClassUtils.isPresent(JACKSON_ANNOTATION, BindingReflectionHintsRegistrar.class.getClassLoader());
|
||||
|
||||
|
||||
/**
|
||||
* Register the necessary reflection hints to bind the specified types.
|
||||
@@ -94,8 +95,7 @@ public class BindingReflectionHintsRegistrar {
|
||||
registerRecordHints(hints, seen, recordComponent.getAccessor());
|
||||
}
|
||||
}
|
||||
typeHint.withMembers(
|
||||
MemberCategory.DECLARED_FIELDS,
|
||||
typeHint.withMembers(MemberCategory.DECLARED_FIELDS,
|
||||
MemberCategory.INVOKE_DECLARED_CONSTRUCTORS);
|
||||
for (Method method : clazz.getMethods()) {
|
||||
String methodName = method.getName();
|
||||
@@ -132,8 +132,7 @@ public class BindingReflectionHintsRegistrar {
|
||||
}
|
||||
|
||||
private void registerPropertyHints(ReflectionHints hints, Set<Type> seen, @Nullable Method method, int parameterIndex) {
|
||||
if (method != null && method.getDeclaringClass() != Object.class &&
|
||||
method.getDeclaringClass() != Enum.class) {
|
||||
if (method != null && method.getDeclaringClass() != Object.class && method.getDeclaringClass() != Enum.class) {
|
||||
hints.registerMethod(method, ExecutableMode.INVOKE);
|
||||
MethodParameter methodParameter = MethodParameter.forExecutable(method, parameterIndex);
|
||||
Type methodParameterType = methodParameter.getGenericParameterType();
|
||||
@@ -191,13 +190,13 @@ public class BindingReflectionHintsRegistrar {
|
||||
.from(element, MergedAnnotations.SearchStrategy.TYPE_HIERARCHY)
|
||||
.stream(JACKSON_ANNOTATION)
|
||||
.filter(MergedAnnotation::isMetaPresent)
|
||||
.forEach(action::accept);
|
||||
.forEach(action);
|
||||
}
|
||||
|
||||
private void registerHintsForClassAttributes(ReflectionHints hints, MergedAnnotation<Annotation> annotation) {
|
||||
annotation.getRoot().asMap().forEach((key,value) -> {
|
||||
annotation.getRoot().asMap().forEach((attributeName, value) -> {
|
||||
if (value instanceof Class<?> classValue && value != Void.class) {
|
||||
if (key.equals("builder")) {
|
||||
if (attributeName.equals("builder")) {
|
||||
hints.registerType(classValue, MemberCategory.INVOKE_DECLARED_CONSTRUCTORS,
|
||||
MemberCategory.INVOKE_DECLARED_METHODS);
|
||||
}
|
||||
@@ -208,6 +207,7 @@ public class BindingReflectionHintsRegistrar {
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Inner class to avoid a hard dependency on Kotlin at runtime.
|
||||
*/
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -393,7 +393,7 @@ public class CacheControl {
|
||||
}
|
||||
|
||||
private void appendDirective(StringBuilder builder, String value) {
|
||||
if (builder.length() > 0) {
|
||||
if (!builder.isEmpty()) {
|
||||
builder.append(", ");
|
||||
}
|
||||
builder.append(value);
|
||||
|
||||
Reference in New Issue
Block a user