From d26d428040fb893f870d4a9240a660b5da032452 Mon Sep 17 00:00:00 2001 From: Kabir Khan Date: Mon, 15 Apr 2024 11:47:36 +0530 Subject: [PATCH] [WFCORE-6750] Rework the parser registration to use the stability level aware variants --- .../CoreManagementSubsystemSchema_1_0.java | 28 +++++++++---------- ...stableApiAnnotationResourceDefinition.java | 3 +- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/core-management/core-management-subsystem/src/main/java/org/wildfly/extension/core/management/CoreManagementSubsystemSchema_1_0.java b/core-management/core-management-subsystem/src/main/java/org/wildfly/extension/core/management/CoreManagementSubsystemSchema_1_0.java index b6a02e7f1df..aad63bd00ce 100644 --- a/core-management/core-management-subsystem/src/main/java/org/wildfly/extension/core/management/CoreManagementSubsystemSchema_1_0.java +++ b/core-management/core-management-subsystem/src/main/java/org/wildfly/extension/core/management/CoreManagementSubsystemSchema_1_0.java @@ -7,7 +7,6 @@ import org.jboss.as.controller.Feature; import org.jboss.as.controller.PersistentResourceXMLDescription; -import org.jboss.as.controller.PersistentResourceXMLDescription.PersistentResourceXMLBuilder; import org.jboss.as.controller.PersistentSubsystemSchema; import org.jboss.as.controller.SubsystemSchema; import org.jboss.as.controller.xml.VersionedNamespace; @@ -17,8 +16,6 @@ import java.util.EnumSet; import java.util.Map; -import static org.jboss.as.controller.PersistentResourceXMLDescription.builder; - /** * Parser and Marshaller for core-management subsystem. * @@ -51,21 +48,24 @@ public VersionedNamespace getName @Override public PersistentResourceXMLDescription getXMLDescription() { - PersistentResourceXMLBuilder builder = builder(CoreManagementExtension.SUBSYSTEM_PATH, namespace); - builder.addChild(builder(ConfigurationChangeResourceDefinition.PATH).addAttribute(ConfigurationChangeResourceDefinition.MAX_HISTORY)); - - if (this.getStability().enables(Stability.PREVIEW)) { - builder.addChild( - builder(UnstableApiAnnotationResourceDefinition.PATH) - .addAttribute(UnstableApiAnnotationResourceDefinition.LEVEL)); - } + PersistentResourceXMLDescription.Factory factory = PersistentResourceXMLDescription.factory(this); + PersistentResourceXMLDescription.Builder builder = factory.builder(CoreManagementExtension.SUBSYSTEM_PATH); + builder.addChild( + factory.builder(ConfigurationChangeResourceDefinition.PATH) + .addAttribute(ConfigurationChangeResourceDefinition.MAX_HISTORY) + .build()); + builder.addChild( + factory.builder(UnstableApiAnnotationResourceDefinition.RESOURCE_REGISTRATION) + .addAttribute(UnstableApiAnnotationResourceDefinition.LEVEL) + .build()); + builder.addChild( + factory.builder(CoreManagementExtension.PROCESS_STATE_LISTENER_PATH) - builder.addChild(builder(CoreManagementExtension.PROCESS_STATE_LISTENER_PATH) .addAttribute(ProcessStateListenerResourceDefinition.LISTENER_CLASS) .addAttribute(ProcessStateListenerResourceDefinition.LISTENER_MODULE) .addAttribute(ProcessStateListenerResourceDefinition.PROPERTIES) - .addAttribute(ProcessStateListenerResourceDefinition.TIMEOUT)); - + .addAttribute(ProcessStateListenerResourceDefinition.TIMEOUT) + .build()); return builder.build(); } } diff --git a/core-management/core-management-subsystem/src/main/java/org/wildfly/extension/core/management/UnstableApiAnnotationResourceDefinition.java b/core-management/core-management-subsystem/src/main/java/org/wildfly/extension/core/management/UnstableApiAnnotationResourceDefinition.java index 458a2fdaed6..66c359c3e60 100644 --- a/core-management/core-management-subsystem/src/main/java/org/wildfly/extension/core/management/UnstableApiAnnotationResourceDefinition.java +++ b/core-management/core-management-subsystem/src/main/java/org/wildfly/extension/core/management/UnstableApiAnnotationResourceDefinition.java @@ -40,12 +40,13 @@ public class UnstableApiAnnotationResourceDefinition extends PersistentResourceD .setDefaultValue(new ModelNode(UnstableApiAnnotationLevel.LOG.name())) .build(); public static final PathElement PATH = PathElement.pathElement(SERVICE, UNSTABLE_API_ANNOTATIONS); + static final ResourceRegistration RESOURCE_REGISTRATION = ResourceRegistration.of(PATH, STABILITY); static final UnstableApiAnnotationResourceDefinition INSTANCE = new UnstableApiAnnotationResourceDefinition(); private UnstableApiAnnotationResourceDefinition() { super( new Parameters( - ResourceRegistration.of(PATH, STABILITY), + RESOURCE_REGISTRATION, CoreManagementExtension.getResourceDescriptionResolver(UNSTABLE_API_ANNOTATIONS)) .setAddHandler(ReloadRequiredAddStepHandler.INSTANCE) .setRemoveHandler(ReloadRequiredRemoveStepHandler.INSTANCE));