mirror of
https://github.com/spring-projects/spring-framework
synced 2026-06-08 17:33:33 +00:00
+2
@@ -31,6 +31,7 @@ public class AotBeanProcessingException extends AotProcessingException {
|
||||
|
||||
private final RootBeanDefinition beanDefinition;
|
||||
|
||||
|
||||
/**
|
||||
* Create an instance with the {@link RegisteredBean} that fails to be
|
||||
* processed, a detail message, and an optional root cause.
|
||||
@@ -64,6 +65,7 @@ public class AotBeanProcessingException extends AotProcessingException {
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the bean definition of the bean that failed to be processed.
|
||||
*/
|
||||
|
||||
+2
-5
@@ -885,16 +885,13 @@ public class CommonAnnotationBeanPostProcessor extends InitDestroyAnnotationBean
|
||||
});
|
||||
GeneratedMethod generateMethod = generatedClass.getMethods().add("apply", method -> {
|
||||
method.addJavadoc("Apply resource autowiring.");
|
||||
method.addModifiers(javax.lang.model.element.Modifier.PUBLIC,
|
||||
javax.lang.model.element.Modifier.STATIC);
|
||||
method.addModifiers(javax.lang.model.element.Modifier.PUBLIC, javax.lang.model.element.Modifier.STATIC);
|
||||
method.addParameter(RegisteredBean.class, REGISTERED_BEAN_PARAMETER);
|
||||
method.addParameter(this.target, INSTANCE_PARAMETER);
|
||||
method.returns(this.target);
|
||||
method.addCode(generateMethodCode(generatedClass.getName(),
|
||||
generationContext.getRuntimeHints()));
|
||||
method.addCode(generateMethodCode(generatedClass.getName(), generationContext.getRuntimeHints()));
|
||||
});
|
||||
beanRegistrationCode.addInstancePostProcessor(generateMethod.toMethodReference());
|
||||
|
||||
registerHints(generationContext.getRuntimeHints());
|
||||
}
|
||||
|
||||
|
||||
+4
-7
@@ -856,12 +856,11 @@ public class PersistenceAnnotationBeanPostProcessor implements InstantiationAwar
|
||||
return CodeBlock.of("$L($L)", generatedMethod.getName(), REGISTERED_BEAN_PARAMETER);
|
||||
}
|
||||
|
||||
@SuppressWarnings("NullAway")
|
||||
private void generateGetEntityManagerMethod(MethodSpec.Builder method, PersistenceElement injectedElement) {
|
||||
String unitName = injectedElement.unitName;
|
||||
Properties properties = injectedElement.properties;
|
||||
method.addJavadoc("Get the '$L' {@link $T}.",
|
||||
(StringUtils.hasLength(unitName)) ? unitName : "default",
|
||||
(StringUtils.hasLength(unitName) ? unitName : "default"),
|
||||
EntityManager.class);
|
||||
method.addModifiers(javax.lang.model.element.Modifier.PUBLIC,
|
||||
javax.lang.model.element.Modifier.STATIC);
|
||||
@@ -871,10 +870,8 @@ public class PersistenceAnnotationBeanPostProcessor implements InstantiationAwar
|
||||
"$T entityManagerFactory = $T.findEntityManagerFactory(($T) $L.getBeanFactory(), $S)",
|
||||
EntityManagerFactory.class, EntityManagerFactoryUtils.class,
|
||||
ListableBeanFactory.class, REGISTERED_BEAN_PARAMETER, unitName);
|
||||
boolean hasProperties = !CollectionUtils.isEmpty(properties);
|
||||
if (hasProperties) {
|
||||
method.addStatement("$T properties = new Properties()",
|
||||
Properties.class);
|
||||
if (properties != null) {
|
||||
method.addStatement("$T properties = new Properties()", Properties.class);
|
||||
for (String propertyName : new TreeSet<>(properties.stringPropertyNames())) {
|
||||
method.addStatement("properties.put($S, $S)", propertyName, properties.getProperty(propertyName));
|
||||
}
|
||||
@@ -882,7 +879,7 @@ public class PersistenceAnnotationBeanPostProcessor implements InstantiationAwar
|
||||
method.addStatement(
|
||||
"return $T.createSharedEntityManager(entityManagerFactory, $L, $L)",
|
||||
SharedEntityManagerCreator.class,
|
||||
(hasProperties) ? "properties" : null,
|
||||
(properties != null ? "properties" : null),
|
||||
injectedElement.synchronizedWithTransaction);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user