-
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
24 changed files
with
513 additions
and
211 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 <a href="mailto:[email protected]">Tomaz Cerar</a> | ||
* @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 { | ||
|
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
Oops, something went wrong.