-
Notifications
You must be signed in to change notification settings - Fork 465
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WFCORE-6995 Allow stability-specific resource transformations for mix…
…ed domains
- Loading branch information
Showing
17 changed files
with
323 additions
and
148 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,7 @@ | |
import java.util.Set; | ||
|
||
import org.jboss.as.controller.AttributeDefinition; | ||
import org.jboss.as.version.Stability; | ||
|
||
/** | ||
* @author <a href="[email protected]">Kabir Khan</a> | ||
|
@@ -29,74 +30,72 @@ abstract class AttributeTransformationDescriptionBuilderImpl<T extends BaseAttri | |
} | ||
|
||
@Override | ||
public ResourceTransformationDescriptionBuilder end() { | ||
return builder; | ||
public Stability getStability() { | ||
return this.builder.getStability(); | ||
} | ||
|
||
@Override | ||
public T setDiscard(DiscardAttributeChecker discardChecker, AttributeDefinition...discardedAttributes) { | ||
AttributeDefinition[] useDefs = discardedAttributes; | ||
for (AttributeDefinition attribute : useDefs) { | ||
String attrName = getAttributeName(attribute); | ||
registry.setDiscardedAttribute(discardChecker, attrName); | ||
} | ||
return thisBuilder(); | ||
public ResourceTransformationDescriptionBuilder end() { | ||
return builder; | ||
} | ||
|
||
@Override | ||
public T setDiscard(DiscardAttributeChecker discardChecker, Collection<AttributeDefinition> 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<RejectAttributeChecker> rejectCheckers, AttributeDefinition...rejectedAttributes) { | ||
for (RejectAttributeChecker rejectChecker : rejectCheckers) { | ||
addRejectCheck(rejectChecker, rejectedAttributes); | ||
this.addRejectCheck(rejectChecker, rejectedAttributes); | ||
} | ||
return thisBuilder(); | ||
} | ||
|
||
@Override | ||
public T addRejectChecks(List<RejectAttributeChecker> 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,19 +105,21 @@ public T addRename(String attributeName, String newName) { | |
return thisBuilder(); | ||
} | ||
|
||
@Override | ||
public T addRenames(Map<String, String> renames) { | ||
for (Map.Entry<String, String> rename : renames.entrySet()) { | ||
registry.addRenamedAttribute(rename.getKey(), rename.getValue()); | ||
this.addRename(rename.getKey(), rename.getValue()); | ||
} | ||
return thisBuilder(); | ||
} | ||
|
||
|
||
@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; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
...s/as/controller/transform/description/ChainedTransformationDescriptionBuilderFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* | ||
* 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.ModelVersion; | ||
|
||
/** | ||
* A factory for creating a chained transformation description builder. | ||
*/ | ||
public interface ChainedTransformationDescriptionBuilderFactory extends FeatureRegistry { | ||
|
||
/** | ||
* Creates a builder of chained transformation descriptions for this subsystem. | ||
* @return a builder of chained transformation descriptions for this subsystem. | ||
*/ | ||
default ChainedTransformationDescriptionBuilder createChainedTransformationDescriptionBuilder() { | ||
return new ChainedTransformationDescriptionBuilderImpl(this.getCurrentSubsystemVersion(), this.getStability(), null); | ||
} | ||
|
||
ModelVersion getCurrentSubsystemVersion(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,28 +13,32 @@ | |
import org.jboss.as.controller.ModelVersion; | ||
import org.jboss.as.controller.PathElement; | ||
import org.jboss.as.controller.transform.SubsystemTransformerRegistration; | ||
import org.jboss.as.version.Stability; | ||
|
||
/** | ||
* | ||
* @author <a href="[email protected]">Kabir Khan</a> | ||
*/ | ||
class ChainedTransformationDescriptionBuilderImpl implements ChainedTransformationDescriptionBuilder { | ||
private final Stability stability; | ||
private final ModelVersion currentVersion; | ||
private final Map<ModelVersionPair, TransformationDescriptionBuilder> 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<ModelVersion, TransformationDescription> build(ModelVersion...versions) { | ||
ModelVersion[] allVersions = new ModelVersion[versions.length + 1]; | ||
allVersions[0] = currentVersion; | ||
|
@@ -66,7 +70,7 @@ private Map<ModelVersion, TransformationDescription> 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)); | ||
|
Oops, something went wrong.