Skip to content
Snippets Groups Projects
Commit fe859ab5 authored by OZGCloud's avatar OZGCloud
Browse files

spring native hints

parent bfa44afd
No related branches found
No related tags found
No related merge requests found
...@@ -38,6 +38,13 @@ ...@@ -38,6 +38,13 @@
<!-- <groupId>org.apache.logging.log4j</groupId>--> <!-- <groupId>org.apache.logging.log4j</groupId>-->
<!-- <artifactId>log4j-core</artifactId>--> <!-- <artifactId>log4j-core</artifactId>-->
<!-- </dependency>--> <!-- </dependency>-->
<!-- https://mvnrepository.com/artifact/org.reflections/reflections -->
<dependency>
<groupId>org.reflections</groupId>
<artifactId>reflections</artifactId>
<version>0.10.2</version>
</dependency>
......
package de.ozgcloud.operator; package de.ozgcloud.operator;
import java.util.HashSet;
import java.util.Objects;
import org.reflections.Reflections;
import org.springframework.aot.hint.MemberCategory;
import org.springframework.aot.hint.RuntimeHints; import org.springframework.aot.hint.RuntimeHints;
import org.springframework.aot.hint.RuntimeHintsRegistrar; import org.springframework.aot.hint.RuntimeHintsRegistrar;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.ImportRuntimeHints; import org.springframework.context.annotation.ImportRuntimeHints;
import io.fabric8.kubernetes.client.impl.KubernetesClientImpl; import io.fabric8.kubernetes.api.model.KubernetesResource;
import io.fabric8.kubernetes.api.model.NamedCluster;
import lombok.extern.slf4j.Slf4j;
@Configuration @Configuration
@ImportRuntimeHints(SpringNativeConfiguration.KuberenetesCLientImplHints.class) @ImportRuntimeHints(SpringNativeConfiguration.KuberenetesCLientImplHints.class)
@Slf4j
public class SpringNativeConfiguration { public class SpringNativeConfiguration {
static class KuberenetesCLientImplHints implements RuntimeHintsRegistrar { static class KuberenetesCLientImplHints implements RuntimeHintsRegistrar {
private final Class<?> clazz = NamedCluster.class;
private final Reflections reflections = new Reflections(clazz.getPackageName(), clazz);
@Override @Override
public void registerHints(RuntimeHints hints, ClassLoader classLoader) { public void registerHints(RuntimeHints hints, ClassLoader classLoader) {
hints.reflection() // https://github.com/kubernetes-native-java/fabric8-spring-native/
.registerType(KubernetesClientImpl.class); var subtypesOfKubernetesResource = reflections.getSubTypesOf(KubernetesResource.class);
var combined = new HashSet<Class<?>>();
combined.addAll(subtypesOfKubernetesResource);
combined.add(io.fabric8.kubernetes.internal.KubernetesDeserializer.class);
combined.add(io.fabric8.kubernetes.client.impl.KubernetesClientImpl.class);
combined
.stream()
.filter(Objects::nonNull)
.forEach(c -> {
if (log.isDebugEnabled()) {
log.debug("trying to register " + c.getName() + " for reflection");
}
hints.reflection().registerType(c, MemberCategory.values());
// registry.reflection().forType(c).withAccess(TypeAccess.values()).build();
});
// hints.reflection().registerType(clazz, null)
// .registerType(KubernetesClientImpl.class, MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS);
} }
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment