-
Notifications
You must be signed in to change notification settings - Fork 2.3k
/
CoreRuntimeHints.java
98 lines (89 loc) · 4.38 KB
/
CoreRuntimeHints.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
/*
* Copyright 2022-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.batch.core.aot;
import java.sql.Types;
import java.time.Duration;
import java.time.Instant;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.OffsetDateTime;
import java.time.OffsetTime;
import java.time.Period;
import java.time.ZonedDateTime;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.Properties;
import java.util.UUID;
import java.util.stream.Stream;
import org.springframework.aop.SpringProxy;
import org.springframework.aop.framework.Advised;
import org.springframework.aot.hint.MemberCategory;
import org.springframework.aot.hint.RuntimeHints;
import org.springframework.aot.hint.RuntimeHintsRegistrar;
import org.springframework.aot.hint.SerializationHints;
import org.springframework.aot.hint.TypeReference;
import org.springframework.batch.core.scope.context.JobContext;
import org.springframework.batch.core.scope.context.StepContext;
import org.springframework.core.DecoratingProxy;
/**
* {@link RuntimeHintsRegistrar} for Spring Batch core module.
*
* @author Glenn Renfro
* @author Mahmoud Ben Hassine
* @author Alexander Arshavskiy
* @since 5.0
*/
public class CoreRuntimeHints implements RuntimeHintsRegistrar {
@Override
public void registerHints(RuntimeHints hints, ClassLoader classLoader) {
// resource hints
hints.resources().registerPattern("org/springframework/batch/core/schema-h2.sql");
hints.resources().registerPattern("org/springframework/batch/core/schema-derby.sql");
hints.resources().registerPattern("org/springframework/batch/core/schema-hsqldb.sql");
hints.resources().registerPattern("org/springframework/batch/core/schema-sqlite.sql");
hints.resources().registerPattern("org/springframework/batch/core/schema-db2.sql");
hints.resources().registerPattern("org/springframework/batch/core/schema-hana.sql");
hints.resources().registerPattern("org/springframework/batch/core/schema-mysql.sql");
hints.resources().registerPattern("org/springframework/batch/core/schema-mariadb.sql");
hints.resources().registerPattern("org/springframework/batch/core/schema-oracle.sql");
hints.resources().registerPattern("org/springframework/batch/core/schema-postgresql.sql");
hints.resources().registerPattern("org/springframework/batch/core/schema-sqlserver.sql");
hints.resources().registerPattern("org/springframework/batch/core/schema-sybase.sql");
// proxy hints
hints.proxies()
.registerJdkProxy(builder -> builder
.proxiedInterfaces(TypeReference.of("org.springframework.batch.core.repository.JobRepository"))
.proxiedInterfaces(SpringProxy.class, Advised.class, DecoratingProxy.class))
.registerJdkProxy(builder -> builder
.proxiedInterfaces(TypeReference.of("org.springframework.batch.core.explore.JobExplorer"))
.proxiedInterfaces(SpringProxy.class, Advised.class, DecoratingProxy.class));
// reflection hints
hints.reflection().registerType(Types.class, MemberCategory.DECLARED_FIELDS);
hints.reflection().registerType(JobContext.class, MemberCategory.INVOKE_PUBLIC_METHODS);
hints.reflection().registerType(StepContext.class, MemberCategory.INVOKE_PUBLIC_METHODS);
// serialization hints
SerializationHints serializationHints = hints.serialization();
Stream.of(Number.class, Byte.class, Short.class, Integer.class, Long.class, Double.class, Float.class,
Character.class, String.class, Boolean.class, Date.class, Calendar.class, LocalDate.class,
LocalTime.class, LocalDateTime.class, OffsetTime.class, OffsetDateTime.class, ZonedDateTime.class,
Instant.class, Duration.class, Period.class, HashMap.class, Hashtable.class, ArrayList.class,
Properties.class, Exception.class, UUID.class).forEach(serializationHints::registerType);
}
}