|
21 | 21 | import java.lang.annotation.Annotation;
|
22 | 22 |
|
23 | 23 | import org.springframework.beans.factory.BeanDefinitionStoreException;
|
24 |
| -import org.springframework.beans.factory.ListableBeanFactory; |
25 | 24 | import org.springframework.beans.factory.aspectj.AnnotationBeanConfigurerAspect;
|
26 | 25 | import org.springframework.beans.factory.config.BeanDefinition;
|
27 | 26 | import org.springframework.beans.factory.parsing.BeanComponentDefinition;
|
28 | 27 | import org.springframework.beans.factory.support.BeanDefinitionBuilder;
|
29 |
| -import org.springframework.beans.factory.support.BeanDefinitionReaderUtils; |
30 | 28 | import org.springframework.beans.factory.support.BeanDefinitionRegistry;
|
31 | 29 | import org.springframework.beans.factory.support.RootBeanDefinition;
|
32 | 30 | import org.springframework.context.annotation.ImportBeanDefinitionRegistrar;
|
|
36 | 34 | import org.springframework.data.config.ParsingUtils;
|
37 | 35 | import org.springframework.data.jpa.domain.support.AuditingBeanFactoryPostProcessor;
|
38 | 36 | import org.springframework.data.jpa.domain.support.AuditingEntityListener;
|
39 |
| -import org.springframework.data.mapping.context.PersistentEntities; |
40 |
| -import org.springframework.data.repository.config.PersistentEntitiesFactoryBean; |
41 |
| -import org.springframework.lang.Nullable; |
42 | 37 | import org.springframework.util.Assert;
|
43 | 38 | import org.springframework.util.ClassUtils;
|
44 | 39 |
|
@@ -94,38 +89,9 @@ protected void registerAuditListenerBeanDefinition(BeanDefinition auditingHandle
|
94 | 89 | protected void postProcess(BeanDefinitionBuilder builder, AuditingConfiguration configuration,
|
95 | 90 | BeanDefinitionRegistry registry) {
|
96 | 91 |
|
97 |
| - String persistentEntitiesBeanName = detectPersistentEntitiesBeanName(registry); |
98 |
| - |
99 |
| - if (persistentEntitiesBeanName == null) { |
100 |
| - |
101 |
| - persistentEntitiesBeanName = BeanDefinitionReaderUtils.uniqueBeanName("jpaPersistentEntities", registry); |
102 |
| - |
103 |
| - // TODO: https://github.com/spring-projects/spring-framework/issues/28728 |
104 |
| - BeanDefinitionBuilder definition = BeanDefinitionBuilder.genericBeanDefinition(PersistentEntities.class) // |
105 |
| - .setFactoryMethod("of") // |
106 |
| - .addConstructorArgReference(JPA_MAPPING_CONTEXT_BEAN_NAME); |
107 |
| - |
108 |
| - registry.registerBeanDefinition(persistentEntitiesBeanName, definition.getBeanDefinition()); |
109 |
| - } |
110 |
| - |
111 |
| - builder.addConstructorArgReference(persistentEntitiesBeanName); |
| 92 | + builder.setFactoryMethod("from").addConstructorArgReference(JPA_MAPPING_CONTEXT_BEAN_NAME); |
112 | 93 | }
|
113 | 94 |
|
114 |
| - @Nullable |
115 |
| - private static String detectPersistentEntitiesBeanName(BeanDefinitionRegistry registry) { |
116 |
| - |
117 |
| - if (registry instanceof ListableBeanFactory beanFactory) { |
118 |
| - for (String bn : beanFactory.getBeanNamesForType(PersistentEntities.class)) { |
119 |
| - if (bn.startsWith("jpa")) { |
120 |
| - return bn; |
121 |
| - } |
122 |
| - } |
123 |
| - } |
124 |
| - |
125 |
| - return null; |
126 |
| - } |
127 |
| - |
128 |
| - |
129 | 95 | /**
|
130 | 96 | * @param registry, the {@link BeanDefinitionRegistry} to be used to register the
|
131 | 97 | * {@link AnnotationBeanConfigurerAspect}.
|
|
0 commit comments