11package io .javaoperatorsdk .quarkus .extension ;
22
33import io .fabric8 .kubernetes .client .CustomResource ;
4- import io .javaoperatorsdk .operator .api .config .ControllerConfiguration ;
4+ import io .javaoperatorsdk .operator .api .config .AbstractControllerConfiguration ;
55import io .javaoperatorsdk .operator .api .config .RetryConfiguration ;
66import io .quarkus .runtime .annotations .RecordableConstructor ;
77import java .util .Collections ;
88import java .util .Set ;
99
1010public class QuarkusControllerConfiguration <R extends CustomResource >
11- implements ControllerConfiguration <R > {
12- private final String associatedControllerClassName ;
13- private final String name ;
14- private final String crdName ;
15- private final String finalizer ;
16- private final boolean generationAware ;
17- private final Set <String > namespaces ;
11+ extends AbstractControllerConfiguration <R > {
12+
1813 private final String crClass ;
19- private final boolean watchAllNamespaces ;
20- private final RetryConfiguration retryConfiguration ;
14+ private Class <R > clazz ;
2115
2216 @ RecordableConstructor
2317 public QuarkusControllerConfiguration (
@@ -29,18 +23,15 @@ public QuarkusControllerConfiguration(
2923 Set <String > namespaces ,
3024 String crClass ,
3125 RetryConfiguration retryConfiguration ) {
32- this .associatedControllerClassName = associatedControllerClassName ;
33- this .name = name ;
34- this .crdName = crdName ;
35- this .finalizer = finalizer ;
36- this .generationAware = generationAware ;
37- this .namespaces = namespaces ;
26+ super (
27+ associatedControllerClassName ,
28+ name ,
29+ crdName ,
30+ finalizer ,
31+ generationAware ,
32+ namespaces ,
33+ retryConfiguration );
3834 this .crClass = crClass ;
39- this .watchAllNamespaces = this .namespaces .contains (WATCH_ALL_NAMESPACES_MARKER );
40- this .retryConfiguration =
41- retryConfiguration == null
42- ? ControllerConfiguration .super .getRetryConfiguration ()
43- : retryConfiguration ;
4435 }
4536
4637 public static Set <String > asSet (String [] namespaces ) {
@@ -59,29 +50,12 @@ public String getCrClass() {
5950 return crClass ;
6051 }
6152
62- @ Override
63- public String getName () {
64- return name ;
65- }
66-
67- @ Override
68- public String getCRDName () {
69- return crdName ;
70- }
71-
72- @ Override
73- public String getFinalizer () {
74- return finalizer ;
75- }
76-
77- @ Override
78- public boolean isGenerationAware () {
79- return generationAware ;
80- }
81-
8253 @ Override
8354 public Class <R > getCustomResourceClass () {
84- return (Class <R >) loadClass (crClass );
55+ if (clazz == null ) {
56+ clazz = (Class <R >) loadClass (crClass );
57+ }
58+ return clazz ;
8559 }
8660
8761 private Class <?> loadClass (String className ) {
@@ -91,24 +65,4 @@ private Class<?> loadClass(String className) {
9165 throw new IllegalArgumentException ("Couldn't find class " + className );
9266 }
9367 }
94-
95- @ Override
96- public String getAssociatedControllerClassName () {
97- return associatedControllerClassName ;
98- }
99-
100- @ Override
101- public Set <String > getNamespaces () {
102- return namespaces ;
103- }
104-
105- @ Override
106- public boolean watchAllNamespaces () {
107- return watchAllNamespaces ;
108- }
109-
110- @ Override
111- public RetryConfiguration getRetryConfiguration () {
112- return retryConfiguration ;
113- }
11468}
0 commit comments