|
20 | 20 |
|
21 | 21 | import java.io.Serializable;
|
22 | 22 | import java.lang.reflect.Method;
|
23 |
| -import java.util.Arrays; |
24 | 23 |
|
25 |
| -import org.reactivestreams.Publisher; |
26 |
| -import org.springframework.dao.InvalidDataAccessApiUsageException; |
27 | 24 | import org.springframework.data.mapping.context.MappingContext;
|
28 | 25 | import org.springframework.data.mapping.model.MappingException;
|
29 | 26 | import org.springframework.data.mongodb.core.ReactiveMongoOperations;
|
|
38 | 35 | import org.springframework.data.repository.core.NamedQueries;
|
39 | 36 | import org.springframework.data.repository.core.RepositoryInformation;
|
40 | 37 | import org.springframework.data.repository.core.RepositoryMetadata;
|
41 |
| -import org.springframework.data.repository.core.support.RepositoryFactorySupport; |
| 38 | +import org.springframework.data.repository.core.support.ReactiveRepositoryFactorySupport; |
42 | 39 | import org.springframework.data.repository.query.EvaluationContextProvider;
|
43 | 40 | import org.springframework.data.repository.query.QueryLookupStrategy;
|
44 | 41 | import org.springframework.data.repository.query.QueryLookupStrategy.Key;
|
45 | 42 | import org.springframework.data.repository.query.RepositoryQuery;
|
46 |
| -import org.springframework.data.repository.util.ReactiveWrapperConverters; |
47 |
| -import org.springframework.data.repository.util.ReactiveWrappers; |
48 | 43 | import org.springframework.expression.spel.standard.SpelExpressionParser;
|
49 | 44 | import org.springframework.util.Assert;
|
50 |
| -import org.springframework.util.ClassUtils; |
51 | 45 |
|
52 | 46 | /**
|
53 | 47 | * Factory to create {@link org.springframework.data.mongodb.repository.ReactiveMongoRepository} instances.
|
|
57 | 51 | * @author Oliver Gierke
|
58 | 52 | * @since 2.0
|
59 | 53 | */
|
60 |
| -public class ReactiveMongoRepositoryFactory extends RepositoryFactorySupport { |
| 54 | +public class ReactiveMongoRepositoryFactory extends ReactiveRepositoryFactorySupport { |
61 | 55 |
|
62 | 56 | private static final SpelExpressionParser EXPRESSION_PARSER = new SpelExpressionParser();
|
63 | 57 |
|
@@ -115,53 +109,6 @@ public <T, ID extends Serializable> MongoEntityInformation<T, ID> getEntityInfor
|
115 | 109 | return getEntityInformation(domainClass, null);
|
116 | 110 | }
|
117 | 111 |
|
118 |
| - /* |
119 |
| - * (non-Javadoc) |
120 |
| - * @see org.springframework.data.repository.core.support.RepositoryFactorySupport#validate(org.springframework.data.repository.core.RepositoryMetadata) |
121 |
| - */ |
122 |
| - @Override |
123 |
| - protected void validate(RepositoryMetadata repositoryMetadata) { |
124 |
| - |
125 |
| - if (!ReactiveWrappers.isAvailable()) { |
126 |
| - throw new InvalidDataAccessApiUsageException( |
127 |
| - String.format("Cannot implement repository %s without reactive library support.", |
128 |
| - repositoryMetadata.getRepositoryInterface().getName())); |
129 |
| - } |
130 |
| - |
131 |
| - Arrays.stream(repositoryMetadata.getRepositoryInterface().getMethods()) |
132 |
| - .forEach(ReactiveMongoRepositoryFactory::validate); |
133 |
| - } |
134 |
| - |
135 |
| - /** |
136 |
| - * Reactive MongoDB support requires reactive wrapper support. If return type/parameters are reactive wrapper types, |
137 |
| - * then it's required to be able to convert these into Publisher. |
138 |
| - * |
139 |
| - * @param method the method to validate. |
140 |
| - */ |
141 |
| - private static void validate(Method method) { |
142 |
| - |
143 |
| - if (ReactiveWrappers.supports(method.getReturnType()) |
144 |
| - && !ClassUtils.isAssignable(Publisher.class, method.getReturnType())) { |
145 |
| - |
146 |
| - if (!ReactiveWrapperConverters.supports(method.getReturnType())) { |
147 |
| - |
148 |
| - throw new InvalidDataAccessApiUsageException( |
149 |
| - String.format("No reactive type converter found for type %s used in %s, method %s.", |
150 |
| - method.getReturnType().getName(), method.getDeclaringClass().getName(), method)); |
151 |
| - } |
152 |
| - } |
153 |
| - |
154 |
| - Arrays.stream(method.getParameterTypes()) // |
155 |
| - .filter(ReactiveWrappers::supports) // |
156 |
| - .filter(parameterType -> !ClassUtils.isAssignable(Publisher.class, parameterType)) // |
157 |
| - .filter(parameterType -> !ReactiveWrapperConverters.supports(parameterType)) // |
158 |
| - .forEach(parameterType -> { |
159 |
| - throw new InvalidDataAccessApiUsageException( |
160 |
| - String.format("No reactive type converter found for type %s used in %s, method %s.", |
161 |
| - parameterType.getName(), method.getDeclaringClass().getName(), method)); |
162 |
| - }); |
163 |
| - } |
164 |
| - |
165 | 112 | @SuppressWarnings("unchecked")
|
166 | 113 | private <T, ID extends Serializable> MongoEntityInformation<T, ID> getEntityInformation(Class<T> domainClass,
|
167 | 114 | RepositoryInformation information) {
|
|
0 commit comments