24
24
import org .springframework .aot .hint .TypeReference ;
25
25
import org .springframework .beans .factory .BeanFactory ;
26
26
import org .springframework .core .io .InputStreamSource ;
27
+ import org .springframework .data .domain .Example ;
27
28
import org .springframework .data .mapping .context .MappingContext ;
29
+ import org .springframework .data .querydsl .QuerydslPredicateExecutor ;
30
+ import org .springframework .data .querydsl .QuerydslUtils ;
31
+ import org .springframework .data .querydsl .ReactiveQuerydslPredicateExecutor ;
28
32
import org .springframework .data .repository .core .RepositoryMetadata ;
29
33
import org .springframework .data .repository .core .support .RepositoryFactoryBeanSupport ;
30
34
import org .springframework .data .repository .core .support .RepositoryFragment ;
34
38
import org .springframework .data .repository .query .FluentQuery .FetchableFluentQuery ;
35
39
import org .springframework .data .repository .query .FluentQuery .ReactiveFluentQuery ;
36
40
import org .springframework .data .repository .query .QueryByExampleExecutor ;
41
+ import org .springframework .data .repository .query .ReactiveQueryByExampleExecutor ;
37
42
import org .springframework .lang .Nullable ;
43
+ import org .springframework .util .ClassUtils ;
44
+
45
+ import com .querydsl .core .types .Predicate ;
38
46
39
47
/**
40
48
* {@link RuntimeHintsRegistrar} holding required hints to bootstrap data repositories. <br />
41
49
* Already registered via {@literal aot.factories}.
42
50
*
43
51
* @author Christoph Strobl
52
+ * @author Mark Paluch
44
53
* @since 3.0
45
54
*/
46
55
class RepositoryRuntimeHints implements RuntimeHintsRegistrar {
47
56
57
+ private static final boolean PROJECT_REACTOR_PRESENT = ClassUtils .isPresent ("reactor.core.publisher.Flux" ,
58
+ RepositoryRuntimeHints .class .getClassLoader ());
59
+
48
60
@ Override
49
61
public void registerHints (RuntimeHints hints , @ Nullable ClassLoader classLoader ) {
50
62
@@ -54,16 +66,45 @@ public void registerHints(RuntimeHints hints, @Nullable ClassLoader classLoader)
54
66
TypeReference .of (RepositoryFragmentsFactoryBean .class ), //
55
67
TypeReference .of (RepositoryFragment .class ), //
56
68
TypeReference .of (TransactionalRepositoryFactoryBeanSupport .class ), //
69
+ TypeReference .of (Example .class ), //
57
70
TypeReference .of (QueryByExampleExecutor .class ), //
58
71
TypeReference .of (MappingContext .class ), //
59
72
TypeReference .of (RepositoryMetadata .class ), //
60
73
TypeReference .of (FluentQuery .class ), //
61
- TypeReference .of (FetchableFluentQuery .class ), //
62
- TypeReference .of (ReactiveFluentQuery .class ) //
74
+ TypeReference .of (FetchableFluentQuery .class ) //
63
75
), builder -> {
64
76
builder .withMembers (MemberCategory .INVOKE_PUBLIC_METHODS );
65
77
});
66
78
79
+ if (PROJECT_REACTOR_PRESENT ) {
80
+
81
+ // repository infrastructure
82
+ hints .reflection ().registerTypes (Arrays .asList ( //
83
+ TypeReference .of (ReactiveFluentQuery .class ), //
84
+ TypeReference .of (ReactiveQueryByExampleExecutor .class )), //
85
+ builder -> {
86
+ builder .withMembers (MemberCategory .INVOKE_PUBLIC_METHODS );
87
+ });
88
+ }
89
+
90
+ if (QuerydslUtils .QUERY_DSL_PRESENT ) {
91
+
92
+ // repository infrastructure
93
+ hints .reflection ().registerTypes (Arrays .asList ( //
94
+ TypeReference .of (Predicate .class ), //
95
+ TypeReference .of (QuerydslPredicateExecutor .class )), builder -> {
96
+ builder .withMembers (MemberCategory .INVOKE_PUBLIC_METHODS );
97
+ });
98
+
99
+ if (PROJECT_REACTOR_PRESENT ) {
100
+ // repository infrastructure
101
+ hints .reflection ().registerTypes (Arrays .asList ( //
102
+ TypeReference .of (ReactiveQuerydslPredicateExecutor .class )), builder -> {
103
+ builder .withMembers (MemberCategory .INVOKE_PUBLIC_METHODS );
104
+ });
105
+ }
106
+ }
107
+
67
108
// named queries
68
109
hints .reflection ().registerTypes (Arrays .asList ( //
69
110
TypeReference .of (Properties .class ), //
0 commit comments