Merge branch '6.1.x'
This commit is contained in:
commit
8cfdaaaabc
|
|
@ -135,8 +135,9 @@ class ScopedProxyBeanRegistrationAotProcessor implements BeanRegistrationAotProc
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CodeBlock generateInstanceSupplierCode(GenerationContext generationContext,
|
public CodeBlock generateInstanceSupplierCode(
|
||||||
BeanRegistrationCode beanRegistrationCode, boolean allowDirectSupplierShortcut) {
|
GenerationContext generationContext, BeanRegistrationCode beanRegistrationCode,
|
||||||
|
boolean allowDirectSupplierShortcut) {
|
||||||
|
|
||||||
GeneratedMethod generatedMethod = beanRegistrationCode.getMethods()
|
GeneratedMethod generatedMethod = beanRegistrationCode.getMethods()
|
||||||
.add("getScopedProxyInstance", method -> {
|
.add("getScopedProxyInstance", method -> {
|
||||||
|
|
|
||||||
|
|
@ -101,8 +101,7 @@ class DefaultBeanRegistrationCodeFragments implements BeanRegistrationCodeFragme
|
||||||
/**
|
/**
|
||||||
* Extract the target class of a public {@link FactoryBean} based on its
|
* Extract the target class of a public {@link FactoryBean} based on its
|
||||||
* constructor. If the implementation does not resolve the target class
|
* constructor. If the implementation does not resolve the target class
|
||||||
* because it itself uses a generic, attempt to extract it from the
|
* because it itself uses a generic, attempt to extract it from the bean type.
|
||||||
* bean type.
|
|
||||||
* @param factoryBeanType the factory bean type
|
* @param factoryBeanType the factory bean type
|
||||||
* @param beanType the bean type
|
* @param beanType the bean type
|
||||||
* @return the target class to use
|
* @return the target class to use
|
||||||
|
|
@ -169,9 +168,11 @@ class DefaultBeanRegistrationCodeFragments implements BeanRegistrationCodeFragme
|
||||||
|
|
||||||
Loader loader = AotServices.factories(this.registeredBean.getBeanFactory().getBeanClassLoader());
|
Loader loader = AotServices.factories(this.registeredBean.getBeanFactory().getBeanClassLoader());
|
||||||
List<Delegate> additionalDelegates = loader.load(Delegate.class).asList();
|
List<Delegate> additionalDelegates = loader.load(Delegate.class).asList();
|
||||||
return new BeanDefinitionPropertiesCodeGenerator(generationContext.getRuntimeHints(),
|
|
||||||
attributeFilter, beanRegistrationCode.getMethods(),
|
return new BeanDefinitionPropertiesCodeGenerator(
|
||||||
additionalDelegates, (name, value) -> generateValueCode(generationContext, name, value))
|
generationContext.getRuntimeHints(), attributeFilter,
|
||||||
|
beanRegistrationCode.getMethods(), additionalDelegates,
|
||||||
|
(name, value) -> generateValueCode(generationContext, name, value))
|
||||||
.generateCode(beanDefinition);
|
.generateCode(beanDefinition);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -230,8 +231,8 @@ class DefaultBeanRegistrationCodeFragments implements BeanRegistrationCodeFragme
|
||||||
if (hasInstanceSupplier()) {
|
if (hasInstanceSupplier()) {
|
||||||
throw new AotBeanProcessingException(this.registeredBean, "instance supplier is not supported");
|
throw new AotBeanProcessingException(this.registeredBean, "instance supplier is not supported");
|
||||||
}
|
}
|
||||||
return new InstanceSupplierCodeGenerator(generationContext, beanRegistrationCode.getClassName(),
|
return new InstanceSupplierCodeGenerator(generationContext,
|
||||||
beanRegistrationCode.getMethods(), allowDirectSupplierShortcut)
|
beanRegistrationCode.getClassName(), beanRegistrationCode.getMethods(), allowDirectSupplierShortcut)
|
||||||
.generateCode(this.registeredBean, this.instantiationDescriptor.get());
|
.generateCode(this.registeredBean, this.instantiationDescriptor.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -761,12 +761,7 @@ public class ConfigurationClassPostProcessor implements BeanDefinitionRegistryPo
|
||||||
}
|
}
|
||||||
|
|
||||||
private CodeBlock handleNull(@Nullable Object value, Supplier<CodeBlock> nonNull) {
|
private CodeBlock handleNull(@Nullable Object value, Supplier<CodeBlock> nonNull) {
|
||||||
if (value == null) {
|
return (value == null ? CodeBlock.of("null") : nonNull.get());
|
||||||
return CodeBlock.of("null");
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return nonNull.get();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -786,9 +781,9 @@ public class ConfigurationClassPostProcessor implements BeanDefinitionRegistryPo
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CodeBlock generateSetBeanDefinitionPropertiesCode(GenerationContext generationContext,
|
public CodeBlock generateSetBeanDefinitionPropertiesCode(
|
||||||
BeanRegistrationCode beanRegistrationCode, RootBeanDefinition beanDefinition,
|
GenerationContext generationContext, BeanRegistrationCode beanRegistrationCode,
|
||||||
Predicate<String> attributeFilter) {
|
RootBeanDefinition beanDefinition, Predicate<String> attributeFilter) {
|
||||||
|
|
||||||
CodeBlock.Builder code = CodeBlock.builder();
|
CodeBlock.Builder code = CodeBlock.builder();
|
||||||
code.add(super.generateSetBeanDefinitionPropertiesCode(generationContext,
|
code.add(super.generateSetBeanDefinitionPropertiesCode(generationContext,
|
||||||
|
|
@ -799,11 +794,13 @@ public class ConfigurationClassPostProcessor implements BeanDefinitionRegistryPo
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CodeBlock generateInstanceSupplierCode(GenerationContext generationContext,
|
public CodeBlock generateInstanceSupplierCode(
|
||||||
BeanRegistrationCode beanRegistrationCode, boolean allowDirectSupplierShortcut) {
|
GenerationContext generationContext, BeanRegistrationCode beanRegistrationCode,
|
||||||
|
boolean allowDirectSupplierShortcut) {
|
||||||
|
|
||||||
InstantiationDescriptor instantiationDescriptor = proxyInstantiationDescriptor(
|
InstantiationDescriptor instantiationDescriptor = proxyInstantiationDescriptor(
|
||||||
generationContext.getRuntimeHints(), this.registeredBean.resolveInstantiationDescriptor());
|
generationContext.getRuntimeHints(), this.registeredBean.resolveInstantiationDescriptor());
|
||||||
|
|
||||||
return new InstanceSupplierCodeGenerator(generationContext,
|
return new InstanceSupplierCodeGenerator(generationContext,
|
||||||
beanRegistrationCode.getClassName(), beanRegistrationCode.getMethods(), allowDirectSupplierShortcut)
|
beanRegistrationCode.getClassName(), beanRegistrationCode.getMethods(), allowDirectSupplierShortcut)
|
||||||
.generateCode(this.registeredBean, instantiationDescriptor);
|
.generateCode(this.registeredBean, instantiationDescriptor);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue