|
| 1 | +/* |
| 2 | + * Copyright 2011-2022 the original author or authors. |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * https://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | +package org.springframework.data.neo4j.aot; |
| 17 | + |
| 18 | +import org.springframework.aot.hint.MemberCategory; |
| 19 | +import org.springframework.aot.hint.RuntimeHints; |
| 20 | +import org.springframework.aot.hint.RuntimeHintsRegistrar; |
| 21 | +import org.springframework.aot.hint.TypeReference; |
| 22 | +import org.springframework.data.neo4j.core.mapping.callback.AfterConvertCallback; |
| 23 | +import org.springframework.data.neo4j.core.mapping.callback.BeforeBindCallback; |
| 24 | +import org.springframework.data.neo4j.core.schema.GeneratedValue; |
| 25 | +import org.springframework.data.neo4j.core.support.UUIDStringGenerator; |
| 26 | +import org.springframework.data.neo4j.repository.query.SimpleQueryByExampleExecutor; |
| 27 | +import org.springframework.data.neo4j.repository.support.SimpleNeo4jRepository; |
| 28 | +import org.springframework.lang.Nullable; |
| 29 | + |
| 30 | +import java.util.Arrays; |
| 31 | + |
| 32 | +/** |
| 33 | + * @author Gerrit Meier |
| 34 | + * @since 7.0.0 |
| 35 | + */ |
| 36 | +public class Neo4jRuntimeHints implements RuntimeHintsRegistrar { |
| 37 | + |
| 38 | + @Override |
| 39 | + public void registerHints(RuntimeHints hints, @Nullable ClassLoader classLoader) { |
| 40 | + |
| 41 | + hints.reflection().registerTypes( |
| 42 | + Arrays.asList( |
| 43 | + TypeReference.of(SimpleNeo4jRepository.class), |
| 44 | + TypeReference.of(SimpleQueryByExampleExecutor.class), |
| 45 | + TypeReference.of(BeforeBindCallback.class), |
| 46 | + TypeReference.of(AfterConvertCallback.class), |
| 47 | + // todo "temporary" fix, should get resolved when defined in @GeneratedValue |
| 48 | + TypeReference.of(UUIDStringGenerator.class), |
| 49 | + TypeReference.of(GeneratedValue.InternalIdGenerator.class), |
| 50 | + TypeReference.of(GeneratedValue.UUIDGenerator.class) |
| 51 | + ), |
| 52 | + builder -> builder.withMembers(MemberCategory.INVOKE_DECLARED_CONSTRUCTORS, |
| 53 | + MemberCategory.INVOKE_PUBLIC_METHODS)); |
| 54 | + } |
| 55 | +} |
0 commit comments