Skip to content

Commit 3e2e93f

Browse files
committed
DATACMNS-1255 - Polishing.
Add default QueryLookupStrategy key lookup method to CdiRepositoryConfiguration to not break existing modules by forcing these to implement a new method.
1 parent 00db1a9 commit 3e2e93f

File tree

2 files changed

+18
-22
lines changed

2 files changed

+18
-22
lines changed

src/main/java/org/springframework/data/repository/cdi/CdiRepositoryBean.java

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,14 @@
4444
import org.springframework.data.repository.config.DefaultRepositoryConfiguration;
4545
import org.springframework.data.repository.config.RepositoryBeanNameGenerator;
4646
import org.springframework.data.repository.config.SpringDataAnnotationBeanNameGenerator;
47-
import org.springframework.data.repository.query.QueryLookupStrategy;
4847
import org.springframework.lang.Nullable;
4948
import org.springframework.util.Assert;
5049
import org.springframework.util.ClassUtils;
5150
import org.springframework.util.StringUtils;
5251

5352
/**
5453
* Base class for {@link Bean} wrappers.
55-
*
54+
*
5655
* @author Dirk Mahler
5756
* @author Oliver Gierke
5857
* @author Mark Paluch
@@ -79,7 +78,7 @@ public abstract class CdiRepositoryBean<T> implements Bean<T>, PassivationCapabl
7978

8079
/**
8180
* Creates a new {@link CdiRepositoryBean}.
82-
*
81+
*
8382
* @param qualifiers must not be {@literal null}.
8483
* @param repositoryType has to be an interface must not be {@literal null}.
8584
* @param beanManager the CDI {@link BeanManager}, must not be {@literal null}.
@@ -90,7 +89,7 @@ public CdiRepositoryBean(Set<Annotation> qualifiers, Class<T> repositoryType, Be
9089

9190
/**
9291
* Creates a new {@link CdiRepositoryBean}.
93-
*
92+
*
9493
* @param qualifiers must not be {@literal null}.
9594
* @param repositoryType has to be an interface must not be {@literal null}.
9695
* @param beanManager the CDI {@link BeanManager}, must not be {@literal null}.
@@ -114,7 +113,7 @@ public CdiRepositoryBean(Set<Annotation> qualifiers, Class<T> repositoryType, Be
114113

115114
/**
116115
* Creates a unique identifier for the given repository type and the given annotations.
117-
*
116+
*
118117
* @param qualifiers must not be {@literal null} or contain {@literal null} values.
119118
* @param repositoryType must not be {@literal null}.
120119
* @return
@@ -148,7 +147,7 @@ public Set<Type> getTypes() {
148147

149148
/**
150149
* Returns an instance of an the given {@link Bean}.
151-
*
150+
*
152151
* @param bean the {@link Bean} about to create an instance for.
153152
* @return the actual component instance.
154153
* @see Bean#getTypes()
@@ -160,7 +159,7 @@ protected <S> S getDependencyInstance(Bean<S> bean) {
160159
/**
161160
* Returns an instance of an the given {@link Bean} and allows to be specific about the type that is about to be
162161
* created.
163-
*
162+
*
164163
* @param bean the {@link Bean} about to create an instance for.
165164
* @param type the expected type of the component instance created for that {@link Bean}. We need to hand this
166165
* parameter explicitly as the {@link Bean} might carry multiple types but the primary one might not be the
@@ -219,7 +218,7 @@ public void destroy(@SuppressWarnings("null") T instance,
219218
/**
220219
* Looks up an instance of a {@link CdiRepositoryConfiguration}. In case the instance cannot be found within the CDI
221220
* scope, a default configuration is used.
222-
*
221+
*
223222
* @return an available CdiRepositoryConfiguration instance or a default configuration.
224223
*/
225224
protected CdiRepositoryConfiguration lookupConfiguration(BeanManager beanManager, Set<Annotation> qualifiers) {
@@ -232,7 +231,7 @@ protected CdiRepositoryConfiguration lookupConfiguration(BeanManager beanManager
232231
/**
233232
* Try to lookup a custom implementation for a {@link org.springframework.data.repository.Repository}. Can only be
234233
* used when a {@code CustomRepositoryImplementationDetector} is provided.
235-
*
234+
*
236235
* @param repositoryType
237236
* @param beanManager
238237
* @param qualifiers
@@ -253,7 +252,7 @@ private Optional<Bean<?>> getCustomImplementationBean(Class<?> repositoryType, B
253252
/**
254253
* Retrieves a custom repository interfaces from a repository type. This works for the whole class hierarchy and can
255254
* find also a custom repository which is inherited over many levels.
256-
*
255+
*
257256
* @param repositoryType The class representing the repository.
258257
* @param cdiRepositoryConfiguration The configuration for CDI usage.
259258
* @return the interface class or {@literal null}.
@@ -377,7 +376,7 @@ public String getId() {
377376

378377
/**
379378
* Creates the actual component instance.
380-
*
379+
*
381380
* @param creationalContext will never be {@literal null}.
382381
* @param repositoryType will never be {@literal null}.
383382
* @return
@@ -395,7 +394,7 @@ protected T create(CreationalContext<T> creationalContext, Class<T> repositoryTy
395394

396395
/**
397396
* Creates the actual component instance.
398-
*
397+
*
399398
* @param creationalContext will never be {@literal null}.
400399
* @param repositoryType will never be {@literal null}.
401400
* @param customImplementation can be {@literal null}.
@@ -430,11 +429,5 @@ static enum DefaultCdiRepositoryConfiguration implements CdiRepositoryConfigurat
430429
public String getRepositoryImplementationPostfix() {
431430
return DefaultRepositoryConfiguration.DEFAULT_REPOSITORY_IMPLEMENTATION_POSTFIX;
432431
}
433-
434-
@Override
435-
public QueryLookupStrategy.Key getQueryLookupStrategy() {
436-
return DefaultRepositoryConfiguration.DEFAULT_QUERY_LOOKUP_STRATEGY;
437-
}
438-
439432
}
440433
}

src/main/java/org/springframework/data/repository/cdi/CdiRepositoryConfiguration.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,14 @@
1616

1717
package org.springframework.data.repository.cdi;
1818

19+
import org.springframework.data.repository.config.DefaultRepositoryConfiguration;
1920
import org.springframework.data.repository.query.QueryLookupStrategy;
2021

2122
/**
2223
* Interface containing the configurable options for the Spring Data repository subsystem using CDI.
2324
*
2425
* @author Mark Paluch
26+
* @author Fabian Henniges
2527
*/
2628
public interface CdiRepositoryConfiguration {
2729

@@ -32,12 +34,13 @@ public interface CdiRepositoryConfiguration {
3234
*/
3335
String getRepositoryImplementationPostfix();
3436

35-
3637
/**
3738
* Return the strategy to lookup queries
3839
*
39-
* @return the lookup strategy to use
40+
* @return the lookup strategy to use.
41+
* @since 2.1
4042
*/
41-
QueryLookupStrategy.Key getQueryLookupStrategy();
42-
43+
default QueryLookupStrategy.Key getQueryLookupStrategy() {
44+
return DefaultRepositoryConfiguration.DEFAULT_QUERY_LOOKUP_STRATEGY;
45+
}
4346
}

0 commit comments

Comments
 (0)