|
18 | 18 |
|
19 | 19 | package org.springframework.data.mybatis.repository.config;
|
20 | 20 |
|
| 21 | +import java.lang.annotation.Annotation; |
21 | 22 | import org.springframework.beans.factory.support.BeanDefinitionRegistry;
|
22 | 23 | import org.springframework.context.EnvironmentAware;
|
23 | 24 | import org.springframework.context.ResourceLoaderAware;
|
24 | 25 | import org.springframework.core.env.Environment;
|
25 | 26 | import org.springframework.core.io.ResourceLoader;
|
26 | 27 | import org.springframework.core.type.AnnotationMetadata;
|
27 |
| -import org.springframework.data.repository.config.*; |
| 28 | +import org.springframework.data.repository.config.RepositoryBeanDefinitionRegistrarSupport; |
| 29 | +import org.springframework.data.repository.config.RepositoryConfigurationDelegate; |
| 30 | +import org.springframework.data.repository.config.RepositoryConfigurationExtension; |
| 31 | +import org.springframework.data.repository.config.RepositoryConfigurationUtils; |
28 | 32 | import org.springframework.util.Assert;
|
29 | 33 |
|
30 |
| -import java.lang.annotation.Annotation; |
31 |
| - |
32 | 34 | /**
|
33 | 35 | * Mybatis repositories register for spring data.
|
34 | 36 | *
|
35 | 37 | * @author Jarvis Song
|
36 | 38 | */
|
37 |
| -class MybatisRepositoriesRegistrar extends RepositoryBeanDefinitionRegistrarSupport implements ResourceLoaderAware, EnvironmentAware { |
| 39 | +class MybatisRepositoriesRegistrar extends RepositoryBeanDefinitionRegistrarSupport implements |
| 40 | + ResourceLoaderAware, EnvironmentAware { |
38 | 41 |
|
39 |
| - private ResourceLoader resourceLoader; |
40 |
| - private Environment environment; |
| 42 | + private ResourceLoader resourceLoader; |
| 43 | + private Environment environment; |
41 | 44 |
|
42 |
| - @Override |
43 |
| - protected Class<? extends Annotation> getAnnotation() { |
44 |
| - return EnableMybatisRepositories.class; |
45 |
| - } |
| 45 | + @Override |
| 46 | + protected Class<? extends Annotation> getAnnotation() { |
| 47 | + return EnableMybatisRepositories.class; |
| 48 | + } |
46 | 49 |
|
47 |
| - @Override |
48 |
| - protected RepositoryConfigurationExtension getExtension() { |
49 |
| - return new MybatisRepositoryConfigExtension(resourceLoader); |
50 |
| - } |
| 50 | + @Override |
| 51 | + protected RepositoryConfigurationExtension getExtension() { |
| 52 | + return new MybatisRepositoryConfigExtension(resourceLoader); |
| 53 | + } |
51 | 54 |
|
52 |
| - @Override |
53 |
| - public void setResourceLoader(ResourceLoader resourceLoader) { |
54 |
| - super.setResourceLoader(resourceLoader); |
55 |
| - this.resourceLoader = resourceLoader; |
56 |
| - } |
| 55 | + @Override |
| 56 | + public void setResourceLoader(ResourceLoader resourceLoader) { |
| 57 | + super.setResourceLoader(resourceLoader); |
| 58 | + this.resourceLoader = resourceLoader; |
| 59 | + } |
57 | 60 |
|
58 |
| - @Override |
59 |
| - public void setEnvironment(Environment environment) { |
60 |
| - this.environment = environment; |
61 |
| - super.setEnvironment(environment); |
62 |
| - } |
| 61 | + @Override |
| 62 | + public void setEnvironment(Environment environment) { |
| 63 | + this.environment = environment; |
| 64 | + super.setEnvironment(environment); |
| 65 | + } |
63 | 66 |
|
64 |
| - @Override |
65 |
| - public void registerBeanDefinitions(AnnotationMetadata annotationMetadata, BeanDefinitionRegistry registry) { |
66 |
| - Assert.notNull(resourceLoader, "ResourceLoader must not be null!"); |
67 |
| - Assert.notNull(annotationMetadata, "AnnotationMetadata must not be null!"); |
68 |
| - Assert.notNull(registry, "BeanDefinitionRegistry must not be null!"); |
| 67 | + @Override |
| 68 | + public void registerBeanDefinitions(AnnotationMetadata annotationMetadata, |
| 69 | + BeanDefinitionRegistry registry) { |
| 70 | + Assert.notNull(resourceLoader, "ResourceLoader must not be null!"); |
| 71 | + Assert.notNull(annotationMetadata, "AnnotationMetadata must not be null!"); |
| 72 | + Assert.notNull(registry, "BeanDefinitionRegistry must not be null!"); |
69 | 73 |
|
70 |
| - // Guard against calls for sub-classes |
71 |
| - if (annotationMetadata.getAnnotationAttributes(getAnnotation().getName()) == null) { |
72 |
| - return; |
73 |
| - } |
| 74 | + // Guard against calls for sub-classes |
| 75 | + if (annotationMetadata.getAnnotationAttributes(getAnnotation().getName()) == null) { |
| 76 | + return; |
| 77 | + } |
74 | 78 |
|
75 |
| - MybatisAnnotationRepositoryConfigurationSource configurationSource = new MybatisAnnotationRepositoryConfigurationSource( |
76 |
| - annotationMetadata, getAnnotation(), resourceLoader, environment); |
| 79 | + MybatisAnnotationRepositoryConfigurationSource configurationSource = new MybatisAnnotationRepositoryConfigurationSource( |
| 80 | + annotationMetadata, getAnnotation(), resourceLoader, environment, registry); |
77 | 81 |
|
78 |
| - RepositoryConfigurationExtension extension = getExtension(); |
79 |
| - RepositoryConfigurationUtils.exposeRegistration(extension, registry, configurationSource); |
| 82 | + RepositoryConfigurationExtension extension = getExtension(); |
| 83 | + RepositoryConfigurationUtils.exposeRegistration(extension, registry, configurationSource); |
80 | 84 |
|
81 |
| - RepositoryConfigurationDelegate delegate = new RepositoryConfigurationDelegate(configurationSource, resourceLoader, |
82 |
| - environment); |
| 85 | + RepositoryConfigurationDelegate delegate = new RepositoryConfigurationDelegate( |
| 86 | + configurationSource, resourceLoader, |
| 87 | + environment); |
83 | 88 |
|
84 |
| - delegate.registerRepositoriesIn(registry, extension); |
85 |
| - } |
| 89 | + delegate.registerRepositoriesIn(registry, extension); |
| 90 | + } |
86 | 91 | }
|
0 commit comments