31
31
import org .springframework .core .env .StandardEnvironment ;
32
32
import org .springframework .core .io .ResourceLoader ;
33
33
import org .springframework .core .io .support .SpringFactoriesLoader ;
34
+ import org .springframework .data .repository .Repository ;
34
35
import org .springframework .data .repository .core .support .RepositoryFactorySupport ;
35
36
import org .springframework .util .Assert ;
36
37
@@ -69,12 +70,13 @@ public class RepositoryConfigurationDelegate {
69
70
public RepositoryConfigurationDelegate (RepositoryConfigurationSource configurationSource ,
70
71
ResourceLoader resourceLoader , Environment environment ) {
71
72
72
- this .isXml = configurationSource instanceof XmlRepositoryConfigurationSource ;
73
+ Assert .notNull (resourceLoader , "ResourceLoader must not be null!" );
74
+
73
75
boolean isAnnotation = configurationSource instanceof AnnotationRepositoryConfigurationSource ;
76
+ this .isXml = configurationSource instanceof XmlRepositoryConfigurationSource ;
74
77
75
- Assert .isTrue (isXml || isAnnotation ,
76
- "Configuration source must either be an Xml- or an AnnotationBasedConfigurationSource!" );
77
- Assert .notNull (resourceLoader , "ResourceLoader must not be null!" );
78
+ Assert .isTrue (this .isXml || isAnnotation ,
79
+ "Configuration source must either be an XML-based or an Annotation-based RepositoryConfigurationSource!" );
78
80
79
81
this .configurationSource = configurationSource ;
80
82
this .resourceLoader = resourceLoader ;
@@ -83,12 +85,14 @@ public RepositoryConfigurationDelegate(RepositoryConfigurationSource configurati
83
85
}
84
86
85
87
/**
86
- * Defaults the environment in case the given one is null. Used as fallback, in case the legacy constructor was
87
- * invoked.
88
+ * Defaults the {@link Environment} in case the given one is {@literal null}.
89
+ *
90
+ * Used as fallback in case the legacy constructor was invoked.
88
91
*
89
92
* @param environment can be {@literal null}.
90
93
* @param resourceLoader can be {@literal null}.
91
- * @return
94
+ * @return the given {@link Environment} if not {@literal null} or an {@link Environment} obtained
95
+ * from the {@link ResourceLoader} if {@link ResourceLoader} is {@link EnvironmentCapable}.
92
96
*/
93
97
private static Environment defaultEnvironment (@ Nullable Environment environment ,
94
98
@ Nullable ResourceLoader resourceLoader ) {
@@ -104,21 +108,22 @@ private static Environment defaultEnvironment(@Nullable Environment environment,
104
108
/**
105
109
* Registers the found repositories in the given {@link BeanDefinitionRegistry}.
106
110
*
107
- * @param registry
108
- * @param extension
109
- * @return {@link BeanComponentDefinition}s for all repository bean definitions found.
111
+ * @param registry {@link BeanDefinitionRegistry} used to register {@link Repository Repositories}.
112
+ * @param extension {@link RepositoryConfigurationExtension} containing store specific configuration meta-data.
113
+ * @return {@link BeanComponentDefinition}s for all {@link Repository} bean definitions found.
110
114
*/
111
115
public List <BeanComponentDefinition > registerRepositoriesIn (BeanDefinitionRegistry registry ,
112
116
RepositoryConfigurationExtension extension ) {
113
117
114
118
extension .registerBeansForRoot (registry , configurationSource );
115
119
116
- RepositoryBeanDefinitionBuilder builder = new RepositoryBeanDefinitionBuilder (registry , extension , resourceLoader ,
117
- environment );
120
+ RepositoryBeanDefinitionBuilder builder =
121
+ new RepositoryBeanDefinitionBuilder (registry , extension , resourceLoader , environment );
122
+
118
123
List <BeanComponentDefinition > definitions = new ArrayList <>();
119
124
120
- for (RepositoryConfiguration <? extends RepositoryConfigurationSource > configuration : extension
121
- .getRepositoryConfigurations (configurationSource , resourceLoader , inMultiStoreMode )) {
125
+ for (RepositoryConfiguration <? extends RepositoryConfigurationSource > configuration
126
+ : extension .getRepositoryConfigurations (configurationSource , resourceLoader , inMultiStoreMode )) {
122
127
123
128
BeanDefinitionBuilder definitionBuilder = builder .build (configuration );
124
129
@@ -152,7 +157,7 @@ public List<BeanComponentDefinition> registerRepositoriesIn(BeanDefinitionRegist
152
157
* than a single type is considered a multi-store configuration scenario which will trigger stricter repository
153
158
* scanning.
154
159
*
155
- * @return
160
+ * @return a boolean value indicating if multiple Spring Data store implementations are present on the classpath.
156
161
*/
157
162
private boolean multipleStoresDetected () {
158
163
0 commit comments