|
32 | 32 | import org.springframework.aot.generate.GenerationContext;
|
33 | 33 | import org.springframework.aot.hint.MemberCategory;
|
34 | 34 | import org.springframework.aot.hint.TypeReference;
|
35 |
| -import org.springframework.beans.factory.FactoryBean; |
36 | 35 | import org.springframework.beans.factory.aot.BeanRegistrationAotContribution;
|
37 | 36 | import org.springframework.beans.factory.aot.BeanRegistrationCode;
|
38 | 37 | import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
|
39 | 38 | import org.springframework.beans.factory.support.RegisteredBean;
|
40 |
| -import org.springframework.beans.factory.support.RootBeanDefinition; |
41 | 39 | import org.springframework.core.DecoratingProxy;
|
42 |
| -import org.springframework.core.ResolvableType; |
43 | 40 | import org.springframework.core.annotation.AnnotationUtils;
|
44 | 41 | import org.springframework.data.aot.AotContext;
|
45 | 42 | import org.springframework.data.projection.EntityProjectionIntrospector;
|
46 | 43 | import org.springframework.data.projection.TargetAware;
|
47 | 44 | import org.springframework.data.repository.Repository;
|
48 | 45 | import org.springframework.data.repository.core.RepositoryInformation;
|
49 |
| -import org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport; |
50 | 46 | import org.springframework.data.repository.core.support.RepositoryFragment;
|
51 | 47 | import org.springframework.data.util.QTypeContributor;
|
52 | 48 | import org.springframework.data.util.TypeContributor;
|
@@ -152,8 +148,6 @@ public RepositoryRegistrationAotContribution forBean(RegisteredBean repositoryBe
|
152 | 148 |
|
153 | 149 | this.repositoryContext = buildAotRepositoryContext(repositoryBean, repositoryMetadata);
|
154 | 150 |
|
155 |
| - enhanceRepositoryBeanDefinition(repositoryBean, repositoryMetadata, this.repositoryContext); |
156 |
| - |
157 | 151 | return this;
|
158 | 152 | }
|
159 | 153 |
|
@@ -203,44 +197,12 @@ private RepositoryInformation resolveRepositoryInformation(RepositoryConfigurati
|
203 | 197 | return RepositoryBeanDefinitionReader.readRepositoryInformation(repositoryMetadata, getBeanFactory());
|
204 | 198 | }
|
205 | 199 |
|
206 |
| - /** |
207 |
| - * Helps the AOT processing render the {@link FactoryBean} type correctly that is used to tell the outcome of the |
208 |
| - * {@link FactoryBean}. We just need to set the target {@link Repository} {@link Class type} of the |
209 |
| - * {@link RepositoryFactoryBeanSupport} while keeping the actual ID and DomainType set to {@link Object}. If the |
210 |
| - * generic type signature does not match, then we do not try to resolve and remap the types, but rather set the |
211 |
| - * {@literal factoryBeanObjectType} attribute on the {@link RootBeanDefinition}. |
212 |
| - */ |
213 |
| - protected void enhanceRepositoryBeanDefinition(RegisteredBean repositoryBean, |
214 |
| - RepositoryConfiguration<?> repositoryMetadata, AotRepositoryContext repositoryContext) { |
215 |
| - |
216 |
| - logTrace(String.format("Enhancing repository factory bean definition [%s]", repositoryBean.getBeanName())); |
217 |
| - |
218 |
| - Class<?> repositoryFactoryBeanType = repositoryContext |
219 |
| - .introspectType(repositoryMetadata.getRepositoryFactoryBeanClassName()).resolveType() |
220 |
| - .orElse(RepositoryFactoryBeanSupport.class); |
221 |
| - |
222 |
| - ResolvableType resolvedRepositoryFactoryBeanType = ResolvableType.forClass(repositoryFactoryBeanType); |
223 |
| - |
224 |
| - RootBeanDefinition repositoryBeanDefinition = repositoryBean.getMergedBeanDefinition(); |
225 |
| - |
226 |
| - if (isRepositoryWithTypeParameters(resolvedRepositoryFactoryBeanType)) { |
227 |
| - repositoryBeanDefinition.setTargetType(ResolvableType.forClassWithGenerics(repositoryFactoryBeanType, |
228 |
| - repositoryContext.getRepositoryInformation().getRepositoryInterface(), Object.class, Object.class)); |
229 |
| - } else { |
230 |
| - repositoryBeanDefinition.setTargetType(resolvedRepositoryFactoryBeanType); |
231 |
| - repositoryBeanDefinition.setAttribute(FactoryBean.OBJECT_TYPE_ATTRIBUTE, |
232 |
| - repositoryContext.getRepositoryInformation().getRepositoryInterface()); |
233 |
| - } |
234 |
| - } |
235 |
| - |
236 | 200 | /**
|
237 | 201 | * {@link BiConsumer Callback} for data module specific contributions.
|
238 | 202 | *
|
239 | 203 | * @param moduleContribution {@link BiConsumer} used by data modules to submit contributions; can be {@literal null}.
|
240 | 204 | * @return this.
|
241 | 205 | */
|
242 |
| - |
243 |
| - @SuppressWarnings("unused") |
244 | 206 | public RepositoryRegistrationAotContribution withModuleContribution(
|
245 | 207 | @Nullable BiConsumer<AotRepositoryContext, GenerationContext> moduleContribution) {
|
246 | 208 | this.moduleContribution = moduleContribution;
|
@@ -385,8 +347,4 @@ static boolean isJavaOrPrimitiveType(Class<?> type) {
|
385 | 347 | public Predicate<Class<?>> typeFilter() { // like only document ones. // TODO: As in MongoDB?
|
386 | 348 | return it -> true;
|
387 | 349 | }
|
388 |
| - |
389 |
| - private static boolean isRepositoryWithTypeParameters(ResolvableType type) { |
390 |
| - return type.getGenerics().length == 3; |
391 |
| - } |
392 | 350 | }
|
0 commit comments