@@ -87,15 +87,25 @@ public <T extends RepositoryConfigurationSource> Collection<RepositoryConfigurat
87
87
for (BeanDefinition candidate : configSource .getCandidates (loader )) {
88
88
89
89
RepositoryConfiguration <T > configuration = getRepositoryConfiguration (candidate , configSource );
90
+ Class <?> repositoryInterface = loadRepositoryInterface (configuration , loader );
90
91
91
- if (! strictMatchesOnly || configSource . usesExplicitFilters () ) {
92
+ if (repositoryInterface == null ) {
92
93
result .add (configuration );
93
94
continue ;
94
95
}
95
96
96
- Class <?> repositoryInterface = loadRepositoryInterface (configuration , loader );
97
+ RepositoryMetadata metadata = AbstractRepositoryMetadata .getMetadata (repositoryInterface );
98
+
99
+ if (!useRepositoryConfiguration (metadata )) {
100
+ continue ;
101
+ }
102
+
103
+ if (!strictMatchesOnly || configSource .usesExplicitFilters ()) {
104
+ result .add (configuration );
105
+ continue ;
106
+ }
97
107
98
- if (repositoryInterface == null || isStrictRepositoryCandidate (repositoryInterface )) {
108
+ if (isStrictRepositoryCandidate (metadata )) {
99
109
result .add (configuration );
100
110
}
101
111
}
@@ -246,7 +256,7 @@ protected <T extends RepositoryConfigurationSource> RepositoryConfiguration<T> g
246
256
}
247
257
248
258
/**
249
- * Returns whether the given repository interface is a candidate for bean definition creation in the strict repository
259
+ * Returns whether the given repository metadata is a candidate for bean definition creation in the strict repository
250
260
* detection mode. The default implementation inspects the domain type managed for a set of well-known annotations
251
261
* (see {@link #getIdentifyingAnnotations()}). If none of them is found, the candidate is discarded. Implementations
252
262
* should make sure, the only return {@literal true} if they're really sure the interface handed to the method is
@@ -256,11 +266,10 @@ protected <T extends RepositoryConfigurationSource> RepositoryConfiguration<T> g
256
266
* @return
257
267
* @since 1.9
258
268
*/
259
- protected boolean isStrictRepositoryCandidate (Class <?> repositoryInterface ) {
260
-
261
- RepositoryMetadata metadata = AbstractRepositoryMetadata .getMetadata (repositoryInterface );
269
+ protected boolean isStrictRepositoryCandidate (RepositoryMetadata metadata ) {
262
270
263
271
Collection <Class <?>> types = getIdentifyingTypes ();
272
+ Class <?> repositoryInterface = metadata .getRepositoryInterface ();
264
273
265
274
for (Class <?> type : types ) {
266
275
if (type .isAssignableFrom (repositoryInterface )) {
@@ -286,6 +295,16 @@ protected boolean isStrictRepositoryCandidate(Class<?> repositoryInterface) {
286
295
return false ;
287
296
}
288
297
298
+ /**
299
+ * Return whether to use the configuration for the repository with the given metadata. Defaults to {@literal true}.
300
+ *
301
+ * @param metadata will never be {@literal null}.
302
+ * @return
303
+ */
304
+ protected boolean useRepositoryConfiguration (RepositoryMetadata metadata ) {
305
+ return true ;
306
+ }
307
+
289
308
/**
290
309
* Loads the repository interface contained in the given {@link RepositoryConfiguration} using the given
291
310
* {@link ResourceLoader}.
@@ -294,7 +313,7 @@ protected boolean isStrictRepositoryCandidate(Class<?> repositoryInterface) {
294
313
* @param loader must not be {@literal null}.
295
314
* @return the repository interface or {@literal null} if it can't be loaded.
296
315
*/
297
- protected Class <?> loadRepositoryInterface (RepositoryConfiguration <?> configuration , ResourceLoader loader ) {
316
+ private Class <?> loadRepositoryInterface (RepositoryConfiguration <?> configuration , ResourceLoader loader ) {
298
317
299
318
String repositoryInterface = configuration .getRepositoryInterface ();
300
319
ClassLoader classLoader = loader .getClassLoader ();
0 commit comments