|
47 | 47 | import org.springframework.core.metrics.ApplicationStartup;
|
48 | 48 | import org.springframework.core.metrics.StartupStep;
|
49 | 49 | import org.springframework.data.repository.core.support.RepositoryFactorySupport;
|
| 50 | +import org.springframework.data.util.ReflectionUtils; |
50 | 51 | import org.springframework.lang.Nullable;
|
51 | 52 | import org.springframework.util.Assert;
|
| 53 | +import org.springframework.util.ClassUtils; |
52 | 54 | import org.springframework.util.StopWatch;
|
53 | 55 |
|
54 | 56 | /**
|
@@ -183,7 +185,7 @@ public List<BeanComponentDefinition> registerRepositoriesIn(BeanDefinitionRegist
|
183 | 185 |
|
184 | 186 | AbstractBeanDefinition beanDefinition = definitionBuilder.getBeanDefinition();
|
185 | 187 |
|
186 |
| - beanDefinition.setAttribute(FACTORY_BEAN_OBJECT_TYPE, configuration.getRepositoryInterface()); |
| 188 | + beanDefinition.setAttribute(FACTORY_BEAN_OBJECT_TYPE, getRepositoryInterface(configuration)); |
187 | 189 | beanDefinition.setResourceDescription(configuration.getResourceDescription());
|
188 | 190 |
|
189 | 191 | String beanName = configurationSource.generateBeanName(beanDefinition);
|
@@ -307,6 +309,23 @@ private static ApplicationStartup getStartup(BeanDefinitionRegistry registry) {
|
307 | 309 | return ApplicationStartup.DEFAULT;
|
308 | 310 | }
|
309 | 311 |
|
| 312 | + /** |
| 313 | + * Returns the repository interface of the given {@link RepositoryConfiguration} as loaded {@link Class}. |
| 314 | + * |
| 315 | + * @param configuration must not be {@literal null}. |
| 316 | + * @return can be {@literal null}. |
| 317 | + */ |
| 318 | + @Nullable |
| 319 | + private Class<?> getRepositoryInterface(RepositoryConfiguration<?> configuration) { |
| 320 | + |
| 321 | + String interfaceName = configuration.getRepositoryInterface(); |
| 322 | + ClassLoader classLoader = resourceLoader.getClassLoader() == null |
| 323 | + ? ClassUtils.getDefaultClassLoader() |
| 324 | + : resourceLoader.getClassLoader(); |
| 325 | + |
| 326 | + return ReflectionUtils.loadIfPresent(interfaceName, classLoader); |
| 327 | + } |
| 328 | + |
310 | 329 | /**
|
311 | 330 | * Customer {@link ContextAnnotationAutowireCandidateResolver} that also considers all injection points for lazy
|
312 | 331 | * repositories lazy.
|
|
0 commit comments