Switch to Spring Framework SNAPSHOTs

Switch to Spring Framework SNAPSHOTs and adapt to updated APIs.

See gh-31834
pull/31845/head
Olga Maciaszek-Sharma 2 years ago committed by Phillip Webb
parent 8f660b32c9
commit 57dc274284

@ -165,16 +165,14 @@ class ChildManagementContextInitializer implements ApplicationListener<WebServer
GenerationContext managementGenerationContext = generationContext.withName("Management");
ClassName generatedInitializerClassName = new ApplicationContextAotGenerator()
.generateApplicationContext(this.managementContext, managementGenerationContext);
GeneratedMethod postProcessorMethod = beanRegistrationCode.getMethodGenerator()
.generateMethod("addManagementInitializer").using((builder) -> {
builder.addJavadoc("Use AOT management context initialization");
builder.addModifiers(Modifier.PRIVATE, Modifier.STATIC);
builder.addParameter(RegisteredBean.class, "registeredBean");
builder.addParameter(ChildManagementContextInitializer.class, "instance");
builder.returns(ChildManagementContextInitializer.class);
builder.addStatement("return instance.withApplicationContextInitializer(new $L())",
generatedInitializerClassName);
});
GeneratedMethod postProcessorMethod = beanRegistrationCode.getMethods().add("addManagementInitializer",
(method) -> method.addJavadoc("Use AOT management context initialization")
.addModifiers(Modifier.PRIVATE, Modifier.STATIC)
.addParameter(RegisteredBean.class, "registeredBean")
.addParameter(ChildManagementContextInitializer.class, "instance")
.returns(ChildManagementContextInitializer.class)
.addStatement("return instance.withApplicationContextInitializer(new $L())",
generatedInitializerClassName));
beanRegistrationCode.addInstancePostProcessor(
MethodReference.ofStatic(beanRegistrationCode.getClassName(), postProcessorMethod.getName()));
}

@ -1414,7 +1414,7 @@ bom {
]
}
}
library("Spring Framework", "6.0.0-M5") {
library("Spring Framework", "6.0.0-SNAPSHOT") {
group("org.springframework") {
imports = [
"spring-framework-bom"

@ -73,21 +73,19 @@ class ConfigurationPropertiesBeanRegistrationAotProcessor implements BeanRegistr
public CodeBlock generateInstanceSupplierCode(GenerationContext generationContext,
BeanRegistrationCode beanRegistrationCode, Executable constructorOrFactoryMethod,
boolean allowDirectSupplierShortcut) {
GeneratedMethod method = beanRegistrationCode.getMethodGenerator().generateMethod("get", "instance")
.using((builder) -> {
Class<?> beanClass = this.registeredBean.getBeanClass();
builder.addJavadoc("Get the bean instance for '$L'.", this.registeredBean.getBeanName());
builder.addModifiers(Modifier.PRIVATE, Modifier.STATIC);
builder.returns(beanClass);
builder.addParameter(RegisteredBean.class, REGISTERED_BEAN_PARAMETER_NAME);
builder.addStatement("$T beanFactory = registeredBean.getBeanFactory()", BeanFactory.class);
builder.addStatement("$T beanName = registeredBean.getBeanName()", String.class);
builder.addStatement("$T<?> beanClass = registeredBean.getBeanClass()", Class.class);
builder.addStatement("return ($T) $T.from(beanFactory, beanName, beanClass)", beanClass,
GeneratedMethod generatedMethod = beanRegistrationCode.getMethods().add("getInstance", (method) -> {
Class<?> beanClass = this.registeredBean.getBeanClass();
method.addJavadoc("Get the bean instance for '$L'.", this.registeredBean.getBeanName())
.addModifiers(Modifier.PRIVATE, Modifier.STATIC).returns(beanClass)
.addParameter(RegisteredBean.class, REGISTERED_BEAN_PARAMETER_NAME)
.addStatement("$T beanFactory = registeredBean.getBeanFactory()", BeanFactory.class)
.addStatement("$T beanName = registeredBean.getBeanName()", String.class)
.addStatement("$T<?> beanClass = registeredBean.getBeanClass()", Class.class)
.addStatement("return ($T) $T.from(beanFactory, beanName, beanClass)", beanClass,
ConstructorBound.class);
});
});
return CodeBlock.of("$T.of($T::$L)", InstanceSupplier.class, beanRegistrationCode.getClassName(),
method.getName());
generatedMethod.getName());
}
}

Loading…
Cancel
Save