|
13 | 13 | * See the License for the specific language governing permissions and
|
14 | 14 | * limitations under the License.
|
15 | 15 | */
|
16 |
| -package org.springframework.data.aot; |
| 16 | +package org.springframework.data.aot.hint; |
17 | 17 |
|
18 | 18 | import java.util.Arrays;
|
19 | 19 | import java.util.Properties;
|
20 | 20 |
|
21 |
| -import org.springframework.aop.SpringProxy; |
22 |
| -import org.springframework.aop.framework.Advised; |
23 | 21 | import org.springframework.aot.hint.MemberCategory;
|
24 | 22 | import org.springframework.aot.hint.RuntimeHints;
|
25 | 23 | import org.springframework.aot.hint.RuntimeHintsRegistrar;
|
26 | 24 | import org.springframework.aot.hint.TypeReference;
|
27 | 25 | import org.springframework.beans.factory.BeanFactory;
|
28 |
| -import org.springframework.core.DecoratingProxy; |
29 | 26 | import org.springframework.core.io.InputStreamSource;
|
30 |
| -import org.springframework.data.domain.AuditorAware; |
31 | 27 | import org.springframework.data.mapping.context.MappingContext;
|
32 | 28 | import org.springframework.data.repository.core.RepositoryMetadata;
|
33 | 29 | import org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport;
|
|
38 | 34 | import org.springframework.lang.Nullable;
|
39 | 35 |
|
40 | 36 | /**
|
| 37 | + * {@link RuntimeHintsRegistrar} holding required hints to bootstrap data repositories. <br /> |
| 38 | + * Already registered via {@literal aot.factories}. |
| 39 | + * |
41 | 40 | * @author Christoph Strobl
|
42 | 41 | * @since 3.0
|
43 | 42 | */
|
44 |
| -public class DataRuntimeHints implements RuntimeHintsRegistrar { |
| 43 | +public class RepositoryRuntimeHints implements RuntimeHintsRegistrar { |
45 | 44 |
|
46 | 45 | @Override
|
47 | 46 | public void registerHints(RuntimeHints hints, @Nullable ClassLoader classLoader) {
|
48 | 47 |
|
49 |
| - System.out.println("Spring data Runtime Hints"); |
| 48 | + // repository infrastructure |
| 49 | + hints.reflection().registerTypes(Arrays.asList( // |
| 50 | + TypeReference.of(RepositoryFactoryBeanSupport.class), // |
| 51 | + TypeReference.of(RepositoryFragmentsFactoryBean.class), // |
| 52 | + TypeReference.of(RepositoryFragment.class), // |
| 53 | + TypeReference.of(TransactionalRepositoryFactoryBeanSupport.class), // |
| 54 | + TypeReference.of(QueryByExampleExecutor.class), // |
| 55 | + TypeReference.of(MappingContext.class), // |
| 56 | + TypeReference.of(RepositoryMetadata.class) // |
| 57 | + ), builder -> { |
| 58 | + builder.withMembers(MemberCategory.INVOKE_PUBLIC_METHODS); |
| 59 | + }); |
50 | 60 |
|
51 |
| - hints.reflection() |
52 |
| - .registerTypes(Arrays.asList(TypeReference.of(RepositoryFactoryBeanSupport.class), |
53 |
| - TypeReference.of(RepositoryFragmentsFactoryBean.class), TypeReference.of(RepositoryFragment.class), |
54 |
| - TypeReference.of(TransactionalRepositoryFactoryBeanSupport.class), |
55 |
| - TypeReference.of(QueryByExampleExecutor.class), TypeReference.of(MappingContext.class), |
56 |
| - TypeReference.of(RepositoryMetadata.class)), builder -> { |
57 |
| - builder.withMembers(MemberCategory.INVOKE_PUBLIC_METHODS); |
58 |
| - }); |
59 |
| - hints.reflection().registerTypes( |
60 |
| - Arrays.asList(TypeReference.of(Properties.class), TypeReference.of(BeanFactory.class), |
61 |
| - TypeReference.of(InputStreamSource[].class)), |
62 |
| - builder -> builder.withMembers(MemberCategory.INVOKE_PUBLIC_METHODS)); |
| 61 | + // named queries |
| 62 | + hints.reflection().registerTypes(Arrays.asList( // |
| 63 | + TypeReference.of(Properties.class), // |
| 64 | + TypeReference.of(BeanFactory.class), // |
| 65 | + TypeReference.of(InputStreamSource[].class) // |
| 66 | + ), builder -> builder.withMembers(MemberCategory.INVOKE_PUBLIC_METHODS)); |
63 | 67 |
|
| 68 | + // |
64 | 69 | hints.reflection().registerType(Throwable.class,
|
65 | 70 | builder -> builder.withMembers(MemberCategory.INVOKE_DECLARED_CONSTRUCTORS, MemberCategory.DECLARED_FIELDS));
|
66 | 71 |
|
| 72 | + // SpEL support |
67 | 73 | hints.reflection().registerType(
|
68 | 74 | TypeReference.of("org.springframework.data.projection.SpelEvaluatingMethodInterceptor$TargetWrapper"),
|
69 | 75 | builder -> builder.withMembers(MemberCategory.INVOKE_DECLARED_CONSTRUCTORS,
|
70 | 76 | MemberCategory.INVOKE_DECLARED_METHODS, MemberCategory.INVOKE_PUBLIC_METHODS));
|
71 | 77 |
|
72 |
| - hints.proxies().registerJdkProxy(TypeReference.of("org.springframework.data.annotation.QueryAnnotation"), |
| 78 | + // annotated queries |
| 79 | + hints.proxies().registerJdkProxy( // |
| 80 | + TypeReference.of("org.springframework.data.annotation.QueryAnnotation"), // |
73 | 81 | TypeReference.of("org.springframework.core.annotation.SynthesizedAnnotation"));
|
74 | 82 | }
|
75 | 83 | }
|
0 commit comments