diff --git a/controller/src/main/java/org/jboss/as/controller/transform/SubsystemTransformerRegistration.java b/controller/src/main/java/org/jboss/as/controller/transform/SubsystemTransformerRegistration.java index 3b399d172d0..33b1c6df6b6 100644 --- a/controller/src/main/java/org/jboss/as/controller/transform/SubsystemTransformerRegistration.java +++ b/controller/src/main/java/org/jboss/as/controller/transform/SubsystemTransformerRegistration.java @@ -7,6 +7,8 @@ import org.jboss.as.controller.ModelVersion; import org.jboss.as.controller.ModelVersionRange; +import org.jboss.as.controller.transform.description.ChainedTransformationDescriptionBuilderFactory; +import org.jboss.as.controller.transform.description.ResourceTransformationDescriptionBuilderFactory; /** * Subsystem transformers registration API @@ -15,7 +17,7 @@ * * @author Tomaz Cerar (c) 2016 Red Hat Inc. */ -public interface SubsystemTransformerRegistration { +public interface SubsystemTransformerRegistration extends ResourceTransformationDescriptionBuilderFactory, ChainedTransformationDescriptionBuilderFactory { /** * Register transformers for a specific model versions. @@ -50,7 +52,10 @@ public interface SubsystemTransformerRegistration { * Get the version of the subsystem * * @return the version + * @deprecated Superseded by {@link #getCurrentVersion()} */ - ModelVersion getCurrentSubsystemVersion(); - + @Deprecated(forRemoval = true, since = "27.0.0") + default ModelVersion getCurrentSubsystemVersion() { + return this.getCurrentVersion(); + } } diff --git a/controller/src/main/java/org/jboss/as/controller/transform/TransformationTargetImpl.java b/controller/src/main/java/org/jboss/as/controller/transform/TransformationTargetImpl.java index e8b3d37cbfd..c36cb16f18c 100644 --- a/controller/src/main/java/org/jboss/as/controller/transform/TransformationTargetImpl.java +++ b/controller/src/main/java/org/jboss/as/controller/transform/TransformationTargetImpl.java @@ -17,6 +17,7 @@ import org.jboss.as.controller.operations.global.QueryOperationHandler; import org.jboss.as.controller.registry.OperationTransformerRegistry; import org.jboss.as.controller.registry.OperationTransformerRegistry.PlaceholderResolver; +import org.jboss.as.version.Stability; /** @@ -62,8 +63,13 @@ private TransformationTargetImpl(final TransformationTargetImpl target, final Pl this.placeholderResolver = placeholderResolver; } + @Deprecated(forRemoval = true, since = "27.0.0") public static TransformationTarget createLocal() { - TransformerRegistry registry = new TransformerRegistry(); + return createLocal(Stability.DEFAULT); + } + + public static TransformationTarget createLocal(Stability stability) { + TransformerRegistry registry = new TransformerRegistry(stability); OperationTransformerRegistry r2 = registry.resolveHost(ModelVersion.create(0), new HashMap()); return new TransformationTargetImpl(null, registry, ModelVersion.create(0), new HashMap(), r2, TransformationTargetType.SERVER, Transformers.OperationExcludedTransformationRegistry.DEFAULT, null); diff --git a/controller/src/main/java/org/jboss/as/controller/transform/TransformerRegistry.java b/controller/src/main/java/org/jboss/as/controller/transform/TransformerRegistry.java index f20bee6298a..5f13c5e27b5 100644 --- a/controller/src/main/java/org/jboss/as/controller/transform/TransformerRegistry.java +++ b/controller/src/main/java/org/jboss/as/controller/transform/TransformerRegistry.java @@ -22,6 +22,8 @@ import org.jboss.as.controller.logging.ControllerLogger; import org.jboss.as.controller.registry.GlobalTransformerRegistry; import org.jboss.as.controller.registry.OperationTransformerRegistry; +import org.jboss.as.controller.transform.description.ResourceTransformationDescriptionBuilderFactory; +import org.jboss.as.version.Stability; import org.jboss.dmr.ModelNode; import org.jboss.dmr.Property; import org.jboss.modules.Module; @@ -34,7 +36,7 @@ * @author Tomaz Cerar * @author Emanuel Muckenhuber */ -public final class TransformerRegistry { +public final class TransformerRegistry implements ResourceTransformationDescriptionBuilderFactory { public static final ModelNode DISCARD_OPERATION = new ModelNode(); static { @@ -47,19 +49,26 @@ public final class TransformerRegistry { private static final PathElement PROFILE = PathElement.pathElement(ModelDescriptionConstants.PROFILE); private static final PathElement SERVER = PathElement.pathElement(ModelDescriptionConstants.RUNNING_SERVER); + private final Stability stability; private final GlobalTransformerRegistry domain = new GlobalTransformerRegistry(); private final GlobalTransformerRegistry subsystem = new GlobalTransformerRegistry(); - TransformerRegistry() { + TransformerRegistry(Stability stability) { + this.stability = stability; // Initialize the empty paths domain.createChildRegistry(PathAddress.pathAddress(PROFILE), ModelVersion.create(0), ResourceTransformer.DEFAULT, false); domain.createChildRegistry(PathAddress.pathAddress(HOST), ModelVersion.create(0), ResourceTransformer.DEFAULT, false); domain.createChildRegistry(PathAddress.pathAddress(HOST, SERVER), ModelVersion.create(0), ResourceTransformer.DEFAULT, false); } + @Override + public Stability getStability() { + return this.stability; + } + public void loadAndRegisterTransformers(String name, ModelVersion subsystemVersion, String extensionModuleName) { try { - SubsystemTransformerRegistration transformerRegistration = new SubsystemTransformerRegistrationImpl(name, subsystemVersion); + SubsystemTransformerRegistration transformerRegistration = this.createSubsystemTransformerRegistration(name, subsystemVersion); if (Module.getCallerModule() != null) { //only register when running in modular environment, testsuite does its own loading for (ExtensionTransformerRegistration registration : Module.loadServiceFromCallerModuleLoader(ModuleIdentifier.fromString(extensionModuleName), ExtensionTransformerRegistration.class)) { if (registration.getSubsystemName().equals(name)) { //to prevent registering transformers for different subsystems @@ -72,16 +81,15 @@ public void loadAndRegisterTransformers(String name, ModelVersion subsystemVersi } } - public SubsystemTransformerRegistration createSubsystemTransformerRegistration(String name, ModelVersion currentVersion){ + public SubsystemTransformerRegistration createSubsystemTransformerRegistration(String name, ModelVersion currentVersion) { return new SubsystemTransformerRegistrationImpl(name, currentVersion); } - private class SubsystemTransformerRegistrationImpl implements SubsystemTransformerRegistration{ + private class SubsystemTransformerRegistrationImpl implements SubsystemTransformerRegistration { private final String name; private final ModelVersion currentVersion; - - public SubsystemTransformerRegistrationImpl(String name, ModelVersion currentVersion) { + SubsystemTransformerRegistrationImpl(String name, ModelVersion currentVersion) { this.name = name; this.currentVersion = currentVersion; } @@ -102,9 +110,14 @@ public TransformersSubRegistration registerModelTransformers(ModelVersionRange v } @Override - public ModelVersion getCurrentSubsystemVersion() { + public ModelVersion getCurrentVersion() { return currentVersion; } + + @Override + public Stability getStability() { + return TransformerRegistry.this.getStability(); + } } /** @@ -276,11 +289,16 @@ public static class Factory { * Create a new Transformer registry. * * @return the created transformer registry + * @deprecated Superseded by {@link #create(Stability)}. */ + @Deprecated(forRemoval = true) public static TransformerRegistry create() { - return new TransformerRegistry(); + return create(Stability.DEFAULT); } + public static TransformerRegistry create(Stability stability) { + return new TransformerRegistry(stability); + } } public static class TransformersSubRegistrationImpl implements TransformersSubRegistration { diff --git a/controller/src/main/java/org/jboss/as/controller/transform/Transformers.java b/controller/src/main/java/org/jboss/as/controller/transform/Transformers.java index 1dfecfdc824..8adbe6266a4 100644 --- a/controller/src/main/java/org/jboss/as/controller/transform/Transformers.java +++ b/controller/src/main/java/org/jboss/as/controller/transform/Transformers.java @@ -13,6 +13,7 @@ import org.jboss.as.controller.RunningMode; import org.jboss.as.controller.registry.ImmutableManagementResourceRegistration; import org.jboss.as.controller.registry.Resource; +import org.jboss.as.version.Stability; import org.jboss.dmr.ModelNode; /** @@ -252,10 +253,20 @@ public static ResourceTransformationContext create(TransformationTarget target, * * @return the transformers instance. Will not be {@code null} */ + @Deprecated(forRemoval = true, since = "27.0.0") public static Transformers createLocal() { return new TransformersImpl(TransformationTargetImpl.createLocal()); } + /** + * Create a local transformer, which will use the default transformation rules, however still respect the + * ignored resource transformation. + * @param stability the stability level of the target host + * @return the transformers instance. Will not be {@code null} + */ + public static Transformers createLocal(Stability stability) { + return new TransformersImpl(TransformationTargetImpl.createLocal(stability)); + } } /** Provides information on whether a target process is ignoring particular resource addresses. */ diff --git a/controller/src/main/java/org/jboss/as/controller/transform/description/AbstractTransformationDescriptionBuilder.java b/controller/src/main/java/org/jboss/as/controller/transform/description/AbstractTransformationDescriptionBuilder.java index 4e29607402d..f84a9497a4a 100644 --- a/controller/src/main/java/org/jboss/as/controller/transform/description/AbstractTransformationDescriptionBuilder.java +++ b/controller/src/main/java/org/jboss/as/controller/transform/description/AbstractTransformationDescriptionBuilder.java @@ -18,12 +18,14 @@ import org.jboss.as.controller.transform.OperationTransformer; import org.jboss.as.controller.transform.PathAddressTransformer; import org.jboss.as.controller.transform.ResourceTransformer; +import org.jboss.as.version.Stability; /** * @author Emanuel Muckenhuber */ abstract class AbstractTransformationDescriptionBuilder implements TransformationDescriptionBuilder { + private final Stability stability; protected final PathElement pathElement; protected PathAddressTransformer pathAddressTransformer; @@ -34,10 +36,11 @@ abstract class AbstractTransformationDescriptionBuilder implements Transformatio protected final List children = new ArrayList(); protected final DynamicDiscardPolicy dynamicDiscardPolicy; - protected AbstractTransformationDescriptionBuilder(PathElement pathElement, PathAddressTransformer pathAddressTransformer, + protected AbstractTransformationDescriptionBuilder(Stability stability, PathElement pathElement, PathAddressTransformer pathAddressTransformer, ResourceTransformer resourceTransformer, OperationTransformer operationTransformer, DynamicDiscardPolicy dynamicDiscardPolicy) { + this.stability = stability; this.pathElement = pathElement; this.pathAddressTransformer = pathAddressTransformer; this.resourceTransformer = resourceTransformer; @@ -45,6 +48,11 @@ protected AbstractTransformationDescriptionBuilder(PathElement pathElement, Path this.dynamicDiscardPolicy = dynamicDiscardPolicy; } + @Override + public Stability getStability() { + return this.stability; + } + public TransformationDescriptionBuilder setResourceTransformer(ResourceTransformer resourceTransformer) { this.resourceTransformer = resourceTransformer; return this; diff --git a/controller/src/main/java/org/jboss/as/controller/transform/description/AttributeTransformationDescriptionBuilderImpl.java b/controller/src/main/java/org/jboss/as/controller/transform/description/AttributeTransformationDescriptionBuilderImpl.java index 5fa8623b21d..4e9edab0545 100644 --- a/controller/src/main/java/org/jboss/as/controller/transform/description/AttributeTransformationDescriptionBuilderImpl.java +++ b/controller/src/main/java/org/jboss/as/controller/transform/description/AttributeTransformationDescriptionBuilderImpl.java @@ -14,6 +14,7 @@ import java.util.Set; import org.jboss.as.controller.AttributeDefinition; +import org.jboss.as.version.Stability; /** * @author Kabir Khan @@ -29,59 +30,55 @@ abstract class AttributeTransformationDescriptionBuilderImpl discardedAttributes) { - for (AttributeDefinition attribute : discardedAttributes) { - String attrName = getAttributeName(attribute); - registry.setDiscardedAttribute(discardChecker, attrName); + for (AttributeDefinition discardedAttribute : discardedAttributes) { + if (this.enables(discardedAttribute)) { + this.registry.setDiscardedAttribute(discardChecker, discardedAttribute.getName()); + } } - return thisBuilder(); + return this.thisBuilder(); } @Override public T setDiscard(DiscardAttributeChecker discardChecker, String... discardedAttributes) { - String[] useDefs = discardedAttributes; - for (String attrName : useDefs) { - registry.setDiscardedAttribute(discardChecker, attrName); + for (String discardedAttribute : discardedAttributes) { + this.registry.setDiscardedAttribute(discardChecker, discardedAttribute); } return thisBuilder(); } @Override - public T addRejectCheck(final RejectAttributeChecker checker, final AttributeDefinition...rejectedAttributes){ - for (AttributeDefinition attribute : rejectedAttributes) { - String attrName = getAttributeName(attribute); - registry.addAttributeCheck(attrName, checker); + public T addRejectCheck(final RejectAttributeChecker checker, final AttributeDefinition... rejectedAttributes){ + for (AttributeDefinition rejectedAttribute : rejectedAttributes) { + if (this.enables(rejectedAttribute)) { + this.registry.addAttributeCheck(rejectedAttribute.getName(), checker); + } } - return thisBuilder(); + return this.thisBuilder(); } @Override public T addRejectCheck(RejectAttributeChecker rejectChecker, String... rejectedAttributes) { - for (String attribute : rejectedAttributes) { - registry.addAttributeCheck(attribute, rejectChecker); + for (String rejectedAttribute : rejectedAttributes) { + this.registry.addAttributeCheck(rejectedAttribute, rejectChecker); } - return thisBuilder(); + return this.thisBuilder(); } @Override public T addRejectChecks(List rejectCheckers, AttributeDefinition...rejectedAttributes) { for (RejectAttributeChecker rejectChecker : rejectCheckers) { - addRejectCheck(rejectChecker, rejectedAttributes); + this.addRejectCheck(rejectChecker, rejectedAttributes); } return thisBuilder(); } @@ -89,14 +86,16 @@ public T addRejectChecks(List rejectCheckers, AttributeD @Override public T addRejectChecks(List rejectCheckers, String... rejectedAttributes) { for (RejectAttributeChecker rejectChecker : rejectCheckers) { - addRejectCheck(rejectChecker, rejectedAttributes); + this.addRejectCheck(rejectChecker, rejectedAttributes); } return thisBuilder(); } @Override - public T addRename(AttributeDefinition attributeName, String newName) { - registry.addRenamedAttribute(getAttributeName(attributeName), newName); + public T addRename(AttributeDefinition attribute, String newName) { + if (this.enables(attribute)) { + this.addRename(attribute.getName(), newName); + } return thisBuilder(); } @@ -106,9 +105,10 @@ public T addRename(String attributeName, String newName) { return thisBuilder(); } + @Override public T addRenames(Map renames) { for (Map.Entry rename : renames.entrySet()) { - registry.addRenamedAttribute(rename.getKey(), rename.getValue()); + this.addRename(rename.getKey(), rename.getValue()); } return thisBuilder(); } @@ -116,9 +116,10 @@ public T addRenames(Map renames) { @Override public T setValueConverter(AttributeConverter attributeConverter, AttributeDefinition...convertedAttributes) { - for (AttributeDefinition attribute : convertedAttributes) { - String attrName = getAttributeName(attribute); - registry.addAttributeConverter(attrName, attributeConverter); + for (AttributeDefinition convertedAttribute : convertedAttributes) { + if (this.enables(convertedAttribute)) { + this.registry.addAttributeConverter(convertedAttribute.getName(), attributeConverter); + } } return thisBuilder(); } @@ -131,10 +132,6 @@ public T setValueConverter(AttributeConverter attributeConverter, String... conv return thisBuilder(); } - protected String getAttributeName(AttributeDefinition attr) { - return attr.getName(); - } - protected AttributeTransformationDescriptionBuilderRegistry getLocalRegistry() { return registry; } diff --git a/controller/src/main/java/org/jboss/as/controller/transform/description/BaseAttributeTransformationDescriptionBuilder.java b/controller/src/main/java/org/jboss/as/controller/transform/description/BaseAttributeTransformationDescriptionBuilder.java index c56f500d897..cb709f1cae9 100644 --- a/controller/src/main/java/org/jboss/as/controller/transform/description/BaseAttributeTransformationDescriptionBuilder.java +++ b/controller/src/main/java/org/jboss/as/controller/transform/description/BaseAttributeTransformationDescriptionBuilder.java @@ -10,6 +10,7 @@ import java.util.Map; import org.jboss.as.controller.AttributeDefinition; +import org.jboss.as.controller.FeatureRegistry; /** @@ -34,7 +35,7 @@ * @author Emanuel Muckenhuber * @author Kabir Khan */ -public interface BaseAttributeTransformationDescriptionBuilder> { +public interface BaseAttributeTransformationDescriptionBuilder> extends FeatureRegistry { /** * Adds a RejectAttributeChecker. More than one reject checker can be used for an attribute, and the RejectAttributeCheckers @@ -106,7 +107,9 @@ public interface BaseAttributeTransformationDescriptionBuilderKabir Khan */ class ChainedTransformationDescriptionBuilderImpl implements ChainedTransformationDescriptionBuilder { + private final Stability stability; private final ModelVersion currentVersion; private final Map builders = new HashMap<>(); private final PathElement element; - ChainedTransformationDescriptionBuilderImpl(ModelVersion currentVersion, PathElement element) { + ChainedTransformationDescriptionBuilderImpl(ModelVersion currentVersion, Stability stability, PathElement element) { this.currentVersion = currentVersion; + this.stability = stability; this.element = element; } @Override public ResourceTransformationDescriptionBuilder createBuilder(ModelVersion fromVersion, ModelVersion toVersion) { - ResourceTransformationDescriptionBuilder builder = new ResourceTransformationDescriptionBuilderImpl(element); + ResourceTransformationDescriptionBuilder builder = new ResourceTransformationDescriptionBuilderImpl(this.stability, element); builders.put(new ModelVersionPair(fromVersion, toVersion), builder); return builder; } + @Override public Map build(ModelVersion...versions) { ModelVersion[] allVersions = new ModelVersion[versions.length + 1]; allVersions[0] = currentVersion; @@ -66,7 +70,7 @@ private Map doBuild(ModelVersion...vers TransformationDescriptionBuilder builder = builders.get(pair); if (builder == null) { //Insert an empty builder in the chain for version deltas which don't have one registered - builder = new ResourceTransformationDescriptionBuilderImpl(element); + builder = new ResourceTransformationDescriptionBuilderImpl(this.stability, element); } placeholderResolvers.put(pair, ChainedPlaceholderResolver.create(builder.build())); TransformationDescription desc = new ChainedTransformingDescription(element, new LinkedHashMap<>(placeholderResolvers)); diff --git a/controller/src/main/java/org/jboss/as/controller/transform/description/ConcreteAttributeTransformationDescriptionBuilder.java b/controller/src/main/java/org/jboss/as/controller/transform/description/ConcreteAttributeTransformationDescriptionBuilder.java index 00943550918..92e5828617b 100644 --- a/controller/src/main/java/org/jboss/as/controller/transform/description/ConcreteAttributeTransformationDescriptionBuilder.java +++ b/controller/src/main/java/org/jboss/as/controller/transform/description/ConcreteAttributeTransformationDescriptionBuilder.java @@ -20,5 +20,4 @@ protected ConcreteAttributeTransformationDescriptionBuilder(ResourceTransformati protected AttributeTransformationDescriptionBuilder thisBuilder() { return this; } - } diff --git a/controller/src/main/java/org/jboss/as/controller/transform/description/DiscardTransformationDescriptionBuilder.java b/controller/src/main/java/org/jboss/as/controller/transform/description/DiscardTransformationDescriptionBuilder.java index 5f074526e83..d093b8a698e 100644 --- a/controller/src/main/java/org/jboss/as/controller/transform/description/DiscardTransformationDescriptionBuilder.java +++ b/controller/src/main/java/org/jboss/as/controller/transform/description/DiscardTransformationDescriptionBuilder.java @@ -9,17 +9,17 @@ import org.jboss.as.controller.transform.OperationTransformer; import org.jboss.as.controller.transform.PathAddressTransformer; import org.jboss.as.controller.transform.ResourceTransformer; +import org.jboss.as.version.Stability; /** * Transformation builder discarding all operations to this resource. * * @author Emanuel Muckenhuber */ -public final class DiscardTransformationDescriptionBuilder extends AbstractTransformationDescriptionBuilder implements TransformationDescriptionBuilder { +public final class DiscardTransformationDescriptionBuilder extends AbstractTransformationDescriptionBuilder { - protected DiscardTransformationDescriptionBuilder(PathElement pathElement) { - super(pathElement, PathAddressTransformer.DEFAULT, ResourceTransformer.DISCARD, - OperationTransformer.DISCARD, null); + protected DiscardTransformationDescriptionBuilder(Stability stability, PathElement pathElement) { + super(stability, pathElement, PathAddressTransformer.DEFAULT, ResourceTransformer.DISCARD, OperationTransformer.DISCARD, null); } @Override @@ -27,5 +27,4 @@ public TransformationDescription build() { final AttributeTransformationDescriptionBuilderImpl.AttributeTransformationDescriptionBuilderRegistry empty = new AttributeTransformationDescriptionBuilderImpl.AttributeTransformationDescriptionBuilderRegistry(); return buildDefault(DiscardPolicy.SILENT, true, empty); } - } diff --git a/controller/src/main/java/org/jboss/as/controller/transform/description/RejectTransformationDescriptionBuilder.java b/controller/src/main/java/org/jboss/as/controller/transform/description/RejectTransformationDescriptionBuilder.java index 4dc5a1a707e..e34656802de 100644 --- a/controller/src/main/java/org/jboss/as/controller/transform/description/RejectTransformationDescriptionBuilder.java +++ b/controller/src/main/java/org/jboss/as/controller/transform/description/RejectTransformationDescriptionBuilder.java @@ -8,16 +8,16 @@ import org.jboss.as.controller.transform.OperationTransformer; import org.jboss.as.controller.transform.PathAddressTransformer; import org.jboss.as.controller.transform.ResourceTransformer; +import org.jboss.as.version.Stability; /** * * @author Kabir Khan */ -public class RejectTransformationDescriptionBuilder extends AbstractTransformationDescriptionBuilder implements TransformationDescriptionBuilder { +public class RejectTransformationDescriptionBuilder extends AbstractTransformationDescriptionBuilder { - protected RejectTransformationDescriptionBuilder(PathElement pathElement) { - super(pathElement, PathAddressTransformer.DEFAULT, ResourceTransformer.DEFAULT, - OperationTransformer.DEFAULT, null); + protected RejectTransformationDescriptionBuilder(Stability stability, PathElement pathElement) { + super(stability, pathElement, PathAddressTransformer.DEFAULT, ResourceTransformer.DEFAULT, OperationTransformer.DEFAULT, null); } @Override @@ -25,5 +25,4 @@ public TransformationDescription build() { final AttributeTransformationDescriptionBuilderImpl.AttributeTransformationDescriptionBuilderRegistry empty = new AttributeTransformationDescriptionBuilderImpl.AttributeTransformationDescriptionBuilderRegistry(); return buildDefault(DiscardPolicy.REJECT_AND_WARN, true, empty); } - } diff --git a/controller/src/main/java/org/jboss/as/controller/transform/description/ResourceTransformationDescriptionBuilder.java b/controller/src/main/java/org/jboss/as/controller/transform/description/ResourceTransformationDescriptionBuilder.java index ef51c582ed4..5a4920b9f0d 100644 --- a/controller/src/main/java/org/jboss/as/controller/transform/description/ResourceTransformationDescriptionBuilder.java +++ b/controller/src/main/java/org/jboss/as/controller/transform/description/ResourceTransformationDescriptionBuilder.java @@ -7,6 +7,7 @@ import org.jboss.as.controller.PathElement; import org.jboss.as.controller.ResourceDefinition; +import org.jboss.as.controller.ResourceRegistration; import org.jboss.as.controller.transform.OperationTransformer; import org.jboss.as.controller.transform.PathAddressTransformer; import org.jboss.as.controller.transform.ResourceTransformer; @@ -66,7 +67,21 @@ public interface ResourceTransformationDescriptionBuilder extends Transformation * @param pathElement the path element * @return the builder for the child resource */ - ResourceTransformationDescriptionBuilder addChildResource(PathElement pathElement); + default ResourceTransformationDescriptionBuilder addChildResource(PathElement pathElement) { + return this.addChildResource(pathElement, null); + } + + /** + * Add a child resource to this builder. This is going to register the child automatically at the + * {@linkplain org.jboss.as.controller.transform.TransformersSubRegistration} when registering the transformation + * description created by this builder. + * + * @param registration a resource registration + * @return the builder for the child resource + */ + default ResourceTransformationDescriptionBuilder addChildResource(ResourceRegistration registration) { + return this.addChildResource(registration, null); + } /** * Add a child resource to this builder. This is going to register the child automatically at the @@ -77,7 +92,20 @@ public interface ResourceTransformationDescriptionBuilder extends Transformation * @param dynamicDiscardPolicy a checker to decide whether the child should be added or not * @return the builder for the child resource */ - ResourceTransformationDescriptionBuilder addChildResource(PathElement pathElement, DynamicDiscardPolicy dynamicDiscardPolicy); + default ResourceTransformationDescriptionBuilder addChildResource(PathElement pathElement, DynamicDiscardPolicy dynamicDiscardPolicy) { + return this.addChildResource(ResourceRegistration.of(pathElement), dynamicDiscardPolicy); + } + + /** + * Add a child resource to this builder. This is going to register the child automatically at the + * {@linkplain org.jboss.as.controller.transform.TransformersSubRegistration} when registering the transformation + * description created by this builder. + * + * @param registration a resource registration + * @param dynamicDiscardPolicy a checker to decide whether the child should be added or not + * @return the builder for the child resource + */ + ResourceTransformationDescriptionBuilder addChildResource(ResourceRegistration registration, DynamicDiscardPolicy dynamicDiscardPolicy); /** * Add a child resource to this builder. This is going to register the child automatically at the @@ -86,8 +114,13 @@ public interface ResourceTransformationDescriptionBuilder extends Transformation * * @param definition the resource definition * @return the builder for the child resource + * @deprecated Use {@link ResourceTransformationDescriptionBuilder#addChildResource(ResourceRegistration)} instead. */ - ResourceTransformationDescriptionBuilder addChildResource(ResourceDefinition definition); + @Deprecated(forRemoval = true) + default ResourceTransformationDescriptionBuilder addChildResource(ResourceDefinition definition) { + ResourceRegistration registration = definition; + return this.addChildResource(registration); + } /** * Add a child resource to this builder. This is going to register the child automatically at the @@ -97,9 +130,13 @@ public interface ResourceTransformationDescriptionBuilder extends Transformation * @param definition the resource definition * @param dynamicDiscardPolicy a checker to decide whether the child should be added or not * @return the builder for the child resource + * @deprecated Use {@link ResourceTransformationDescriptionBuilder#addChildResource(ResourceRegistration, DynamicDiscardPolicy)} instead. */ - ResourceTransformationDescriptionBuilder addChildResource(ResourceDefinition definition, DynamicDiscardPolicy dynamicDiscardPolicy); - + @Deprecated(forRemoval = true) + default ResourceTransformationDescriptionBuilder addChildResource(ResourceDefinition definition, DynamicDiscardPolicy dynamicDiscardPolicy) { + ResourceRegistration registration = definition; + return this.addChildResource(registration, dynamicDiscardPolicy); + } /** * Recursively discards all child resources and its operations. @@ -107,7 +144,17 @@ public interface ResourceTransformationDescriptionBuilder extends Transformation * @param pathElement the path element * @return the builder for the child resource */ - DiscardTransformationDescriptionBuilder discardChildResource(PathElement pathElement); + default DiscardTransformationDescriptionBuilder discardChildResource(PathElement pathElement) { + return this.discardChildResource(ResourceRegistration.of(pathElement)); + } + + /** + * Recursively discards all child resources and its operations. + * + * @param registration a resource registration + * @return the builder for the child resource + */ + DiscardTransformationDescriptionBuilder discardChildResource(ResourceRegistration registration); /** * Recursively rejects all child resources and its operations @@ -115,7 +162,17 @@ public interface ResourceTransformationDescriptionBuilder extends Transformation * @param pathElement the path element * @return the builder for the child resource */ - RejectTransformationDescriptionBuilder rejectChildResource(PathElement pathElement); + default RejectTransformationDescriptionBuilder rejectChildResource(PathElement pathElement) { + return this.rejectChildResource(ResourceRegistration.of(pathElement)); + } + + /** + * Recursively rejects all child resources and its operations + * + * @param registration a resource registration + * @return the builder for the child resource + */ + RejectTransformationDescriptionBuilder rejectChildResource(ResourceRegistration registration); /** * Add a child resource, where all operations will get redirected to the legacy address. You can either pass in @@ -129,7 +186,25 @@ public interface ResourceTransformationDescriptionBuilder extends Transformation * @param legacy the legacy path element. * @return the builder for the child resource */ - ResourceTransformationDescriptionBuilder addChildRedirection(PathElement current, PathElement legacy); + default ResourceTransformationDescriptionBuilder addChildRedirection(PathElement current, PathElement legacy) { + return this.addChildRedirection(ResourceRegistration.of(current), legacy); + } + + /** + * Add a child resource, where all operations will get redirected to the legacy address. You can either pass in + *
    + *
  • Fixed elements - e.g. {@code current:addr1=test} + {@code legacy:addr2=toast}, in which case {@code addr1=test} gets redirected to {@code addr2=toast}}
  • + *
  • Wildcard elements - e.g. {@code current:addr1=*} + {@code legacy:addr2=*}, in which case {@code addr1=test} gets redirected to {@code addr2=test}, + * {@code addr1=ping} gets redirected to {@code addr2=ping}, etc.
  • + *
+ * + * @param registration a resource registration + * @param legacy the legacy path element. + * @return the builder for the child resource + */ + default ResourceTransformationDescriptionBuilder addChildRedirection(ResourceRegistration registration, PathElement legacy) { + return this.addChildRedirection(registration, legacy, null); + } /** * Add a child resource, where all operations will get redirected to the legacy address. You can either pass in @@ -144,7 +219,29 @@ public interface ResourceTransformationDescriptionBuilder extends Transformation * @param dynamicDiscardPolicy a checker to decide whether the child should be added or not * @return the builder for the child resource */ - ResourceTransformationDescriptionBuilder addChildRedirection(PathElement current, PathElement legacy, DynamicDiscardPolicy dynamicDiscardPolicy); + default ResourceTransformationDescriptionBuilder addChildRedirection(PathElement current, PathElement legacy, DynamicDiscardPolicy dynamicDiscardPolicy) { + return this.addChildRedirection(ResourceRegistration.of(current), legacy, dynamicDiscardPolicy); + } + + /** + * Add a child resource, where all operations will get redirected to the legacy address. You can either pass in + *
    + *
  • Fixed elements - e.g. {@code current:addr1=test} + {@code legacy:addr2=toast}, in which case {@code addr1=test} gets redirected to {@code addr2=toast}}
  • + *
  • Wildcard elements - e.g. {@code current:addr1=*} + {@code legacy:addr2=*}, in which case {@code addr1=test} gets redirected to {@code addr2=test}, + * {@code addr1=ping} gets redirected to {@code addr2=ping}, etc.
  • + *
+ * + * @param registration a resource registration + * @param legacy the legacy path element. + * @param dynamicDiscardPolicy a checker to decide whether the child should be added or not + * @return the builder for the child resource + */ + default ResourceTransformationDescriptionBuilder addChildRedirection(ResourceRegistration registration, PathElement legacy, DynamicDiscardPolicy dynamicDiscardPolicy) { + PathElement path = registration.getPathElement(); + assert path.isWildcard() == legacy.isWildcard() : "wildcard mismatch between current and legacy paths"; + PathAddressTransformer transformation = legacy.isWildcard() ? new PathAddressTransformer.ReplaceElementKey(legacy.getKey()) : new PathAddressTransformer.BasicPathAddressTransformer(legacy); + return this.addChildRedirection(registration, transformation, dynamicDiscardPolicy); + } /** * Add a child resource, where all operation will get redirected to a different address defined by @@ -154,7 +251,21 @@ public interface ResourceTransformationDescriptionBuilder extends Transformation * @param pathAddressTransformer the path transformation * @return the builder for the child resource */ - ResourceTransformationDescriptionBuilder addChildRedirection(PathElement pathElement, PathAddressTransformer pathAddressTransformer); + default ResourceTransformationDescriptionBuilder addChildRedirection(PathElement pathElement, PathAddressTransformer pathAddressTransformer) { + return this.addChildRedirection(pathElement, pathAddressTransformer, null); + } + + /** + * Add a child resource, where all operation will get redirected to a different address defined by + * the path transformation. + * + * @param registration a resource registration + * @param pathAddressTransformer the path transformation + * @return the builder for the child resource + */ + default ResourceTransformationDescriptionBuilder addChildRedirection(ResourceRegistration registration, PathAddressTransformer pathAddressTransformer) { + return this.addChildRedirection(registration, pathAddressTransformer, null); + } /** * Add a child resource, where all operation will get redirected to a different address defined by @@ -165,14 +276,29 @@ public interface ResourceTransformationDescriptionBuilder extends Transformation * @param dynamicDiscardPolicy a checker to decide whether the child should be added or not * @return the builder for the child resource */ - ResourceTransformationDescriptionBuilder addChildRedirection(PathElement pathElement, PathAddressTransformer pathAddressTransformer, DynamicDiscardPolicy dynamicDiscardPolicy); + default ResourceTransformationDescriptionBuilder addChildRedirection(PathElement pathElement, PathAddressTransformer pathAddressTransformer, DynamicDiscardPolicy dynamicDiscardPolicy) { + return this.addChildRedirection(ResourceRegistration.of(pathElement), pathAddressTransformer, dynamicDiscardPolicy); + } + + /** + * Add a child resource, where all operation will get redirected to a different address defined by + * the path transformation. + * + * @param registration a resource registration + * @param pathAddressTransformer the path transformation + * @param dynamicDiscardPolicy a checker to decide whether the child should be added or not + * @return the builder for the child resource + */ + ResourceTransformationDescriptionBuilder addChildRedirection(ResourceRegistration registration, PathAddressTransformer pathAddressTransformer, DynamicDiscardPolicy dynamicDiscardPolicy); /** * Add an already created {@link TransformationDescriptionBuilder} as a child of this builder. * * @param builder the builder * @return the builder for this resource + * @deprecated Use other methods for creating child transformation descriptions */ + @Deprecated(forRemoval = true) ResourceTransformationDescriptionBuilder addChildBuilder(TransformationDescriptionBuilder builder); /** @@ -182,5 +308,4 @@ public interface ResourceTransformationDescriptionBuilder extends Transformation * @return the builder for this resource */ ResourceTransformationDescriptionBuilder discardOperations(String... operationNames); - } diff --git a/controller/src/main/java/org/jboss/as/controller/transform/description/ResourceTransformationDescriptionBuilderFactory.java b/controller/src/main/java/org/jboss/as/controller/transform/description/ResourceTransformationDescriptionBuilderFactory.java new file mode 100644 index 00000000000..5adfa55b3f8 --- /dev/null +++ b/controller/src/main/java/org/jboss/as/controller/transform/description/ResourceTransformationDescriptionBuilderFactory.java @@ -0,0 +1,32 @@ +/* + * Copyright The WildFly Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +package org.jboss.as.controller.transform.description; + +import org.jboss.as.controller.FeatureRegistry; +import org.jboss.as.controller.PathElement; + +/** + * A factory for creating transformation description builders. + */ +public interface ResourceTransformationDescriptionBuilderFactory extends FeatureRegistry { + + /** + * Creates a builder of a transformation description for a root resource. + * @return a builder of a transformation description. + */ + default ResourceTransformationDescriptionBuilder createResourceTransformationDescriptionBuilder() { + return this.createResourceTransformationDescriptionBuilder(null); + } + + /** + * Creates a builder of a transformation description for a resource. + * @param path the path of the target resource + * @return a builder of a transformation description. + */ + default ResourceTransformationDescriptionBuilder createResourceTransformationDescriptionBuilder(PathElement path) { + return new ResourceTransformationDescriptionBuilderImpl(this.getStability(), path); + } +} diff --git a/controller/src/main/java/org/jboss/as/controller/transform/description/ResourceTransformationDescriptionBuilderImpl.java b/controller/src/main/java/org/jboss/as/controller/transform/description/ResourceTransformationDescriptionBuilderImpl.java index 3e1bc12958f..7afc1adb33f 100644 --- a/controller/src/main/java/org/jboss/as/controller/transform/description/ResourceTransformationDescriptionBuilderImpl.java +++ b/controller/src/main/java/org/jboss/as/controller/transform/description/ResourceTransformationDescriptionBuilderImpl.java @@ -10,10 +10,11 @@ import java.util.List; import org.jboss.as.controller.PathElement; -import org.jboss.as.controller.ResourceDefinition; +import org.jboss.as.controller.ResourceRegistration; import org.jboss.as.controller.transform.OperationTransformer; import org.jboss.as.controller.transform.PathAddressTransformer; import org.jboss.as.controller.transform.ResourceTransformer; +import org.jboss.as.version.Stability; /** * @author Emanuel Muckenhuber @@ -25,94 +26,60 @@ class ResourceTransformationDescriptionBuilderImpl extends AbstractTransformatio private DiscardPolicy discardPolicy = DiscardPolicy.NEVER; private final AttributeTransformationDescriptionBuilderImpl.AttributeTransformationDescriptionBuilderRegistry registry = new AttributeTransformationDescriptionBuilderImpl.AttributeTransformationDescriptionBuilderRegistry(); - protected ResourceTransformationDescriptionBuilderImpl(final PathElement pathElement) { - this(pathElement, PathAddressTransformer.DEFAULT); + protected ResourceTransformationDescriptionBuilderImpl(Stability stability, final PathElement pathElement) { + this(stability, pathElement, PathAddressTransformer.DEFAULT); } - protected ResourceTransformationDescriptionBuilderImpl(final PathElement pathElement, final PathAddressTransformer pathAddressTransformer) { - this(pathElement, pathAddressTransformer, null); + protected ResourceTransformationDescriptionBuilderImpl(Stability stability, final PathElement pathElement, final PathAddressTransformer pathAddressTransformer) { + this(stability, pathElement, pathAddressTransformer, null); } - protected ResourceTransformationDescriptionBuilderImpl(PathElement pathElement, DynamicDiscardPolicy dynamicDiscardPolicy) { - this(pathElement, PathAddressTransformer.DEFAULT, dynamicDiscardPolicy); + protected ResourceTransformationDescriptionBuilderImpl(Stability stability, PathElement pathElement, DynamicDiscardPolicy dynamicDiscardPolicy) { + this(stability, pathElement, PathAddressTransformer.DEFAULT, dynamicDiscardPolicy); } - protected ResourceTransformationDescriptionBuilderImpl(final PathElement pathElement, + protected ResourceTransformationDescriptionBuilderImpl(Stability stability, final PathElement pathElement, final PathAddressTransformer pathAddressTransformer, DynamicDiscardPolicy dynamicDiscardPolicy) { - super(pathElement, pathAddressTransformer, ResourceTransformer.DEFAULT, OperationTransformer.DEFAULT, + super(stability, pathElement, pathAddressTransformer, ResourceTransformer.DEFAULT, OperationTransformer.DEFAULT, dynamicDiscardPolicy); } @Override - public ResourceTransformationDescriptionBuilder addChildResource(final PathElement pathElement) { - return addChildResource(pathElement, null); - } - - @Override - public ResourceTransformationDescriptionBuilder addChildResource(PathElement pathElement, DynamicDiscardPolicy dynamicDiscardPolicy) { - final ResourceTransformationDescriptionBuilderImpl builder = new ResourceTransformationDescriptionBuilderImpl( - pathElement, dynamicDiscardPolicy); - children.add(builder); + public ResourceTransformationDescriptionBuilder addChildResource(ResourceRegistration registration, DynamicDiscardPolicy dynamicDiscardPolicy) { + final ResourceTransformationDescriptionBuilderImpl builder = new ResourceTransformationDescriptionBuilderImpl(this.getStability(), registration.getPathElement(), dynamicDiscardPolicy); + if (this.enables(registration)) { + this.children.add(builder); + } return builder; } @Override - public ResourceTransformationDescriptionBuilder addChildResource(final ResourceDefinition definition) { - return addChildResource(definition.getPathElement(), null); - } - - @Override - public ResourceTransformationDescriptionBuilder addChildResource(ResourceDefinition definition, DynamicDiscardPolicy dynamicDiscardPolicy) { - return addChildResource(definition.getPathElement(), dynamicDiscardPolicy); - } - - @Override - public DiscardTransformationDescriptionBuilder discardChildResource(final PathElement pathElement) { - final DiscardTransformationDescriptionBuilder builder = TransformationDescriptionBuilder.Factory.createDiscardInstance(pathElement); - children.add(builder); + public DiscardTransformationDescriptionBuilder discardChildResource(ResourceRegistration registration) { + final DiscardTransformationDescriptionBuilder builder = new DiscardTransformationDescriptionBuilder(this.getStability(), registration.getPathElement()); + if (this.enables(registration)) { + this.children.add(builder); + } return builder; } @Override - public RejectTransformationDescriptionBuilder rejectChildResource(PathElement pathElement) { - final RejectTransformationDescriptionBuilder builder = TransformationDescriptionBuilder.Factory.createRejectInstance(pathElement); - children.add(builder); + public RejectTransformationDescriptionBuilder rejectChildResource(ResourceRegistration registration) { + final RejectTransformationDescriptionBuilder builder = new RejectTransformationDescriptionBuilder(this.getStability(), registration.getPathElement()); + if (this.enables(registration)) { + this.children.add(builder); + } return builder; } - @Override - public ResourceTransformationDescriptionBuilder addChildRedirection(final PathElement current, final PathElement legacy) { - return addChildRedirection(current, legacy, null); - } - - @Override - public ResourceTransformationDescriptionBuilder addChildRedirection(PathElement current, PathElement legacy, DynamicDiscardPolicy dynamicDiscardPolicy) { - final PathAddressTransformer transformation; - if (legacy.isWildcard()) { - assert current.isWildcard() : "legacy is wildcard while current is not"; - transformation = new PathAddressTransformer.ReplaceElementKey(legacy.getKey()); - } else { - assert !current.isWildcard() : "legacy is fixed while current is not"; - transformation = new PathAddressTransformer.BasicPathAddressTransformer(legacy); + public ResourceTransformationDescriptionBuilder addChildRedirection(ResourceRegistration registration, PathAddressTransformer pathAddressTransformer, DynamicDiscardPolicy dynamicDiscardPolicy) { + final ResourceTransformationDescriptionBuilderImpl builder = new ResourceTransformationDescriptionBuilderImpl(this.getStability(), registration.getPathElement(), pathAddressTransformer, dynamicDiscardPolicy); + if (this.enables(registration)) { + this.children.add(builder); } - return addChildRedirection(current, transformation, dynamicDiscardPolicy); - - } - - @Override - public ResourceTransformationDescriptionBuilder addChildRedirection(final PathElement oldAddress, final PathAddressTransformer pathAddressTransformer) { - return addChildRedirection(oldAddress, pathAddressTransformer, null); - } - - @Override - public ResourceTransformationDescriptionBuilder addChildRedirection(PathElement oldAddress, PathAddressTransformer pathAddressTransformer, DynamicDiscardPolicy dynamicDiscardPolicy) { - final ResourceTransformationDescriptionBuilderImpl builder = new ResourceTransformationDescriptionBuilderImpl(oldAddress, pathAddressTransformer, dynamicDiscardPolicy); - children.add(builder); return builder; } - @Override public ResourceTransformationDescriptionBuilder addChildBuilder(TransformationDescriptionBuilder builder) { children.add(builder); diff --git a/controller/src/main/java/org/jboss/as/controller/transform/description/TransformationDescriptionBuilder.java b/controller/src/main/java/org/jboss/as/controller/transform/description/TransformationDescriptionBuilder.java index 8de298056df..2e412f8f570 100644 --- a/controller/src/main/java/org/jboss/as/controller/transform/description/TransformationDescriptionBuilder.java +++ b/controller/src/main/java/org/jboss/as/controller/transform/description/TransformationDescriptionBuilder.java @@ -5,15 +5,17 @@ package org.jboss.as.controller.transform.description; +import org.jboss.as.controller.FeatureRegistry; import org.jboss.as.controller.ModelVersion; import org.jboss.as.controller.PathElement; +import org.jboss.as.version.Stability; /** * A transformation description builder. * * @author Emanuel Muckenhuber */ -public interface TransformationDescriptionBuilder { +public interface TransformationDescriptionBuilder extends FeatureRegistry { /** * Build the transformation description. Modifications to the builder won't affect the built description after this @@ -23,15 +25,17 @@ public interface TransformationDescriptionBuilder { */ TransformationDescription build(); + @Deprecated(forRemoval = true) class Factory { /** * Create a resource builder instance. * * @return the transformation builder + * @deprecated Superseded by {@link ResourceTransformationDescriptionBuilderFactory#createResourceTransformationDescriptionBuilder()} */ public static ResourceTransformationDescriptionBuilder createSubsystemInstance() { - return new ResourceTransformationDescriptionBuilderImpl(null); + return new ResourceTransformationDescriptionBuilderImpl(Stability.DEFAULT, null); } /** @@ -39,9 +43,10 @@ public static ResourceTransformationDescriptionBuilder createSubsystemInstance() * * @param pathElement the path element of the child to be transformed * @return the transformation builder + * @deprecated Superseded by {@link ResourceTransformationDescriptionBuilderFactory#createResourceTransformationDescriptionBuilder(PathElement)} */ public static ResourceTransformationDescriptionBuilder createInstance(final PathElement pathElement) { - return new ResourceTransformationDescriptionBuilderImpl(pathElement); + return new ResourceTransformationDescriptionBuilderImpl(Stability.DEFAULT, pathElement); } /** @@ -49,9 +54,10 @@ public static ResourceTransformationDescriptionBuilder createInstance(final Path * * @param pathElement the path element of the child to be transformed * @return the transformation builder + * @deprecated To be removed without replacement. */ public static DiscardTransformationDescriptionBuilder createDiscardInstance(PathElement pathElement) { - return new DiscardTransformationDescriptionBuilder(pathElement); + return new DiscardTransformationDescriptionBuilder(Stability.DEFAULT, pathElement); } /** @@ -59,18 +65,20 @@ public static DiscardTransformationDescriptionBuilder createDiscardInstance(Path * * @param pathElement the path element of the child to be transformed * @return the transformation builder + * @deprecated To be removed without replacement. */ public static RejectTransformationDescriptionBuilder createRejectInstance(PathElement pathElement) { - return new RejectTransformationDescriptionBuilder(pathElement); + return new RejectTransformationDescriptionBuilder(Stability.DEFAULT, pathElement); } /** * Create a chained builder instance for a subsystem * * @param currentVersion the current version of the subsystem. + * @deprecated Superseded by {@link ChainedTransformationDescriptionBuilderFactory#createChainedTransformationDescriptionBuilder()} */ public static ChainedTransformationDescriptionBuilder createChainedSubystemInstance(ModelVersion currentVersion) { - return new ChainedTransformationDescriptionBuilderImpl(currentVersion, null); + return new ChainedTransformationDescriptionBuilderImpl(currentVersion, Stability.DEFAULT, null); } /** @@ -78,9 +86,10 @@ public static ChainedTransformationDescriptionBuilder createChainedSubystemInsta * * @param pathElement the child resource element which the chained transformers handle * @param currentVersion the current version of the model containing the resource being transformed. + * @deprecated Superseded by {@link ChainedTransformationDescriptionBuilderFactory#createChainedTransformationDescriptionBuilder(PathElement)} */ public static ChainedTransformationDescriptionBuilder createChainedInstance(PathElement pathElement, ModelVersion currentVersion) { - return new ChainedTransformationDescriptionBuilderImpl(currentVersion, pathElement); + return new ChainedTransformationDescriptionBuilderImpl(currentVersion, Stability.DEFAULT, pathElement); } } diff --git a/controller/src/test/java/org/jboss/as/controller/transform/description/BasicResourceTestCase.java b/controller/src/test/java/org/jboss/as/controller/transform/description/BasicResourceTestCase.java index 62bbf5a58d4..5882298978b 100644 --- a/controller/src/test/java/org/jboss/as/controller/transform/description/BasicResourceTestCase.java +++ b/controller/src/test/java/org/jboss/as/controller/transform/description/BasicResourceTestCase.java @@ -12,10 +12,14 @@ import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.REMOVE; import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.STEPS; +import java.util.Collection; import java.util.Collections; +import java.util.EnumSet; import java.util.Locale; import java.util.NoSuchElementException; +import java.util.stream.Collectors; +import org.jboss.as.controller.AttributeDefinition; import org.jboss.as.controller.ExpressionResolver; import org.jboss.as.controller.ModelVersion; import org.jboss.as.controller.OperationFailedException; @@ -23,7 +27,9 @@ import org.jboss.as.controller.PathElement; import org.jboss.as.controller.ProcessType; import org.jboss.as.controller.ResourceDefinition; +import org.jboss.as.controller.ResourceRegistration; import org.jboss.as.controller.RunningMode; +import org.jboss.as.controller.SimpleAttributeDefinitionBuilder; import org.jboss.as.controller.SimpleResourceDefinition; import org.jboss.as.controller.descriptions.ModelDescriptionConstants; import org.jboss.as.controller.descriptions.NonResolvingResourceDescriptionResolver; @@ -41,40 +47,58 @@ import org.jboss.as.controller.transform.TransformerRegistry; import org.jboss.as.controller.transform.Transformers; import org.jboss.as.controller.transform.TransformersSubRegistration; +import org.jboss.as.version.Stability; import org.jboss.dmr.ModelNode; import org.jboss.dmr.ModelType; import org.junit.Assert; -import org.junit.Before; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; /** * @author Emanuel Muckenhuber */ +@RunWith(Parameterized.class) public class BasicResourceTestCase { + @Parameterized.Parameters + public static Iterable parameters() { + return EnumSet.allOf(Stability.class); + } + + private static final PathElement PATH = PathElement.pathElement("toto", "testSubsystem"); + private static final AttributeDefinition COMMUNITY_SUBSYSTEM_ATTRIBUTE = new SimpleAttributeDefinitionBuilder("community", ModelType.BOOLEAN).setRequired(false).setDefaultValue(ModelNode.TRUE).setStability(Stability.COMMUNITY).build(); + private static final Collection DISCARDED_RESOURCES = EnumSet.allOf(Stability.class).stream().map(stability -> ResourceRegistration.of(PathElement.pathElement(stability.name()), stability)).collect(Collectors.toList()); + private static final PathElement DISCARD = PathElement.pathElement("discard"); + private static final PathElement DYNAMIC = PathElement.pathElement("dynamic"); + private static final PathElement DYNAMIC_REDIRECT_ORIGINAL = PathElement.pathElement("dynamic-redirect-original"); + private static final PathElement DYNAMIC_REDIRECT_NEW = PathElement.pathElement("dynamic-redirect-new"); + private static final ResourceRegistration FOO_RESOURCE = ResourceRegistration.of(PathElement.pathElement("child", "foo"), Stability.COMMUNITY); + private static final AttributeDefinition FOO_ATTRIBUTE = new SimpleAttributeDefinitionBuilder("preview-attribute", ModelType.BOOLEAN).setRequired(false).setDefaultValue(ModelNode.TRUE).setStability(Stability.PREVIEW).build(); + private static final ResourceRegistration FOO_BAR_RESOURCE = ResourceRegistration.of(PathElement.pathElement("grandchild", "bar"), Stability.PREVIEW); + private static final AttributeDefinition FOO_BAR_ATTRIBUTE = new SimpleAttributeDefinitionBuilder("experimental-attribute", ModelType.BOOLEAN).setRequired(false).setDefaultValue(ModelNode.TRUE).setStability(Stability.EXPERIMENTAL).build(); - private static PathElement PATH = PathElement.pathElement("toto", "testSubsystem"); - private static PathElement DISCARD = PathElement.pathElement("discard"); - private static PathElement DYNAMIC = PathElement.pathElement("dynamic"); - private static PathElement DYNAMIC_REDIRECT_ORIGINAL = PathElement.pathElement("dynamic-redirect-original"); - private static PathElement DYNAMIC_REDIRECT_NEW = PathElement.pathElement("dynamic-redirect-new"); + private static final PathElement CONFIGURATION_TEST = PathElement.pathElement("configuration", "test"); + private static final PathElement TEST_CONFIGURATION = PathElement.pathElement("test", "configuration"); - private static PathElement CONFIGURATION_TEST = PathElement.pathElement("configuration", "test"); - private static PathElement TEST_CONFIGURATION = PathElement.pathElement("test", "configuration"); + private static final PathElement SETTING_DIRECTORY = PathElement.pathElement("setting", "directory"); + private static final PathElement DIRECTORY_SETTING = PathElement.pathElement("directory", "setting"); - private static PathElement SETTING_DIRECTORY = PathElement.pathElement("setting", "directory"); - private static PathElement DIRECTORY_SETTING = PathElement.pathElement("directory", "setting"); + private final Resource resourceRoot = Resource.Factory.create(); + private final TransformerRegistry registry; + private final ManagementResourceRegistration resourceRegistration; - private Resource resourceRoot = Resource.Factory.create(); - private TransformerRegistry registry = TransformerRegistry.Factory.create(); - private ManagementResourceRegistration resourceRegistration = ManagementResourceRegistration.Factory.forProcessType(ProcessType.EMBEDDED_SERVER).createRegistration(ROOT); + private final TransformationDescription description; - private static final TransformationDescription description; + public BasicResourceTestCase(Stability stability) { + this.resourceRegistration = ManagementResourceRegistration.Factory.forProcessType(ProcessType.EMBEDDED_SERVER, stability).createRegistration(ROOT); + this.registry = TransformerRegistry.Factory.create(stability); + final ResourceTransformationDescriptionBuilder builder = this.registry.createResourceTransformationDescriptionBuilder(PATH); - static { - // Build - final ResourceTransformationDescriptionBuilder builder = TransformationDescriptionBuilder.Factory.createInstance(PATH); + DISCARDED_RESOURCES.forEach(builder::discardChildResource); builder.getAttributeBuilder() + .setDiscard(new DiscardAttributeChecker.DiscardAttributeValueChecker(COMMUNITY_SUBSYSTEM_ATTRIBUTE.getDefaultValue()), COMMUNITY_SUBSYSTEM_ATTRIBUTE) + .addRejectCheck(RejectAttributeChecker.DEFINED, COMMUNITY_SUBSYSTEM_ATTRIBUTE) .addRejectCheck(RejectAttributeChecker.SIMPLE_EXPRESSIONS, "test") .setValueConverter(AttributeConverter.Factory.createHardCoded(ModelNode.TRUE), "othertest") .end(); @@ -181,16 +205,18 @@ protected void convertAttribute(PathAddress address, String attributeName, Model .getAttributeBuilder().addRejectCheck(RejectAttributeChecker.SIMPLE_EXPRESSIONS, "test-config").end() .addChildRedirection(SETTING_DIRECTORY, DIRECTORY_SETTING); + builder.addChildResource(FOO_RESOURCE).getAttributeBuilder() + .setDiscard(new DiscardAttributeChecker.DiscardAttributeValueChecker(FOO_ATTRIBUTE.getDefaultValue()), FOO_ATTRIBUTE) + .addRejectCheck(RejectAttributeChecker.DEFINED, FOO_ATTRIBUTE) + .end() + .addChildResource(FOO_BAR_RESOURCE).getAttributeBuilder() + .setDiscard(new DiscardAttributeChecker.DiscardAttributeValueChecker(FOO_BAR_ATTRIBUTE.getDefaultValue()), FOO_BAR_ATTRIBUTE) + .addRejectCheck(RejectAttributeChecker.DEFINED, FOO_BAR_ATTRIBUTE) + .end(); + // Register at the server root - description = builder.build(); - } + this.description = builder.build(); - @Before - public void setUp() { - // Cleanup - resourceRoot = Resource.Factory.create(); - registry = TransformerRegistry.Factory.create(); - resourceRegistration = ManagementResourceRegistration.Factory.forProcessType(ProcessType.EMBEDDED_SERVER).createRegistration(ROOT); // test final Resource toto = Resource.Factory.create(); toto.getModel().get("test").set("onetwothree"); @@ -238,7 +264,30 @@ public void setUp() { resourceAttr.getModel().get("test-attribute").set("test"); attrResource.registerChild(PathElement.pathElement("resource-attribute", "test"), resourceAttr); - // + for (ResourceRegistration discardedResource : DISCARDED_RESOURCES) { + if (this.resourceRegistration.enables(discardedResource)) { + toto.registerChild(PathElement.pathElement(discardedResource.getPathElement().getKey(), "discard"), Resource.Factory.create()); + } + } + + if (this.resourceRegistration.enables(COMMUNITY_SUBSYSTEM_ATTRIBUTE)) { + toto.getModel().get(COMMUNITY_SUBSYSTEM_ATTRIBUTE.getName()).set(COMMUNITY_SUBSYSTEM_ATTRIBUTE.getDefaultValue()); + } + if (this.resourceRegistration.enables(FOO_RESOURCE)) { + Resource foo = Resource.Factory.create(); + toto.registerChild(FOO_RESOURCE.getPathElement(), foo); + if (this.resourceRegistration.enables(FOO_ATTRIBUTE)) { + foo.getModel().get(FOO_ATTRIBUTE.getName()).set(FOO_ATTRIBUTE.getDefaultValue()); + } + if (this.resourceRegistration.enables(FOO_BAR_RESOURCE)) { + Resource bar = Resource.Factory.create(); + foo.registerChild(FOO_BAR_RESOURCE.getPathElement(), bar); + if (this.resourceRegistration.enables(FOO_BAR_ATTRIBUTE)) { + bar.getModel().get(FOO_BAR_ATTRIBUTE.getName()).set(FOO_BAR_ATTRIBUTE.getDefaultValue()); + } + } + } + resourceRoot.registerChild(PATH, toto); // Register the description @@ -286,6 +335,29 @@ public void testResourceTransformation() throws Exception { Assert.assertFalse(attResourceModel.get("test-resource").isDefined()); // check that the resource got removed Assert.assertTrue(attResourceModel.hasDefined("test-attribute")); Assert.assertTrue(attResource.hasChild(PathElement.pathElement("resource", "test"))); + + for (ResourceRegistration discardedResource : DISCARDED_RESOURCES) { + if (this.resourceRegistration.enables(discardedResource)) { + Assert.assertFalse(toto.hasChild(discardedResource.getPathElement())); + } + } + if (this.resourceRegistration.enables(COMMUNITY_SUBSYSTEM_ATTRIBUTE)) { + Assert.assertFalse(model.hasDefined(COMMUNITY_SUBSYSTEM_ATTRIBUTE.getName())); + } + if (this.resourceRegistration.enables(FOO_RESOURCE)) { + Assert.assertTrue(toto.hasChild(FOO_RESOURCE.getPathElement())); + Resource foo = toto.getChild(FOO_RESOURCE.getPathElement()); + if (this.resourceRegistration.enables(FOO_ATTRIBUTE)) { + Assert.assertFalse(foo.getModel().hasDefined(FOO_ATTRIBUTE.getName())); + if (this.resourceRegistration.enables(FOO_BAR_RESOURCE)) { + Assert.assertTrue(foo.hasChild(FOO_BAR_RESOURCE.getPathElement())); + Resource bar = foo.getChild(FOO_BAR_RESOURCE.getPathElement()); + if (this.resourceRegistration.enables(FOO_BAR_ATTRIBUTE)) { + Assert.assertFalse(bar.getModel().hasDefined(FOO_BAR_ATTRIBUTE.getName())); + } + } + } + } } @Test diff --git a/host-controller/src/main/java/org/jboss/as/domain/controller/transformers/DeploymentTransformers.java b/host-controller/src/main/java/org/jboss/as/domain/controller/transformers/DeploymentTransformers.java index ce95450a8c7..c5d3c78f2df 100644 --- a/host-controller/src/main/java/org/jboss/as/domain/controller/transformers/DeploymentTransformers.java +++ b/host-controller/src/main/java/org/jboss/as/domain/controller/transformers/DeploymentTransformers.java @@ -13,7 +13,6 @@ import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.READ_CONTENT; import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.REMOVE_CONTENT; import static org.jboss.as.domain.controller.transformers.KernelAPIVersion.createBuilderFromCurrent; -import static org.jboss.as.domain.controller.transformers.KernelAPIVersion.createChainFromCurrent; import static org.jboss.as.server.controller.resources.DeploymentAttributes.isUnmanagedContent; import java.util.Map; @@ -23,6 +22,7 @@ import org.jboss.as.controller.transform.TransformationContext; import org.jboss.as.controller.transform.description.AttributeConverter; import org.jboss.as.controller.transform.description.ChainedTransformationDescriptionBuilder; +import org.jboss.as.controller.transform.description.ChainedTransformationDescriptionBuilderFactory; import org.jboss.as.controller.transform.description.DiscardAttributeChecker; import org.jboss.as.controller.transform.description.RejectAttributeChecker; import org.jboss.as.controller.transform.description.ResourceTransformationDescriptionBuilder; @@ -35,8 +35,8 @@ * @author Emmanuel Hugonnet (c) 2016 Red Hat, inc. */ class DeploymentTransformers { - static ChainedTransformationDescriptionBuilder buildTransformerChain() { - ChainedTransformationDescriptionBuilder chainedBuilder = createChainFromCurrent(DeploymentResourceDefinition.PATH); + static ChainedTransformationDescriptionBuilder buildTransformerChain(ChainedTransformationDescriptionBuilderFactory factory) { + ChainedTransformationDescriptionBuilder chainedBuilder = factory.createChainedTransformationDescriptionBuilder(DeploymentResourceDefinition.PATH); ResourceTransformationDescriptionBuilder builder = createBuilderFromCurrent(chainedBuilder, KernelAPIVersion.VERSION_4_1); builder diff --git a/host-controller/src/main/java/org/jboss/as/domain/controller/transformers/DomainTransformers.java b/host-controller/src/main/java/org/jboss/as/domain/controller/transformers/DomainTransformers.java index 71c7e5965ed..dab464f5635 100644 --- a/host-controller/src/main/java/org/jboss/as/domain/controller/transformers/DomainTransformers.java +++ b/host-controller/src/main/java/org/jboss/as/domain/controller/transformers/DomainTransformers.java @@ -37,11 +37,11 @@ import org.jboss.as.controller.transform.TransformerRegistry; import org.jboss.as.controller.transform.TransformersSubRegistration; import org.jboss.as.controller.transform.description.ChainedTransformationDescriptionBuilder; +import org.jboss.as.controller.transform.description.ChainedTransformationDescriptionBuilderFactory; import org.jboss.as.controller.transform.description.DiscardAttributeChecker; import org.jboss.as.controller.transform.description.RejectAttributeChecker; import org.jboss.as.controller.transform.description.ResourceTransformationDescriptionBuilder; import org.jboss.as.controller.transform.description.TransformationDescription; -import org.jboss.as.controller.transform.description.TransformationDescriptionBuilder; import org.jboss.as.domain.controller.logging.DomainControllerLogger; import org.jboss.as.domain.controller.operations.DomainServerLifecycleHandlers; import org.jboss.as.domain.controller.resources.HostExcludeResourceDefinition; @@ -66,11 +66,12 @@ public static void initializeDomainRegistry(final TransformerRegistry registry) //For JBoss EAP: 8.0.0 -> 5.0.0 -> 4.0.0 -> 1.8.0 -> 1.7.0 -> 1.6.0 -> 1.5.0 registerRootTransformers(registry); - registerChainedManagementTransformers(registry); - registerChainedServerGroupTransformers(registry); + ChainedTransformationDescriptionBuilderFactory factory = KernelAPIVersion.createChainedTransformationDescriptionBuilderFactory(registry); + registerChainedManagementTransformers(registry, factory); + registerChainedServerGroupTransformers(registry, factory); registerProfileTransformers(registry); - registerSocketBindingGroupTransformers(registry); - registerDeploymentTransformers(registry); + registerSocketBindingGroupTransformers(registry, factory); + registerDeploymentTransformers(registry, factory); } private static void registerRootTransformers(TransformerRegistry registry) { @@ -91,7 +92,7 @@ private static void registerRootTransformers(TransformerRegistry registry) { // FIRST: versions with special transformations //todo we should use ChainedTransformationDescriptionBuilder but it doesn't work properly with "root" resources - ResourceTransformationDescriptionBuilder builder = TransformationDescriptionBuilder.Factory.createInstance(null); + ResourceTransformationDescriptionBuilder builder = registry.createResourceTransformationDescriptionBuilder(); // discard host-exclude builder.discardChildResource(HostExcludeResourceDefinition.PATH_ELEMENT); @@ -109,7 +110,7 @@ private static void registerRootTransformers(TransformerRegistry registry) { // NEXT: We've registered all the versions that have special transformation needs. // Now, we register a transformer for every other version that discards host-exclude - builder = TransformationDescriptionBuilder.Factory.createInstance(null); + builder = registry.createResourceTransformationDescriptionBuilder(); builder.discardChildResource(HostExcludeResourceDefinition.PATH_ELEMENT); for (KernelAPIVersion version : allOthers) { TransformersSubRegistration domain = registry.getDomainRegistration(version.modelVersion); @@ -125,13 +126,13 @@ private static void registerNonChainedTransformers(Set remaind } } - private static void registerChainedManagementTransformers(TransformerRegistry registry) { - ChainedTransformationDescriptionBuilder builder = ManagementTransformers.buildTransformerChain(); + private static void registerChainedManagementTransformers(TransformerRegistry registry, ChainedTransformationDescriptionBuilderFactory factory) { + ChainedTransformationDescriptionBuilder builder = ManagementTransformers.buildTransformerChain(factory); registerChainedTransformer(registry, builder, VERSION_1_7, VERSION_1_8, VERSION_4_1); } - private static void registerChainedServerGroupTransformers(TransformerRegistry registry) { - ChainedTransformationDescriptionBuilder builder = ServerGroupTransformers.buildTransformerChain(); + private static void registerChainedServerGroupTransformers(TransformerRegistry registry, ChainedTransformationDescriptionBuilderFactory factory) { + ChainedTransformationDescriptionBuilder builder = ServerGroupTransformers.buildTransformerChain(factory); registerChainedTransformer(registry, builder, VERSION_15_0, VERSION_13_0, VERSION_10_0, VERSION_8_0, VERSION_7_0, VERSION_6_0, VERSION_5_0, VERSION_4_1, VERSION_4_0, VERSION_3_0, VERSION_2_1, VERSION_2_0, VERSION_1_8, VERSION_1_7); @@ -145,8 +146,7 @@ private static void registerProfileTransformers(TransformerRegistry registry) { //but it is very handy for testing the 'clone' behaviour final KernelAPIVersion[] PRE_PROFILE_CLONE_VERSIONS = new KernelAPIVersion[]{VERSION_3_0, VERSION_2_1, VERSION_2_0, VERSION_1_8, VERSION_1_7}; for (KernelAPIVersion version : PRE_PROFILE_CLONE_VERSIONS) { - ResourceTransformationDescriptionBuilder builder = - ResourceTransformationDescriptionBuilder.Factory.createInstance(ProfileResourceDefinition.PATH); + ResourceTransformationDescriptionBuilder builder = registry.createResourceTransformationDescriptionBuilder(ProfileResourceDefinition.PATH); builder.getAttributeBuilder() .addRejectCheck(RejectAttributeChecker.DEFINED, ProfileResourceDefinition.INCLUDES) .setDiscard(DiscardAttributeChecker.UNDEFINED, ProfileResourceDefinition.INCLUDES) @@ -158,8 +158,8 @@ private static void registerProfileTransformers(TransformerRegistry registry) { } } - private static void registerSocketBindingGroupTransformers(TransformerRegistry registry) { - ChainedTransformationDescriptionBuilder builder = SocketBindingGroupTransformers.buildTransformerChain(); + private static void registerSocketBindingGroupTransformers(TransformerRegistry registry, ChainedTransformationDescriptionBuilderFactory factory) { + ChainedTransformationDescriptionBuilder builder = SocketBindingGroupTransformers.buildTransformerChain(factory); registerChainedTransformer(registry, builder, VERSION_1_8, VERSION_1_7); } @@ -170,8 +170,8 @@ private static void registerChainedTransformer(TransformerRegistry registry, Cha } } - private static void registerDeploymentTransformers(TransformerRegistry registry) { - ChainedTransformationDescriptionBuilder builder = DeploymentTransformers.buildTransformerChain(); + private static void registerDeploymentTransformers(TransformerRegistry registry, ChainedTransformationDescriptionBuilderFactory factory) { + ChainedTransformationDescriptionBuilder builder = DeploymentTransformers.buildTransformerChain(factory); registerChainedTransformer(registry, builder, VERSION_4_1, VERSION_4_0, VERSION_3_0, VERSION_2_1, VERSION_2_0, VERSION_1_8, VERSION_1_7); } diff --git a/host-controller/src/main/java/org/jboss/as/domain/controller/transformers/KernelAPIVersion.java b/host-controller/src/main/java/org/jboss/as/domain/controller/transformers/KernelAPIVersion.java index b70a737ec00..fd1debe30ba 100644 --- a/host-controller/src/main/java/org/jboss/as/domain/controller/transformers/KernelAPIVersion.java +++ b/host-controller/src/main/java/org/jboss/as/domain/controller/transformers/KernelAPIVersion.java @@ -6,10 +6,11 @@ package org.jboss.as.domain.controller.transformers; import org.jboss.as.controller.ModelVersion; -import org.jboss.as.controller.PathElement; +import org.jboss.as.controller.transform.TransformerRegistry; import org.jboss.as.controller.transform.description.ChainedTransformationDescriptionBuilder; +import org.jboss.as.controller.transform.description.ChainedTransformationDescriptionBuilderFactory; import org.jboss.as.controller.transform.description.ResourceTransformationDescriptionBuilder; -import org.jboss.as.controller.transform.description.TransformationDescriptionBuilder; +import org.jboss.as.version.Stability; import org.jboss.as.version.Version; /** @@ -95,8 +96,18 @@ public ModelVersion getModelVersion() { return modelVersion; } - static ChainedTransformationDescriptionBuilder createChainFromCurrent(PathElement forPath) { - return TransformationDescriptionBuilder.Factory.createChainedInstance(forPath, CURRENT.modelVersion); + static ChainedTransformationDescriptionBuilderFactory createChainedTransformationDescriptionBuilderFactory(TransformerRegistry registry) { + return new ChainedTransformationDescriptionBuilderFactory() { + @Override + public Stability getStability() { + return registry.getStability(); + } + + @Override + public ModelVersion getCurrentVersion() { + return CURRENT.getModelVersion(); + } + }; } static ResourceTransformationDescriptionBuilder createBuilder(ChainedTransformationDescriptionBuilder chainBuilder, KernelAPIVersion from, KernelAPIVersion to) { diff --git a/host-controller/src/main/java/org/jboss/as/domain/controller/transformers/ManagementTransformers.java b/host-controller/src/main/java/org/jboss/as/domain/controller/transformers/ManagementTransformers.java index deb031d2c18..ba4a5668007 100644 --- a/host-controller/src/main/java/org/jboss/as/domain/controller/transformers/ManagementTransformers.java +++ b/host-controller/src/main/java/org/jboss/as/domain/controller/transformers/ManagementTransformers.java @@ -7,11 +7,11 @@ import static org.jboss.as.domain.controller.transformers.KernelAPIVersion.createBuilder; import static org.jboss.as.domain.controller.transformers.KernelAPIVersion.createBuilderFromCurrent; -import static org.jboss.as.domain.controller.transformers.KernelAPIVersion.createChainFromCurrent; import org.jboss.as.controller.PathElement; import org.jboss.as.controller.access.constraint.SensitivityClassification; import org.jboss.as.controller.transform.description.ChainedTransformationDescriptionBuilder; +import org.jboss.as.controller.transform.description.ChainedTransformationDescriptionBuilderFactory; import org.jboss.as.controller.transform.description.ResourceTransformationDescriptionBuilder; import org.jboss.as.domain.management.CoreManagementResourceDefinition; import org.jboss.as.domain.management.access.AccessAuthorizationResourceDefinition; @@ -31,10 +31,10 @@ private ManagementTransformers() { // prevent instantiation } - static ChainedTransformationDescriptionBuilder buildTransformerChain() { + static ChainedTransformationDescriptionBuilder buildTransformerChain(ChainedTransformationDescriptionBuilderFactory factory) { // Discard the domain level core-service=management resource and its children unless RBAC is enabled // Configuring rbac details is OK (i.e. discarable), so long as the provider is not enabled - ChainedTransformationDescriptionBuilder chainedBuilder = createChainFromCurrent(CoreManagementResourceDefinition.PATH_ELEMENT); + ChainedTransformationDescriptionBuilder chainedBuilder = factory.createChainedTransformationDescriptionBuilder(CoreManagementResourceDefinition.PATH_ELEMENT); ResourceTransformationDescriptionBuilder builder18To17 = createBuilder(chainedBuilder, KernelAPIVersion.VERSION_1_8, KernelAPIVersion.VERSION_1_7); builder18To17.addChildResource(AccessAuthorizationResourceDefinition.PATH_ELEMENT) diff --git a/host-controller/src/main/java/org/jboss/as/domain/controller/transformers/ServerGroupTransformers.java b/host-controller/src/main/java/org/jboss/as/domain/controller/transformers/ServerGroupTransformers.java index aacaf7f7c69..7f9045ca19a 100644 --- a/host-controller/src/main/java/org/jboss/as/domain/controller/transformers/ServerGroupTransformers.java +++ b/host-controller/src/main/java/org/jboss/as/domain/controller/transformers/ServerGroupTransformers.java @@ -8,9 +8,9 @@ import static org.jboss.as.domain.controller.transformers.KernelAPIVersion.createBuilder; import static org.jboss.as.domain.controller.transformers.KernelAPIVersion.createBuilderFromCurrent; -import static org.jboss.as.domain.controller.transformers.KernelAPIVersion.createChainFromCurrent; import org.jboss.as.controller.transform.description.ChainedTransformationDescriptionBuilder; +import org.jboss.as.controller.transform.description.ChainedTransformationDescriptionBuilderFactory; import org.jboss.as.controller.transform.description.DiscardAttributeChecker; import org.jboss.as.controller.transform.description.RejectAttributeChecker; import org.jboss.as.controller.transform.description.ResourceTransformationDescriptionBuilder; @@ -24,8 +24,8 @@ */ class ServerGroupTransformers { - static ChainedTransformationDescriptionBuilder buildTransformerChain() { - ChainedTransformationDescriptionBuilder chainedBuilder = createChainFromCurrent(ServerGroupResourceDefinition.PATH); + static ChainedTransformationDescriptionBuilder buildTransformerChain(ChainedTransformationDescriptionBuilderFactory factory) { + ChainedTransformationDescriptionBuilder chainedBuilder = factory.createChainedTransformationDescriptionBuilder(ServerGroupResourceDefinition.PATH); ////////////////////////////////// //The EAP/AS 7.x chains diff --git a/host-controller/src/main/java/org/jboss/as/domain/controller/transformers/SocketBindingGroupTransformers.java b/host-controller/src/main/java/org/jboss/as/domain/controller/transformers/SocketBindingGroupTransformers.java index 4687650a309..863f9fa9cd1 100644 --- a/host-controller/src/main/java/org/jboss/as/domain/controller/transformers/SocketBindingGroupTransformers.java +++ b/host-controller/src/main/java/org/jboss/as/domain/controller/transformers/SocketBindingGroupTransformers.java @@ -6,10 +6,10 @@ package org.jboss.as.domain.controller.transformers; import static org.jboss.as.domain.controller.transformers.KernelAPIVersion.createBuilderFromCurrent; -import static org.jboss.as.domain.controller.transformers.KernelAPIVersion.createChainFromCurrent; import org.jboss.as.controller.resource.AbstractSocketBindingGroupResourceDefinition; import org.jboss.as.controller.transform.description.ChainedTransformationDescriptionBuilder; +import org.jboss.as.controller.transform.description.ChainedTransformationDescriptionBuilderFactory; import org.jboss.as.controller.transform.description.DiscardAttributeChecker; import org.jboss.as.controller.transform.description.RejectAttributeChecker; import org.jboss.as.controller.transform.description.ResourceTransformationDescriptionBuilder; @@ -23,9 +23,8 @@ */ class SocketBindingGroupTransformers { - static ChainedTransformationDescriptionBuilder buildTransformerChain() { - ChainedTransformationDescriptionBuilder chainedBuilder = - createChainFromCurrent(AbstractSocketBindingGroupResourceDefinition.PATH); + static ChainedTransformationDescriptionBuilder buildTransformerChain(ChainedTransformationDescriptionBuilderFactory factory) { + ChainedTransformationDescriptionBuilder chainedBuilder = factory.createChainedTransformationDescriptionBuilder(AbstractSocketBindingGroupResourceDefinition.PATH); ResourceTransformationDescriptionBuilder builder = createBuilderFromCurrent(chainedBuilder, KernelAPIVersion.VERSION_1_8);