7
7
import io .fabric8 .kubernetes .client .CustomResourceDoneable ;
8
8
import io .javaoperatorsdk .operator .api .config .ControllerConfiguration ;
9
9
import io .javaoperatorsdk .operator .api .config .RetryConfiguration ;
10
+ import io .quarkus .runtime .annotations .RecordableConstructor ;
10
11
11
12
public class QuarkusControllerConfiguration <R extends CustomResource > implements ControllerConfiguration <R > {
12
- private String name ;
13
- private String crdName ;
14
- private String finalizer ;
15
- private boolean generationAware ;
16
- private boolean clusterScoped ;
17
- private Set <String > namespaces ;
18
- private Class <R > crClass ;
19
- private Class <CustomResourceDoneable <R >> doneableClass ;
20
- private boolean watchAllNamespaces ;
21
- private RetryConfiguration retryConfiguration ;
22
-
23
- // For serialization
24
- public QuarkusControllerConfiguration () {
25
- }
26
-
27
- public QuarkusControllerConfiguration (String name , String crdName , String finalizer , boolean generationAware , boolean clusterScoped , String [] namespaces , Class crClass , String doneableClass , RetryConfiguration retryConfiguration ) {
13
+ private final String name ;
14
+ private final String crdName ;
15
+ private final String finalizer ;
16
+ private final boolean generationAware ;
17
+ private final boolean clusterScoped ;
18
+ private final Set <String > namespaces ;
19
+ private final String crClass ;
20
+ private final String doneableClass ;
21
+ private final boolean watchAllNamespaces ;
22
+ private final RetryConfiguration retryConfiguration ;
23
+
24
+ @ RecordableConstructor
25
+ public QuarkusControllerConfiguration (String name , String crdName , String finalizer , boolean generationAware , boolean clusterScoped , String [] namespaces , String crClass , String doneableClass , RetryConfiguration retryConfiguration ) {
28
26
this .name = name ;
29
27
this .crdName = crdName ;
30
28
this .finalizer = finalizer ;
31
29
this .generationAware = generationAware ;
32
30
this .clusterScoped = clusterScoped ;
33
31
this .namespaces = namespaces == null || namespaces .length == 0 ? Collections .emptySet () : Set .of (namespaces );
34
32
this .crClass = crClass ;
35
- try {
36
- this .doneableClass = (Class <CustomResourceDoneable <R >>) Thread .currentThread ().getContextClassLoader ().loadClass (doneableClass );
37
- } catch (ClassNotFoundException e ) {
38
- throw new IllegalArgumentException ("Couldn't find class " + doneableClass );
39
- }
33
+ this .doneableClass = doneableClass ;
40
34
this .watchAllNamespaces = this .namespaces .contains (WATCH_ALL_NAMESPACES_MARKER );
41
35
this .retryConfiguration = retryConfiguration == null ? ControllerConfiguration .super .getRetryConfiguration () : retryConfiguration ;
42
36
}
@@ -63,12 +57,20 @@ public boolean isGenerationAware() {
63
57
64
58
@ Override
65
59
public Class <R > getCustomResourceClass () {
66
- return crClass ;
60
+ try {
61
+ return (Class <R >) Thread .currentThread ().getContextClassLoader ().loadClass (crClass );
62
+ } catch (ClassNotFoundException e ) {
63
+ throw new IllegalArgumentException ("Couldn't find class " + crClass );
64
+ }
67
65
}
68
66
69
67
@ Override
70
68
public Class <? extends CustomResourceDoneable <R >> getDoneableClass () {
71
- return doneableClass ;
69
+ try {
70
+ return (Class <CustomResourceDoneable <R >>) Thread .currentThread ().getContextClassLoader ().loadClass (doneableClass );
71
+ } catch (ClassNotFoundException e ) {
72
+ throw new IllegalArgumentException ("Couldn't find class " + doneableClass );
73
+ }
72
74
}
73
75
74
76
@ Override
@@ -90,54 +92,4 @@ public boolean watchAllNamespaces() {
90
92
public RetryConfiguration getRetryConfiguration () {
91
93
return retryConfiguration ;
92
94
}
93
-
94
- // For serialization
95
- public void setName (String name ) {
96
- this .name = name ;
97
- }
98
-
99
- // For serialization
100
- public void setCrdName (String crdName ) {
101
- this .crdName = crdName ;
102
- }
103
-
104
- // For serialization
105
- void setFinalizer (String finalizer ) {
106
- this .finalizer = finalizer ;
107
- }
108
-
109
- // For serialization
110
- public void setGenerationAware (boolean generationAware ) {
111
- this .generationAware = generationAware ;
112
- }
113
-
114
- // For serialization
115
- public void setClusterScoped (boolean clusterScoped ) {
116
- this .clusterScoped = clusterScoped ;
117
- }
118
-
119
- // For serialization
120
- public void setNamespaces (Set <String > namespaces ) {
121
- this .namespaces = namespaces ;
122
- }
123
-
124
- // For serialization
125
- public void setCrClass (Class <R > crClass ) {
126
- this .crClass = crClass ;
127
- }
128
-
129
- // For serialization
130
- public void setDoneableClass (Class <CustomResourceDoneable <R >> doneableClass ) {
131
- this .doneableClass = doneableClass ;
132
- }
133
-
134
- // For serialization
135
- public void setWatchAllNamespaces (boolean watchAllNamespaces ) {
136
- this .watchAllNamespaces = watchAllNamespaces ;
137
- }
138
-
139
- // For serialization
140
- public void setRetryConfiguration (RetryConfiguration retryConfiguration ) {
141
- this .retryConfiguration = retryConfiguration ;
142
- }
143
95
}
0 commit comments