16
16
package org .springframework .data .redis .repository .support ;
17
17
18
18
import java .io .Serializable ;
19
- import java .lang .reflect .Method ;
20
19
21
20
import org .springframework .data .keyvalue .core .KeyValueOperations ;
22
- import org .springframework .data .keyvalue .repository .query .KeyValuePartTreeQuery ;
23
- import org .springframework .data .keyvalue .repository .query .KeyValuePartTreeQuery .QueryInitialization ;
24
21
import org .springframework .data .keyvalue .repository .support .KeyValueRepositoryFactory ;
25
- import org .springframework .data .projection .ProjectionFactory ;
26
22
import org .springframework .data .redis .core .mapping .RedisPersistentEntity ;
27
23
import org .springframework .data .redis .repository .core .MappingRedisEntityInformation ;
24
+ import org .springframework .data .redis .repository .query .RedisQueryCreator ;
28
25
import org .springframework .data .repository .core .EntityInformation ;
29
- import org .springframework .data .repository .core .NamedQueries ;
30
- import org .springframework .data .repository .core .RepositoryMetadata ;
31
26
import org .springframework .data .repository .core .support .RepositoryFactorySupport ;
32
- import org .springframework .data .repository .query .EvaluationContextProvider ;
33
- import org .springframework .data .repository .query .QueryLookupStrategy ;
34
- import org .springframework .data .repository .query .QueryLookupStrategy .Key ;
35
- import org .springframework .data .repository .query .QueryMethod ;
36
- import org .springframework .data .repository .query .RepositoryQuery ;
37
27
import org .springframework .data .repository .query .parser .AbstractQueryCreator ;
38
- import org .springframework .util .Assert ;
39
28
40
29
/**
41
30
* {@link RepositoryFactorySupport} specific of handing Redis
48
37
public class RedisRepositoryFactory extends KeyValueRepositoryFactory {
49
38
50
39
private final KeyValueOperations operations ;
51
- private final Class <? extends AbstractQueryCreator <?, ?>> queryCreator ;
52
40
53
41
/**
54
42
* @param keyValueOperations
55
43
* @see KeyValueRepositoryFactory#KeyValueRepositoryFactory(KeyValueOperations)
56
44
*/
57
45
public RedisRepositoryFactory (KeyValueOperations keyValueOperations ) {
58
- this (keyValueOperations , DEFAULT_QUERY_CREATOR );
46
+ this (keyValueOperations , RedisQueryCreator . class );
59
47
}
60
48
61
49
/**
@@ -68,16 +56,6 @@ public RedisRepositoryFactory(KeyValueOperations keyValueOperations,
68
56
super (keyValueOperations , queryCreator );
69
57
70
58
this .operations = keyValueOperations ;
71
- this .queryCreator = queryCreator ;
72
- }
73
-
74
- /*
75
- * (non-Javadoc)
76
- * @see org.springframework.data.keyvalue.repository.support.KeyValueRepositoryFactory#getQueryLookupStrategy(org.springframework.data.repository.query.QueryLookupStrategy.Key, org.springframework.data.repository.query.EvaluationContextProvider)
77
- */
78
- @ Override
79
- protected QueryLookupStrategy getQueryLookupStrategy (Key key , EvaluationContextProvider evaluationContextProvider ) {
80
- return new RedisQueryLookupStrategy (key , evaluationContextProvider , operations , queryCreator );
81
59
}
82
60
83
61
/*
@@ -95,53 +73,4 @@ public <T, ID extends Serializable> EntityInformation<T, ID> getEntityInformatio
95
73
96
74
return entityInformation ;
97
75
}
98
-
99
- /**
100
- * @author Christoph Strobl
101
- * @since 1.7
102
- */
103
- private static class RedisQueryLookupStrategy implements QueryLookupStrategy {
104
-
105
- private EvaluationContextProvider evaluationContextProvider ;
106
- private KeyValueOperations keyValueOperations ;
107
-
108
- private Class <? extends AbstractQueryCreator <?, ?>> queryCreator ;
109
-
110
- /**
111
- * Creates a new {@link RedisQueryLookupStrategy} for the given {@link Key}, {@link EvaluationContextProvider},
112
- * {@link KeyValueOperations} and query creator type.
113
- * <p>
114
- *
115
- * @param key
116
- * @param evaluationContextProvider must not be {@literal null}.
117
- * @param keyValueOperations must not be {@literal null}.
118
- * @param queryCreator must not be {@literal null}.
119
- */
120
- public RedisQueryLookupStrategy (Key key , EvaluationContextProvider evaluationContextProvider ,
121
- KeyValueOperations keyValueOperations , Class <? extends AbstractQueryCreator <?, ?>> queryCreator ) {
122
-
123
- Assert .notNull (evaluationContextProvider , "EvaluationContextProvider must not be null!" );
124
- Assert .notNull (keyValueOperations , "KeyValueOperations must not be null!" );
125
- Assert .notNull (queryCreator , "Query creator type must not be null!" );
126
-
127
- this .evaluationContextProvider = evaluationContextProvider ;
128
- this .keyValueOperations = keyValueOperations ;
129
- this .queryCreator = queryCreator ;
130
- }
131
-
132
- /*
133
- * (non-Javadoc)
134
- * @see org.springframework.data.repository.query.QueryLookupStrategy#resolveQuery(java.lang.reflect.Method, org.springframework.data.repository.core.RepositoryMetadata, org.springframework.data.repository.core.NamedQueries)
135
- */
136
- @ Override
137
- public RepositoryQuery resolveQuery (Method method , RepositoryMetadata metadata , ProjectionFactory factory ,
138
- NamedQueries namedQueries ) {
139
-
140
- QueryMethod queryMethod = new QueryMethod (method , metadata , factory );
141
- KeyValuePartTreeQuery partTreeQuery = new KeyValuePartTreeQuery (queryMethod , evaluationContextProvider ,
142
- this .keyValueOperations , this .queryCreator );
143
- partTreeQuery .setQueryIntialization (QueryInitialization .NEW );
144
- return partTreeQuery ;
145
- }
146
- }
147
76
}
0 commit comments