|
43 | 43 | import org.springframework.beans.factory.support.AbstractBeanDefinition;
|
44 | 44 | import org.springframework.beans.factory.support.BeanDefinitionBuilder;
|
45 | 45 | import org.springframework.beans.factory.support.BeanDefinitionRegistry;
|
46 |
| -import org.springframework.beans.factory.support.RegisteredBean; |
47 | 46 | import org.springframework.beans.factory.support.RootBeanDefinition;
|
48 | 47 | import org.springframework.context.annotation.AnnotationConfigUtils;
|
49 | 48 | import org.springframework.core.annotation.AnnotationAttributes;
|
50 | 49 | import org.springframework.core.io.ResourceLoader;
|
51 |
| -import org.springframework.core.type.classreading.MetadataReaderFactory; |
52 |
| -import org.springframework.core.type.filter.TypeFilter; |
53 | 50 | import org.springframework.dao.DataAccessException;
|
54 | 51 | import org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor;
|
55 | 52 | import org.springframework.data.aot.AotContext;
|
|
63 | 60 | import org.springframework.data.repository.aot.generate.RepositoryContributor;
|
64 | 61 | import org.springframework.data.repository.config.AnnotationRepositoryConfigurationSource;
|
65 | 62 | import org.springframework.data.repository.config.AotRepositoryContext;
|
66 |
| -import org.springframework.data.repository.config.ImplementationDetectionConfiguration; |
67 |
| -import org.springframework.data.repository.config.ImplementationLookupConfiguration; |
68 |
| -import org.springframework.data.repository.config.RepositoryConfiguration; |
69 | 63 | import org.springframework.data.repository.config.RepositoryConfigurationExtensionSupport;
|
70 | 64 | import org.springframework.data.repository.config.RepositoryConfigurationSource;
|
71 | 65 | import org.springframework.data.repository.config.RepositoryRegistrationAotProcessor;
|
72 | 66 | import org.springframework.data.repository.config.XmlRepositoryConfigurationSource;
|
73 |
| -import org.springframework.data.util.Streamable; |
74 | 67 | import org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor;
|
75 | 68 | import org.springframework.util.ClassUtils;
|
76 | 69 | import org.springframework.util.StringUtils;
|
@@ -105,6 +98,11 @@ public String getModuleName() {
|
105 | 98 | return "JPA";
|
106 | 99 | }
|
107 | 100 |
|
| 101 | + @Override |
| 102 | + public String getRepositoryBaseClassName() { |
| 103 | + return SimpleJpaRepository.class.getName(); |
| 104 | + } |
| 105 | + |
108 | 106 | @Override
|
109 | 107 | public String getRepositoryFactoryBeanClassName() {
|
110 | 108 | return JpaRepositoryFactoryBean.class.getName();
|
@@ -342,123 +340,5 @@ public static class JpaRepositoryRegistrationAotProcessor extends RepositoryRegi
|
342 | 340 | return emf != null ? new JpaRepositoryContributor(repositoryContext, emf)
|
343 | 341 | : new JpaRepositoryContributor(repositoryContext);
|
344 | 342 | }
|
345 |
| - |
346 |
| - @Nullable |
347 |
| - @Override |
348 |
| - @SuppressWarnings("NullAway") |
349 |
| - protected RepositoryConfiguration<?> getRepositoryMetadata(RegisteredBean bean) { |
350 |
| - RepositoryConfiguration<?> configuration = super.getRepositoryMetadata(bean); |
351 |
| - |
352 |
| - if (configuration != null && configuration.getRepositoryBaseClassName().isPresent()) { |
353 |
| - return configuration; |
354 |
| - } |
355 |
| - return new Meh<>(configuration); |
356 |
| - } |
357 |
| - } |
358 |
| - |
359 |
| - /** |
360 |
| - * I'm just a dirty hack so we can refine the {@link #getRepositoryBaseClassName()} method as we cannot instantiate |
361 |
| - * the bean safely to extract it form the repository factory in data commons. So we either have a configurable |
362 |
| - * {@link RepositoryConfiguration} return from |
363 |
| - * {@link RepositoryRegistrationAotProcessor#getRepositoryMetadata(RegisteredBean)} or change the arrangement and |
364 |
| - * maybe move the type out of the factoy. |
365 |
| - * |
366 |
| - * @param <T> |
367 |
| - */ |
368 |
| - static class Meh<T extends RepositoryConfigurationSource> implements RepositoryConfiguration<T> { |
369 |
| - |
370 |
| - private RepositoryConfiguration<?> configuration; |
371 |
| - |
372 |
| - public Meh(RepositoryConfiguration<?> configuration) { |
373 |
| - this.configuration = configuration; |
374 |
| - } |
375 |
| - |
376 |
| - @Nullable |
377 |
| - @Override |
378 |
| - public Object getSource() { |
379 |
| - return configuration.getSource(); |
380 |
| - } |
381 |
| - |
382 |
| - @Override |
383 |
| - public T getConfigurationSource() { |
384 |
| - return (T) configuration.getConfigurationSource(); |
385 |
| - } |
386 |
| - |
387 |
| - @Override |
388 |
| - public boolean isLazyInit() { |
389 |
| - return configuration.isLazyInit(); |
390 |
| - } |
391 |
| - |
392 |
| - @Override |
393 |
| - public boolean isPrimary() { |
394 |
| - return configuration.isPrimary(); |
395 |
| - } |
396 |
| - |
397 |
| - @Override |
398 |
| - public Streamable<String> getBasePackages() { |
399 |
| - return configuration.getBasePackages(); |
400 |
| - } |
401 |
| - |
402 |
| - @Override |
403 |
| - public Streamable<String> getImplementationBasePackages() { |
404 |
| - return configuration.getImplementationBasePackages(); |
405 |
| - } |
406 |
| - |
407 |
| - @Override |
408 |
| - public String getRepositoryInterface() { |
409 |
| - return configuration.getRepositoryInterface(); |
410 |
| - } |
411 |
| - |
412 |
| - @Override |
413 |
| - public Optional<Object> getQueryLookupStrategyKey() { |
414 |
| - return Optional.ofNullable(configuration.getQueryLookupStrategyKey()); |
415 |
| - } |
416 |
| - |
417 |
| - @Override |
418 |
| - public Optional<String> getNamedQueriesLocation() { |
419 |
| - return configuration.getNamedQueriesLocation(); |
420 |
| - } |
421 |
| - |
422 |
| - @Override |
423 |
| - public Optional<String> getRepositoryBaseClassName() { |
424 |
| - String name = SimpleJpaRepository.class.getName(); |
425 |
| - return Optional.of(name); |
426 |
| - } |
427 |
| - |
428 |
| - @Override |
429 |
| - public String getRepositoryFactoryBeanClassName() { |
430 |
| - return configuration.getRepositoryFactoryBeanClassName(); |
431 |
| - } |
432 |
| - |
433 |
| - @Override |
434 |
| - public String getImplementationBeanName() { |
435 |
| - return configuration.getImplementationBeanName(); |
436 |
| - } |
437 |
| - |
438 |
| - @Override |
439 |
| - public String getRepositoryBeanName() { |
440 |
| - return configuration.getRepositoryBeanName(); |
441 |
| - } |
442 |
| - |
443 |
| - @Override |
444 |
| - public Streamable<TypeFilter> getExcludeFilters() { |
445 |
| - return configuration.getExcludeFilters(); |
446 |
| - } |
447 |
| - |
448 |
| - @Override |
449 |
| - public ImplementationDetectionConfiguration toImplementationDetectionConfiguration(MetadataReaderFactory factory) { |
450 |
| - return configuration.toImplementationDetectionConfiguration(factory); |
451 |
| - } |
452 |
| - |
453 |
| - @Override |
454 |
| - public ImplementationLookupConfiguration toLookupConfiguration(MetadataReaderFactory factory) { |
455 |
| - return configuration.toLookupConfiguration(factory); |
456 |
| - } |
457 |
| - |
458 |
| - @Nullable |
459 |
| - @Override |
460 |
| - public String getResourceDescription() { |
461 |
| - return configuration.getResourceDescription(); |
462 |
| - } |
463 | 343 | }
|
464 | 344 | }
|
0 commit comments