Skip to content

Commit 585b4e0

Browse files
committed
Merge branch '6.2.x'
# Conflicts: # framework-platform/framework-platform.gradle # spring-orm/src/main/java/org/springframework/orm/jpa/persistenceunit/PersistenceManagedTypesBeanRegistrationAotProcessor.java # spring-orm/src/test/java/org/springframework/orm/jpa/persistenceunit/PersistenceManagedTypesBeanRegistrationAotProcessorTests.java
2 parents e5fccd1 + 2060c34 commit 585b4e0

File tree

6 files changed

+76
-61
lines changed

6 files changed

+76
-61
lines changed

framework-platform/framework-platform.gradle

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ dependencies {
2626
constraints {
2727
api("com.fasterxml:aalto-xml:1.3.4")
2828
api("com.fasterxml.woodstox:woodstox-core:6.7.0")
29-
api("com.github.ben-manes.caffeine:caffeine:3.2.2")
29+
api("com.github.ben-manes.caffeine:caffeine:3.2.3")
3030
api("com.github.librepdf:openpdf:1.3.43")
3131
api("com.google.code.findbugs:findbugs:3.0.1")
3232
api("com.google.code.findbugs:jsr305:3.0.2")
@@ -124,7 +124,7 @@ dependencies {
124124
api("org.hibernate.orm:hibernate-core:7.2.0.CR1")
125125
api("org.hibernate.validator:hibernate-validator:9.1.0.CR1")
126126
api("org.hsqldb:hsqldb:2.7.4")
127-
api("org.htmlunit:htmlunit:4.17.0")
127+
api("org.htmlunit:htmlunit:4.18.0")
128128
api("org.javamoney:moneta:1.4.4")
129129
api("org.jboss.logging:jboss-logging:3.6.1.Final")
130130
api("org.jruby:jruby:10.0.2.0")
@@ -135,8 +135,8 @@ dependencies {
135135
api("org.python:jython-standalone:2.7.4")
136136
api("org.quartz-scheduler:quartz:2.3.2")
137137
api("org.reactivestreams:reactive-streams:1.0.4")
138-
api("org.seleniumhq.selenium:htmlunit3-driver:4.36.1")
139-
api("org.seleniumhq.selenium:selenium-java:4.36.0")
138+
api("org.seleniumhq.selenium:htmlunit3-driver:4.38.0")
139+
api("org.seleniumhq.selenium:selenium-java:4.38.0")
140140
api("org.skyscreamer:jsonassert:1.5.3")
141141
api("org.testng:testng:7.11.0")
142142
api("org.webjars:underscorejs:1.8.3")

spring-context/src/main/java/org/springframework/cache/annotation/CachingConfigurer.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,14 @@
2424
import org.springframework.cache.interceptor.KeyGenerator;
2525

2626
/**
27-
* Interface to be implemented by @{@link org.springframework.context.annotation.Configuration
28-
* Configuration} classes annotated with @{@link EnableCaching} that wish or need to specify
29-
* explicitly how caches are resolved and how keys are generated for annotation-driven
30-
* cache management.
27+
* Interface to be implemented for explicitly specifying how caches are resolved
28+
* and how keys are generated for annotation-driven cache management.
3129
*
32-
* <p>See @{@link EnableCaching} for general examples and context; see
33-
* {@link #cacheManager()}, {@link #cacheResolver()}, {@link #keyGenerator()}, and
34-
* {@link #errorHandler()} for detailed instructions.
30+
* <p>Typically implemented by @{@link org.springframework.context.annotation.Configuration
31+
* Configuration} classes annotated with @{@link EnableCaching}.
32+
* See @{@link EnableCaching} for general examples and context; see
33+
* {@link #cacheManager()}, {@link #cacheResolver()}, {@link #keyGenerator()},
34+
* and {@link #errorHandler()} for detailed instructions.
3535
*
3636
* <p><b>NOTE: A {@code CachingConfigurer} will get initialized early.</b>
3737
* Do not inject common dependencies into autowired fields directly; instead, consider

spring-context/src/main/java/org/springframework/scheduling/annotation/AsyncConfigurer.java

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,18 @@
2323
import org.springframework.aop.interceptor.AsyncUncaughtExceptionHandler;
2424

2525
/**
26-
* Interface to be implemented by @{@link org.springframework.context.annotation.Configuration
27-
* Configuration} classes annotated with @{@link EnableAsync} that wish to customize the
28-
* {@link Executor} instance used when processing async method invocations or the
29-
* {@link AsyncUncaughtExceptionHandler} instance used to process exception thrown from
30-
* async method with {@code void} return type.
26+
* Interface to be implemented for customizing the {@link Executor} instance used when
27+
* processing async method invocations or the {@link AsyncUncaughtExceptionHandler}
28+
* instance used to process exceptions thrown from async methods with a {@code void}
29+
* return type.
3130
*
32-
* <p>See @{@link EnableAsync} for usage examples.
31+
* <p>Typically implemented by @{@link org.springframework.context.annotation.Configuration
32+
* Configuration} classes annotated with @{@link EnableAsync}.
33+
* See the @{@link EnableAsync} javadoc for usage examples.
34+
*
35+
* <p><b>NOTE: An {@code AsyncConfigurer} will get initialized early.</b>
36+
* Do not inject common dependencies into autowired fields directly; instead, consider
37+
* declaring a lazy {@link org.springframework.beans.factory.ObjectProvider} for those.
3338
*
3439
* @author Chris Beams
3540
* @author Stephane Nicoll

spring-orm/src/main/java/org/springframework/orm/jpa/persistenceunit/PersistenceManagedTypesBeanRegistrationAotProcessor.java

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@
6565
* @author Sebastien Deleuze
6666
* @since 6.0
6767
*/
68-
@SuppressWarnings("unchecked")
6968
class PersistenceManagedTypesBeanRegistrationAotProcessor implements BeanRegistrationAotProcessor {
7069

7170
private static final boolean JPA_PRESENT = ClassUtils.isPresent("jakarta.persistence.Entity",
@@ -82,12 +81,12 @@ class PersistenceManagedTypesBeanRegistrationAotProcessor implements BeanRegistr
8281
return null;
8382
}
8483

84+
8585
private static final class JpaManagedTypesBeanRegistrationCodeFragments extends BeanRegistrationCodeFragmentsDecorator {
8686

8787
private static final List<Class<? extends Annotation>> CALLBACK_TYPES = List.of(PreUpdate.class,
8888
PostUpdate.class, PrePersist.class, PostPersist.class, PreRemove.class, PostRemove.class, PostLoad.class);
8989

90-
9190
private static final ParameterizedTypeName LIST_OF_STRINGS_TYPE = ParameterizedTypeName.get(List.class, String.class);
9291

9392
private final RegisteredBean registeredBean;
@@ -102,8 +101,8 @@ private JpaManagedTypesBeanRegistrationCodeFragments(BeanRegistrationCodeFragmen
102101

103102
@Override
104103
public CodeBlock generateInstanceSupplierCode(GenerationContext generationContext,
105-
BeanRegistrationCode beanRegistrationCode,
106-
boolean allowDirectSupplierShortcut) {
104+
BeanRegistrationCode beanRegistrationCode, boolean allowDirectSupplierShortcut) {
105+
107106
PersistenceManagedTypes persistenceManagedTypes = this.registeredBean.getBeanFactory()
108107
.getBean(this.registeredBean.getBeanName(), PersistenceManagedTypes.class);
109108
contributeHints(generationContext.getRuntimeHints(),
@@ -140,7 +139,7 @@ private void contributeHints(RuntimeHints hints, @Nullable ClassLoader classLoad
140139
contributeHibernateHints(hints, classLoader, managedClass);
141140
}
142141
catch (ClassNotFoundException ex) {
143-
throw new IllegalArgumentException("Failed to instantiate the managed class: " + managedClassName, ex);
142+
throw new IllegalArgumentException("Failed to instantiate JPA managed class: " + managedClassName, ex);
144143
}
145144
}
146145
}
@@ -149,7 +148,8 @@ private void contributeEntityListenersHints(RuntimeHints hints, Class<?> managed
149148
EntityListeners entityListeners = AnnotationUtils.findAnnotation(managedClass, EntityListeners.class);
150149
if (entityListeners != null) {
151150
for (Class<?> entityListener : entityListeners.value()) {
152-
hints.reflection().registerType(entityListener, MemberCategory.INVOKE_DECLARED_CONSTRUCTORS, MemberCategory.INVOKE_PUBLIC_METHODS);
151+
hints.reflection().registerType(entityListener,
152+
MemberCategory.INVOKE_DECLARED_CONSTRUCTORS, MemberCategory.INVOKE_PUBLIC_METHODS);
153153
}
154154
}
155155
}
@@ -169,12 +169,14 @@ private void contributeConverterHints(RuntimeHints hints, Class<?> managedClass)
169169
}
170170
Convert convertClassAnnotation = AnnotationUtils.findAnnotation(managedClass, Convert.class);
171171
if (convertClassAnnotation != null) {
172-
reflectionHints.registerType(convertClassAnnotation.converter(), MemberCategory.INVOKE_DECLARED_CONSTRUCTORS);
172+
reflectionHints.registerType(convertClassAnnotation.converter(),
173+
MemberCategory.INVOKE_DECLARED_CONSTRUCTORS);
173174
}
174175
ReflectionUtils.doWithFields(managedClass, field -> {
175176
Convert convertFieldAnnotation = AnnotationUtils.findAnnotation(field, Convert.class);
176177
if (convertFieldAnnotation != null && convertFieldAnnotation.converter() != AttributeConverter.class) {
177-
reflectionHints.registerType(convertFieldAnnotation.converter(), MemberCategory.INVOKE_DECLARED_CONSTRUCTORS);
178+
reflectionHints.registerType(convertFieldAnnotation.converter(),
179+
MemberCategory.INVOKE_DECLARED_CONSTRUCTORS);
178180
}
179181
});
180182
}
@@ -186,11 +188,11 @@ private void contributeCallbackHints(RuntimeHints hints, Class<?> managedClass)
186188
method -> CALLBACK_TYPES.stream().anyMatch(method::isAnnotationPresent));
187189
}
188190

189-
@SuppressWarnings("unchecked")
190191
private void contributeHibernateHints(RuntimeHints hints, @Nullable ClassLoader classLoader, Class<?> managedClass) {
191192
ReflectionHints reflection = hints.reflection();
192193

193-
Class<? extends Annotation> embeddableInstantiatorClass = loadClass("org.hibernate.annotations.EmbeddableInstantiator", classLoader);
194+
Class<? extends Annotation> embeddableInstantiatorClass =
195+
loadClass("org.hibernate.annotations.EmbeddableInstantiator", classLoader);
194196
if (embeddableInstantiatorClass != null) {
195197
registerForReflection(reflection,
196198
AnnotationUtils.findAnnotation(managedClass, embeddableInstantiatorClass), "value");
@@ -204,23 +206,26 @@ private void contributeHibernateHints(RuntimeHints hints, @Nullable ClassLoader
204206
AnnotationUtils.findAnnotation(method, embeddableInstantiatorClass), "value"));
205207
}
206208

207-
Class<? extends Annotation> valueGenerationTypeClass = loadClass("org.hibernate.annotations.ValueGenerationType", classLoader);
209+
Class<? extends Annotation> valueGenerationTypeClass =
210+
loadClass("org.hibernate.annotations.ValueGenerationType", classLoader);
208211
if (valueGenerationTypeClass != null) {
209212
ReflectionUtils.doWithFields(managedClass, field -> registerForReflection(reflection,
210213
AnnotationUtils.findAnnotation(field, valueGenerationTypeClass), "generatedBy"));
211214
ReflectionUtils.doWithMethods(managedClass, method -> registerForReflection(reflection,
212215
AnnotationUtils.findAnnotation(method, valueGenerationTypeClass), "generatedBy"));
213216
}
214217

215-
Class<? extends Annotation> idGeneratorTypeClass = loadClass("org.hibernate.annotations.IdGeneratorType", classLoader);
218+
Class<? extends Annotation> idGeneratorTypeClass =
219+
loadClass("org.hibernate.annotations.IdGeneratorType", classLoader);
216220
if (idGeneratorTypeClass != null) {
217221
ReflectionUtils.doWithFields(managedClass, field -> registerForReflection(reflection,
218222
AnnotationUtils.findAnnotation(field, idGeneratorTypeClass), "value"));
219223
ReflectionUtils.doWithMethods(managedClass, method -> registerForReflection(reflection,
220224
AnnotationUtils.findAnnotation(method, idGeneratorTypeClass), "value"));
221225
}
222226

223-
Class<? extends Annotation> attributeBinderTypeClass = loadClass("org.hibernate.annotations.AttributeBinderType", classLoader);
227+
Class<? extends Annotation> attributeBinderTypeClass =
228+
loadClass("org.hibernate.annotations.AttributeBinderType", classLoader);
224229
if (attributeBinderTypeClass != null) {
225230
ReflectionUtils.doWithFields(managedClass, field -> registerForReflection(reflection,
226231
AnnotationUtils.findAnnotation(field, attributeBinderTypeClass), "binder"));
@@ -229,6 +234,7 @@ private void contributeHibernateHints(RuntimeHints hints, @Nullable ClassLoader
229234
}
230235
}
231236

237+
@SuppressWarnings("unchecked")
232238
private static @Nullable Class<? extends Annotation> loadClass(String className, @Nullable ClassLoader classLoader) {
233239
try {
234240
return (Class<? extends Annotation>) ClassUtils.forName(className, classLoader);
@@ -238,7 +244,7 @@ private void contributeHibernateHints(RuntimeHints hints, @Nullable ClassLoader
238244
}
239245
}
240246

241-
@SuppressWarnings("NullAway") // Not null assertion performed in ReflectionHints.registerType
247+
@SuppressWarnings("NullAway") // Not-null assertion performed in ReflectionHints.registerType
242248
private void registerForReflection(ReflectionHints reflection, @Nullable Annotation annotation, String attribute) {
243249
if (annotation == null) {
244250
return;
@@ -247,4 +253,5 @@ private void registerForReflection(ReflectionHints reflection, @Nullable Annotat
247253
reflection.registerType(type, MemberCategory.INVOKE_DECLARED_CONSTRUCTORS);
248254
}
249255
}
256+
250257
}

spring-orm/src/test/java/org/springframework/orm/jpa/persistenceunit/PersistenceManagedTypesBeanRegistrationAotProcessorTests.java

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,7 @@ void processEntityManagerWithPackagesToScan() {
6666
GenericApplicationContext context = new AnnotationConfigApplicationContext();
6767
context.registerBean(JpaDomainConfiguration.class);
6868
compile(context, (initializer, compiled) -> {
69-
GenericApplicationContext freshApplicationContext = toFreshApplicationContext(
70-
initializer);
69+
GenericApplicationContext freshApplicationContext = toFreshApplicationContext(initializer);
7170
PersistenceManagedTypes persistenceManagedTypes = freshApplicationContext.getBean(
7271
"persistenceManagedTypes", PersistenceManagedTypes.class);
7372
assertThat(persistenceManagedTypes.getManagedClassNames()).containsExactlyInAnyOrder(
@@ -121,6 +120,7 @@ void contributeHibernateHints() {
121120
@SuppressWarnings("unchecked")
122121
private void compile(GenericApplicationContext applicationContext,
123122
BiConsumer<ApplicationContextInitializer<GenericApplicationContext>, Compiled> result) {
123+
124124
ApplicationContextAotGenerator generator = new ApplicationContextAotGenerator();
125125
TestGenerationContext generationContext = new TestGenerationContext();
126126
generator.processAheadOfTime(applicationContext, generationContext);
@@ -131,6 +131,7 @@ private void compile(GenericApplicationContext applicationContext,
131131

132132
private GenericApplicationContext toFreshApplicationContext(
133133
ApplicationContextInitializer<GenericApplicationContext> initializer) {
134+
134135
GenericApplicationContext freshApplicationContext = new GenericApplicationContext();
135136
initializer.initialize(freshApplicationContext);
136137
freshApplicationContext.refresh();
@@ -145,24 +146,6 @@ private void contributeHints(GenericApplicationContext applicationContext, Consu
145146
}
146147

147148

148-
public static class JpaDomainConfiguration extends AbstractEntityManagerWithPackagesToScanConfiguration {
149-
150-
@Override
151-
protected String packageToScan() {
152-
return "org.springframework.orm.jpa.domain";
153-
}
154-
}
155-
156-
157-
public static class HibernateDomainConfiguration extends AbstractEntityManagerWithPackagesToScanConfiguration {
158-
159-
@Override
160-
protected String packageToScan() {
161-
return "org.springframework.orm.jpa.hibernate.domain";
162-
}
163-
}
164-
165-
166149
public abstract static class AbstractEntityManagerWithPackagesToScanConfiguration {
167150

168151
protected boolean scanningInvoked;
@@ -182,13 +165,13 @@ public HibernateJpaVendorAdapter jpaVendorAdapter() {
182165
@Bean
183166
public PersistenceManagedTypes persistenceManagedTypes(ResourceLoader resourceLoader) {
184167
this.scanningInvoked = true;
185-
return new PersistenceManagedTypesScanner(resourceLoader)
186-
.scan(packageToScan());
168+
return new PersistenceManagedTypesScanner(resourceLoader).scan(packageToScan());
187169
}
188170

189171
@Bean
190172
public LocalContainerEntityManagerFactoryBean entityManagerFactory(DataSource dataSource,
191173
JpaVendorAdapter jpaVendorAdapter, PersistenceManagedTypes persistenceManagedTypes) {
174+
192175
LocalContainerEntityManagerFactoryBean entityManagerFactoryBean = new LocalContainerEntityManagerFactoryBean();
193176
entityManagerFactoryBean.setDataSource(dataSource);
194177
entityManagerFactoryBean.setJpaVendorAdapter(jpaVendorAdapter);
@@ -199,4 +182,22 @@ public LocalContainerEntityManagerFactoryBean entityManagerFactory(DataSource da
199182
protected abstract String packageToScan();
200183
}
201184

185+
186+
public static class JpaDomainConfiguration extends AbstractEntityManagerWithPackagesToScanConfiguration {
187+
188+
@Override
189+
protected String packageToScan() {
190+
return "org.springframework.orm.jpa.domain";
191+
}
192+
}
193+
194+
195+
public static class HibernateDomainConfiguration extends AbstractEntityManagerWithPackagesToScanConfiguration {
196+
197+
@Override
198+
protected String packageToScan() {
199+
return "org.springframework.orm.jpa.hibernate.domain";
200+
}
201+
}
202+
202203
}

spring-tx/src/main/java/org/springframework/transaction/annotation/TransactionManagementConfigurer.java

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,17 @@
1919
import org.springframework.transaction.TransactionManager;
2020

2121
/**
22-
* Interface to be implemented by @{@link org.springframework.context.annotation.Configuration
23-
* Configuration} classes annotated with @{@link EnableTransactionManagement} that wish to
24-
* (or need to) explicitly specify the default {@code PlatformTransactionManager} bean
25-
* (or {@code ReactiveTransactionManager} bean) to be used for annotation-driven
26-
* transaction management, as opposed to the default approach of a by-type lookup.
27-
* One reason this might be necessary is if there are two {@code PlatformTransactionManager}
28-
* beans (or two {@code ReactiveTransactionManager} beans) present in the container.
22+
* Interface to be implemented for explicitly specifying the default
23+
* {@link org.springframework.transaction.PlatformTransactionManager} bean
24+
* (or {@link org.springframework.transaction.ReactiveTransactionManager} bean)
25+
* to be used for annotation-driven transaction management, as opposed to the
26+
* default approach of a by-type lookup. One reason this might be necessary is
27+
* if there are two {@code PlatformTransactionManager} beans (or two
28+
* {@code ReactiveTransactionManager} beans) present in the container.
2929
*
30-
* <p>See @{@link EnableTransactionManagement} for general examples and context;
30+
* <p>Typically implemented by @{@link org.springframework.context.annotation.Configuration
31+
* Configuration} classes annotated with @{@link EnableTransactionManagement}.
32+
* See @{@link EnableTransactionManagement} for general examples and context;
3133
* see {@link #annotationDrivenTransactionManager()} for detailed instructions.
3234
*
3335
* <p><b>NOTE: A {@code TransactionManagementConfigurer} will get initialized early.</b>

0 commit comments

Comments
 (0)