@@ -74,13 +74,14 @@ public class FeatureSpecGenerator implements ForkCallback {
74
74
private Path standaloneSpecsFile ;
75
75
private Path domainSpecsFile ;
76
76
private String mimimumStability ;
77
+ private String description ;
77
78
78
79
String getBranchId (String spec , int dots ) {
79
80
int i = 0 ;
80
81
int index = 0 ;
81
- while (i <= dots ) {
82
+ while (i <= dots ) {
82
83
index = spec .indexOf ('.' , index + 1 );
83
- if (index < 0 ) {
84
+ if (index < 0 ) {
84
85
return spec ;
85
86
}
86
87
++i ;
@@ -98,8 +99,8 @@ FeatureSpecNode getSpec(String name) {
98
99
99
100
void addReferencedSpec (String referencedSpecName , String referencingSpec , FeatureSpecNode referencingNode ) {
100
101
Map <String , FeatureSpecNode > specs = referencedSpecs .get (referencedSpecName );
101
- if (specs != null ) {
102
- if (specs .size () == 1 ) {
102
+ if (specs != null ) {
103
+ if (specs .size () == 1 ) {
103
104
specs = new HashMap <>(specs );
104
105
referencedSpecs .put (referencedSpecName , specs );
105
106
}
@@ -141,13 +142,14 @@ public FeatureSpecGenerator() {
141
142
}
142
143
143
144
public FeatureSpecGenerator (String installation , Path outputDir , Map <String , Path > inheritedSpecs ,
144
- String mimimumStability , boolean fork , boolean debug ) {
145
+ String mimimumStability , String description , boolean fork , boolean debug ) {
145
146
this .installation = installation ;
146
147
this .outputDir = outputDir ;
147
148
this .fork = fork ;
148
149
this .debug = debug ;
149
150
this .inheritedSpecs = inheritedSpecs ;
150
151
this .mimimumStability = mimimumStability ;
152
+ this .description = description == null ? "" : description ;
151
153
}
152
154
153
155
public int generateSpecs () throws ProvisioningException {
@@ -156,24 +158,24 @@ public int generateSpecs() throws ProvisioningException {
156
158
doGenerate ();
157
159
} finally {
158
160
final List <String > toClear = new ArrayList <>();
159
- for (Map .Entry <Object , Object > prop : System .getProperties ().entrySet ()) {
161
+ for (Map .Entry <Object , Object > prop : System .getProperties ().entrySet ()) {
160
162
final Object value = originalProps .get (prop .getKey ());
161
163
if (value != null ) {
162
164
System .setProperty (prop .getKey ().toString (), value .toString ());
163
165
} else {
164
166
toClear .add (prop .getKey ().toString ());
165
167
}
166
168
}
167
- for (String prop : toClear ) {
169
+ for (String prop : toClear ) {
168
170
System .clearProperty (prop );
169
171
}
170
- if (systemProps != null ) {
172
+ if (systemProps != null ) {
171
173
IoUtils .recursiveDelete (systemProps );
172
174
}
173
- if (standaloneSpecsFile != null ) {
175
+ if (standaloneSpecsFile != null ) {
174
176
IoUtils .recursiveDelete (standaloneSpecsFile );
175
177
}
176
- if (domainSpecsFile != null ) {
178
+ if (domainSpecsFile != null ) {
177
179
IoUtils .recursiveDelete (domainSpecsFile );
178
180
}
179
181
}
@@ -183,9 +185,9 @@ public int generateSpecs() throws ProvisioningException {
183
185
private void doGenerate () throws ProvisioningException {
184
186
final ModelNode standaloneFeatures ;
185
187
ModelNode domainRoots = null ;
186
- if (fork ) {
188
+ if (fork ) {
187
189
String minStab = mimimumStability == null ? "" : mimimumStability ;
188
- ForkedEmbeddedUtil .fork (this , getStoredSystemProps (), installation , getStandaloneSpecsFile ().toString (), getDomainSpecsFile ().toString (), minStab );
190
+ ForkedEmbeddedUtil .fork (this , getStoredSystemProps (), installation , getStandaloneSpecsFile ().toString (), getDomainSpecsFile ().toString (), description , minStab );
189
191
standaloneFeatures = readSpecsFile (getStandaloneSpecsFile ());
190
192
Path model = getStandaloneSpecsFile ().getParent ().resolve ("model.json" );
191
193
try {
@@ -194,14 +196,14 @@ private void doGenerate() throws ProvisioningException {
194
196
} catch (IOException ex ) {
195
197
throw new ProvisioningException (ex );
196
198
}
197
- if (Files .exists (Paths .get (installation ).resolve (WfConstants .DOMAIN ).resolve (WfConstants .CONFIGURATION ))) {
199
+ if (Files .exists (Paths .get (installation ).resolve (WfConstants .DOMAIN ).resolve (WfConstants .CONFIGURATION ))) {
198
200
domainRoots = readSpecsFile (getDomainSpecsFile ());
199
201
}
200
202
} else {
201
203
final Path home = Paths .get (installation );
202
- if (Files .exists (home .resolve (WfConstants .STANDALONE ).resolve (WfConstants .CONFIGURATION ))) {
204
+ if (Files .exists (home .resolve (WfConstants .STANDALONE ).resolve (WfConstants .CONFIGURATION ))) {
203
205
standaloneFeatures = readFeatureSpecs (createStandaloneServer (installation , mimimumStability , null ));
204
- ModelNode result = generateModel (createStandaloneServer (installation , mimimumStability , "standalone-local.xml" ));
206
+ ModelNode result = generateModel (createStandaloneServer (installation , mimimumStability , "standalone-local.xml" ), description );
205
207
try {
206
208
if (!Files .exists (outputDir )) {
207
209
Files .createDirectories (outputDir );
@@ -213,7 +215,7 @@ private void doGenerate() throws ProvisioningException {
213
215
} else {
214
216
throw new ProvisioningException ("The installation does not include standalone configuration" );
215
217
}
216
- if (Files .exists (home .resolve (WfConstants .DOMAIN ).resolve (WfConstants .CONFIGURATION ))) {
218
+ if (Files .exists (home .resolve (WfConstants .DOMAIN ).resolve (WfConstants .CONFIGURATION ))) {
217
219
domainRoots = readFeatureSpecs (createEmbeddedHc (installation , mimimumStability ));
218
220
}
219
221
}
@@ -236,7 +238,7 @@ private void doGenerate() throws ProvisioningException {
236
238
}
237
239
238
240
rootNode .processChildren (FeatureSpecNode .STANDALONE_MODEL );
239
- if (domainRoots != null ) {
241
+ if (domainRoots != null ) {
240
242
rootNode .processChildren (FeatureSpecNode .PROFILE_MODEL );
241
243
rootNode .processChildren (FeatureSpecNode .DOMAIN_MODEL );
242
244
rootNode .processChildren (FeatureSpecNode .HOST_MODEL );
@@ -247,16 +249,18 @@ private void doGenerate() throws ProvisioningException {
247
249
248
250
@ Override
249
251
public void forkedForEmbedded (String ... args ) throws ConfigGeneratorException {
250
- if (args .length != 3 && args .length != 4 ) {
252
+ System .out .println ("**************************** Arguments " + Arrays .toString (args ));
253
+ if (args .length != 4 && args .length != 5 ) {
251
254
final StringBuilder buf = new StringBuilder ();
252
255
StringUtils .append (buf , Arrays .asList (args ));
253
- throw new IllegalArgumentException ("Expected 3-4 arguments but got " + Arrays .asList (args ));
256
+ throw new IllegalArgumentException ("Expected 4-5 arguments but got " + Arrays .asList (args ));
254
257
}
255
258
try {
256
- String mimimumStability = args .length == 4 ? args [3 ] : null ;
259
+ String description = args .length > 3 ? args [3 ] : null ;
260
+ String mimimumStability = args .length == 5 ? args [4 ] : null ;
257
261
ModelNode result = readFeatureSpecs (createStandaloneServer (args [0 ], mimimumStability , null ));
258
262
writeSpecsFile (Paths .get (args [1 ]), result );
259
- ModelNode resultModel = generateModel (createStandaloneServer (args [0 ], mimimumStability , "standalone-local.xml" ));
263
+ ModelNode resultModel = generateModel (createStandaloneServer (args [0 ], mimimumStability , "standalone-local.xml" ), description );
260
264
writeModelFile (Paths .get (args [1 ]).toAbsolutePath ().getParent ().resolve ("model.json" ), resultModel );
261
265
System .out .println ("FORKED TO " + Paths .get (args [1 ]).toAbsolutePath ().getParent ().resolve ("model.json" ));
262
266
if (Files .exists (Paths .get (args [0 ]).resolve (WfConstants .DOMAIN ).resolve (WfConstants .CONFIGURATION ))) {
@@ -270,20 +274,20 @@ public void forkedForEmbedded(String... args) throws ConfigGeneratorException {
270
274
271
275
@ Override
272
276
public void forkedEmbeddedMessage (String msg ) {
273
- if (debug ) {
277
+ if (debug ) {
274
278
System .out .println (msg );
275
279
}
276
280
}
277
281
278
282
protected Path getStoredSystemProps () throws ProvisioningException {
279
- if (systemProps == null ) {
283
+ if (systemProps == null ) {
280
284
systemProps = ForkedEmbeddedUtil .storeSystemProps ();
281
285
}
282
286
return systemProps ;
283
287
}
284
288
285
289
protected Path getStandaloneSpecsFile () throws ProvisioningException {
286
- if (standaloneSpecsFile == null ) {
290
+ if (standaloneSpecsFile == null ) {
287
291
try {
288
292
standaloneSpecsFile = Files .createTempFile ("wfgp" , "standalone-specs" );
289
293
} catch (IOException e ) {
@@ -294,7 +298,7 @@ protected Path getStandaloneSpecsFile() throws ProvisioningException {
294
298
}
295
299
296
300
protected Path getDomainSpecsFile () throws ProvisioningException {
297
- if (domainSpecsFile == null ) {
301
+ if (domainSpecsFile == null ) {
298
302
try {
299
303
domainSpecsFile = Files .createTempFile ("wfgp" , "domain-specs" );
300
304
} catch (IOException e ) {
@@ -306,14 +310,14 @@ protected Path getDomainSpecsFile() throws ProvisioningException {
306
310
307
311
protected FeatureSpec getInheritedSpec (String name ) throws ProvisioningException {
308
312
FeatureSpec spec = parsedInheritedSpecs .get (name );
309
- if (spec != null ) {
313
+ if (spec != null ) {
310
314
return spec ;
311
315
}
312
316
final Path path = inheritedSpecs .get (name );
313
- if (path == null ) {
317
+ if (path == null ) {
314
318
return null ;
315
319
}
316
- try (BufferedReader reader = Files .newBufferedReader (path )) {
320
+ try (BufferedReader reader = Files .newBufferedReader (path )) {
317
321
spec = FeatureSpecXmlParser .getInstance ().parse (reader );
318
322
} catch (IOException | XMLStreamException e ) {
319
323
throw new ProvisioningException ("Failed to parse " + name + " spec " + path , e );
@@ -339,43 +343,47 @@ private static String[] getCmdArgs(String mimimumStability, String serverConfig)
339
343
args .add ("--stability=" + mimimumStability );
340
344
}
341
345
if (serverConfig != null ) {
342
- args .add ("--server-config=" + serverConfig );
346
+ args .add ("--server-config=" + serverConfig );
343
347
}
344
348
return args .toArray (String []::new );
345
349
}
346
350
347
- private static ModelNode generateModel (final EmbeddedManagedProcess server ) throws ProvisioningException {
351
+ private static ModelNode generateModel (final EmbeddedManagedProcess server , String description ) throws ProvisioningException {
348
352
try {
349
353
server .start ();
350
354
Boolean all = Boolean .getBoolean ("org.wildfly.galleon.complete.model" );
351
355
if (!all ) {
352
- return readModel (server );
356
+ return readModel (server , description );
353
357
}
354
- return readAll (server );
358
+ return readAll (server , description );
355
359
} catch (EmbeddedProcessStartException ex ) {
356
360
throw new ProvisioningException ("Failed to read feature spec descriptions" , ex );
357
361
} finally {
358
362
server .stop ();
359
363
}
360
364
}
361
365
362
- private static ModelNode readModel (final EmbeddedManagedProcess server ) throws ProvisioningException {
366
+ private static ModelNode readModel (final EmbeddedManagedProcess server , String description ) throws ProvisioningException {
363
367
List <String > subsystems = listSubsystems (server );
364
- ModelNode result = new ModelNode ();
368
+ ModelNode result = new ModelNode (). setEmptyObject () ;
365
369
ModelNode subsystemNodes = result .get ("children" ).get (ClientConstants .SUBSYSTEM ).get ("model-description" );
366
- for (String subsystem : subsystems ) {
370
+ for (String subsystem : subsystems ) {
367
371
ModelNode address = Operations .createAddress (ClientConstants .SUBSYSTEM , subsystem );
368
- ModelNode subsystemDescription = readResourceDescription (server , address );
372
+ ModelNode subsystemDescription = readResourceDescription (server , address , true );
369
373
subsystemDescription .get (ClientConstants .ADDRESS ).add (address );
370
374
subsystemNodes .get (subsystem ).set (subsystemDescription );
371
375
}
372
376
ModelNode address = Operations .createAddress (ClientConstants .DEPLOYMENT );
373
- result .get ("children" ).get (ClientConstants .DEPLOYMENT ).get ("model-description" ).get ("*" ).set (readResourceDescription (server , address ));
377
+ result .get ("children" ).get (ClientConstants .DEPLOYMENT ).get ("model-description" ).get ("*" ).set (readResourceDescription (server , address , true ));
374
378
result .remove (ClientConstants .RESULT );
379
+ ModelNode subsystemsDescription = readResourceDescription (server , Operations .createAddress ().setEmptyList (), false );
380
+ result .get ("children" ).get (ClientConstants .SUBSYSTEM ).get ("description" ).set (subsystemsDescription .get ("children" ).get (ClientConstants .SUBSYSTEM ).get ("description" ));
381
+ result .get ("children" ).get (ClientConstants .DEPLOYMENT ).get ("description" ).set (subsystemsDescription .get ("children" ).get (ClientConstants .DEPLOYMENT ).get ("description" ));
382
+ result .get ("description" ).set (description );
375
383
return result ;
376
384
}
377
385
378
- private static ModelNode readAll (final EmbeddedManagedProcess server ) throws ProvisioningException {
386
+ private static ModelNode readAll (final EmbeddedManagedProcess server , String description ) throws ProvisioningException {
379
387
ModelNode rootAddress = Operations .createAddress ().setEmptyList ();
380
388
final ModelNode op = Operations .createOperation ("read-resource-description" , rootAddress );
381
389
op .get (ClientConstants .RECURSIVE ).set (true );
@@ -385,10 +393,12 @@ private static ModelNode readAll(final EmbeddedManagedProcess server) throws Pro
385
393
} catch (IOException e ) {
386
394
throw new ProvisioningException ("Failed to read feature descriptions" , e );
387
395
}
388
- if (!Operations .isSuccessfulOutcome (result )) {
396
+ if (!Operations .isSuccessfulOutcome (result )) {
389
397
throw new ProvisioningException (Operations .getFailureDescription (result ).asString ());
390
398
}
391
- return result .get (ClientConstants .RESULT );
399
+ final ModelNode effectiveResult = result .get (ClientConstants .RESULT );
400
+ effectiveResult .get ("description" ).set (description );
401
+ return effectiveResult ;
392
402
}
393
403
394
404
private static List <String > listSubsystems (final EmbeddedManagedProcess server ) throws ProvisioningException {
@@ -402,33 +412,33 @@ private static List<String> listSubsystems(final EmbeddedManagedProcess server)
402
412
} catch (IOException e ) {
403
413
throw new ProvisioningException ("Failed to read feature descriptions" , e );
404
414
}
405
- if (!Operations .isSuccessfulOutcome (result )) {
415
+ if (!Operations .isSuccessfulOutcome (result )) {
406
416
throw new ProvisioningException (Operations .getFailureDescription (result ).asString ());
407
417
}
408
418
List <String > names = new ArrayList <>();
409
- for (ModelNode name : result .get (ClientConstants .RESULT ).asList ()) {
419
+ for (ModelNode name : result .get (ClientConstants .RESULT ).asList ()) {
410
420
names .add (name .asString ());
411
421
}
412
422
return names ;
413
423
}
414
424
415
- private static ModelNode readResourceDescription (final EmbeddedManagedProcess server , ModelNode address ) throws ProvisioningException {
425
+ private static ModelNode readResourceDescription (final EmbeddedManagedProcess server , ModelNode address , boolean recursive ) throws ProvisioningException {
416
426
final ModelNode op = Operations .createOperation ("read-resource-description" , address );
417
- op .get (ClientConstants .RECURSIVE ).set (true );
427
+ op .get (ClientConstants .RECURSIVE ).set (recursive );
418
428
final ModelNode opResult ;
419
429
try {
420
430
opResult = server .getModelControllerClient ().execute (op );
421
431
} catch (IOException e ) {
422
432
throw new ProvisioningException ("Failed to read feature descriptions" , e );
423
433
}
424
- if (!Operations .isSuccessfulOutcome (opResult )) {
434
+ if (!Operations .isSuccessfulOutcome (opResult )) {
425
435
throw new ProvisioningException (Operations .getFailureDescription (opResult ).asString ());
426
436
}
427
437
final ModelNode result = opResult .get (ClientConstants .RESULT );
428
- if (ModelType .LIST == result .getType ()) {
438
+ if (ModelType .LIST == result .getType ()) {
429
439
ModelNode finalResult = new ModelNode ().setEmptyList ();
430
- for (ModelNode node : result .asList ()) {
431
- if (node .hasDefined (ClientConstants .RESULT )) {
440
+ for (ModelNode node : result .asList ()) {
441
+ if (node .hasDefined (ClientConstants .RESULT )) {
432
442
finalResult .add (node .get (ClientConstants .RESULT ));
433
443
}
434
444
}
@@ -448,7 +458,7 @@ private static ModelNode readFeatureSpecs(final EmbeddedManagedProcess server) t
448
458
} catch (IOException e ) {
449
459
throw new ProvisioningException ("Failed to read feature descriptions" , e );
450
460
}
451
- if (!Operations .isSuccessfulOutcome (result )) {
461
+ if (!Operations .isSuccessfulOutcome (result )) {
452
462
throw new ProvisioningException (Operations .getFailureDescription (result ).asString ());
453
463
}
454
464
return result .require (ClientConstants .RESULT ).require ("feature" );
@@ -468,15 +478,15 @@ private ModelNode readSpecsFile(Path specsFile) throws ProvisioningException {
468
478
}
469
479
470
480
private void writeSpecsFile (Path specsFile , ModelNode specs ) throws ProvisioningException {
471
- try (BufferedWriter writer = Files .newBufferedWriter (specsFile )) {
481
+ try (BufferedWriter writer = Files .newBufferedWriter (specsFile )) {
472
482
writer .write (specs .asString ());
473
483
} catch (IOException e ) {
474
484
throw new ProvisioningException (Errors .writeFile (specsFile ), e );
475
485
}
476
486
}
477
487
478
488
private void writeModelFile (Path specsFile , ModelNode specs ) throws ProvisioningException {
479
- try (BufferedWriter writer = Files .newBufferedWriter (specsFile )) {
489
+ try (BufferedWriter writer = Files .newBufferedWriter (specsFile )) {
480
490
writer .write (specs .toJSONString (false ));
481
491
} catch (IOException e ) {
482
492
throw new ProvisioningException (Errors .writeFile (specsFile ), e );
0 commit comments