15
15
import static org .jboss .as .controller .descriptions .ModelDescriptionConstants .OP ;
16
16
import static org .jboss .as .controller .descriptions .ModelDescriptionConstants .OP_ADDR ;
17
17
import static org .jboss .as .controller .descriptions .ModelDescriptionConstants .REMOVE ;
18
+ import static org .jboss .as .controller .descriptions .ModelDescriptionConstants .SUBSYSTEM ;
18
19
import static org .jboss .as .controller .descriptions .ModelDescriptionConstants .UNDEFINE_ATTRIBUTE_OPERATION ;
19
20
import static org .jboss .as .controller .descriptions .ModelDescriptionConstants .URL ;
20
21
import static org .jboss .as .controller .descriptions .ModelDescriptionConstants .VALUE ;
45
46
import org .jboss .as .controller .MapAttributeDefinition ;
46
47
import org .jboss .as .controller .ObjectMapAttributeDefinition ;
47
48
import org .jboss .as .controller .ObjectTypeAttributeDefinition ;
49
+ import org .jboss .as .controller .ParallelBootOperationStepHandler ;
48
50
import org .jboss .as .controller .ParsedBootOp ;
49
51
import org .jboss .as .controller .PathAddress ;
50
52
import org .jboss .as .controller .RunningMode ;
@@ -160,11 +162,20 @@ public void processOperations(ImmutableManagementResourceRegistration rootRegist
160
162
}
161
163
MGMT_OP_LOGGER .debug ("We are applying YAML files to the configuration" );
162
164
Map <PathAddress , ParsedBootOp > xmlOperations = new HashMap <>();
165
+ boolean paralleBoot = false ;
163
166
for (ParsedBootOp op : postExtensionOps ) {
164
- if (op .getChildOperations ().isEmpty ()) {
167
+ List <ModelNode > childOperations = op .getChildOperations ();
168
+ if (childOperations .isEmpty ()) {
165
169
xmlOperations .put (op .getAddress (), op );
166
170
} else {
167
- for (ModelNode childOp : op .getChildOperations ()) {
171
+ if (op .handler instanceof ParallelBootOperationStepHandler ) {
172
+ if (!paralleBoot ) {
173
+ paralleBoot = true ;
174
+ } else {
175
+ MGMT_OP_LOGGER .multipleParallelBootOperation ();
176
+ }
177
+ }
178
+ for (ModelNode childOp : childOperations ) {
168
179
ParsedBootOp subOp = new ParsedBootOp (childOp , null );
169
180
xmlOperations .put (subOp .getAddress (), subOp );
170
181
}
@@ -176,10 +187,44 @@ public void processOperations(ImmutableManagementResourceRegistration rootRegist
176
187
for (Map .Entry <String , Object > deployment : deployments .entrySet ()) {
177
188
processUnmanagedDeployments (rootRegistration , deployment , xmlOperations , postExtensionOps );
178
189
}
190
+ List <ParsedBootOp > reorderedList = new ArrayList <>(postExtensionOps .size ());
191
+ //We need to find the parallel boot operation becaue it might have changed due to deletion of resource so we can't use the initial one.
192
+ ParsedBootOp parallelBootOp = null ;
193
+ if (paralleBoot ) {
194
+ for (ParsedBootOp op : postExtensionOps ) {
195
+ if (op .handler instanceof ParallelBootOperationStepHandler ) {
196
+ if (parallelBootOp == null ) {
197
+ parallelBootOp = op ;
198
+ parallelBootOp .bootHandlerUpdateNeeded ();
199
+ break ;
200
+ }
201
+ }
202
+ }
203
+ }
204
+ for (ParsedBootOp op : postExtensionOps ) {
205
+ // ModelControllerImpl doesn't include subsystem ops directly in the postExtensionsOps param in parallel boot.
206
+ // So, if postExtensionOps contains a subsystem op, it's because we've created it from YAML.
207
+ if (parallelBootOp != null && isSubsystemOperation (op )) {
208
+ //The new operations created from the YAML are added to the parallel boot operation enclosing all the subsystem operations
209
+ parallelBootOp .addChildOperation (op );
210
+ } else if (op .handler instanceof ParallelBootOperationStepHandler ) {
211
+ //The parallel boot operation is added to the list
212
+ reorderedList .add (parallelBootOp );
213
+ } else {
214
+ //The new operations created from the YAML are added to the list of operations (if they haven't already be added in a subsystem enclosing operation).
215
+ reorderedList .add (op );
216
+ }
217
+ }
218
+ postExtensionOps .clear ();
219
+ postExtensionOps .addAll (reorderedList );
179
220
this .configs .clear ();
180
221
needReload = true ;
181
222
}
182
223
224
+ private boolean isSubsystemOperation (ParsedBootOp op ) {
225
+ return op .getAddress ().size () > 0 && SUBSYSTEM .equals (op .getAddress ().getElement (0 ).getKey ());
226
+ }
227
+
183
228
@ SuppressWarnings ("unchecked" )
184
229
private void processResource (PathAddress parentAddress , Map <String , Object > yaml , ImmutableManagementResourceRegistration rootRegistration , ImmutableManagementResourceRegistration resourceRegistration , Map <PathAddress , ParsedBootOp > xmlOperations , List <ParsedBootOp > postExtensionOps , boolean placeHolder ) {
185
230
for (String name : yaml .keySet ()) {
@@ -424,7 +469,7 @@ private void processAttributes(PathAddress address, ImmutableManagementResourceR
424
469
}
425
470
}
426
471
for (AttributeDefinition def : operationEntry .getOperationDefinition ().getParameters ()) {
427
- if (def != null && ! attributeNames .contains (def .getName ())) {
472
+ if (def != null && !attributeNames .contains (def .getName ())) {
428
473
if (!def .isResourceOnly ()) {
429
474
attributes .add (def );
430
475
}
0 commit comments