Class DiscardAttributesTransformer
- java.lang.Object
-
- org.jboss.as.controller.transform.DiscardAttributesTransformer
-
- All Implemented Interfaces:
OperationTransformer,ResourceTransformer
public abstract class DiscardAttributesTransformer extends Object implements OperationTransformer, ResourceTransformer
Discards attributes silently. This class should ONLY be used if you are 100% sure a new attribute can be discarded, even if set. Provide aDiscardAttributesTransformer.DiscardApproverto the constructor to provide specific logic for making the determination as to whether the transformation should be done. It is made abstract to make you think about using it.Normally, you would want to use
DiscardUndefinedAttributesTransformerinstead.A typical use case for this transformer would be in combination with
DiscardUndefinedAttributesTransformer. First this transformer would run, with aDiscardAttributesTransformer.DiscardApproverchecking the state of the model or operation to decide whether removing attributes is valid. The discard approver would only approve the removal if the value of the model or operation parameters is such that the servers launched by a slave Host Controller running the legacy version and unaware of the removed attributes would function consistently with newer version servers who saw the attributes. This transformer would remove the attributes in that case, and leave them otherwise. Then theDiscardUndefinedAttributesTransformerwould run and would log a warning or fail operations if any of the attributes were left. So this transformer cleans if possible, andDiscardUndefinedAttributesTransformerdeals with any problems left after cleaning.- Author:
- Kabir Khan
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classDiscardAttributesTransformer.AttributeValueDiscardApproverADiscardApproverthat checks the value of a provided attribute in order to decide whether transformation is allowed.static interfaceDiscardAttributesTransformer.DiscardApproverApproves the transformation of the resource or operation.-
Nested classes/interfaces inherited from interface org.jboss.as.controller.transform.OperationTransformer
OperationTransformer.TransformedOperation
-
-
Field Summary
Fields Modifier and Type Field Description static DiscardAttributesTransformer.DiscardApproverLENIENT_DISCARD_APPROVERADiscardApproverthat always returnstrue; use with extreme caution. It would be a very unusual situation for it to be appropriate to always transform a resource or operation regardless of the values in the model or operation.-
Fields inherited from interface org.jboss.as.controller.transform.OperationTransformer
DEFAULT, DEFAULT_REJECTION_POLICY, DISCARD, SUCCESSFUL_RESULT
-
Fields inherited from interface org.jboss.as.controller.transform.ResourceTransformer
DEFAULT, DISCARD
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedDiscardAttributesTransformer(String... attributeNames)Deprecated.use a variant that takes aDiscardAttributesTransformer.DiscardApproverDiscardAttributesTransformer(Set<String> attributeNames)Deprecated.use a variant that takes aDiscardAttributesTransformer.DiscardApproverprotectedDiscardAttributesTransformer(AttributeDefinition... attributes)Deprecated.use a variant that takes aDiscardAttributesTransformer.DiscardApproverprotectedDiscardAttributesTransformer(DiscardAttributesTransformer.DiscardApprover discardApprover, String... attributeNames)Creates a new transformer.DiscardAttributesTransformer(DiscardAttributesTransformer.DiscardApprover discardApprover, Set<String> attributeNames)Creates a new transformer.protectedDiscardAttributesTransformer(DiscardAttributesTransformer.DiscardApprover discardApprover, AttributeDefinition... attributes)Creates a new transformer.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description OperationTransformergetUndefineAttributeTransformer()OperationTransformergetWriteAttributeTransformer()OperationTransformer.TransformedOperationtransformOperation(TransformationContext context, PathAddress address, org.jboss.dmr.ModelNode operation)Transform the operation.voidtransformResource(ResourceTransformationContext context, PathAddress address, Resource resource)Transform a resource.
-
-
-
Field Detail
-
LENIENT_DISCARD_APPROVER
public static final DiscardAttributesTransformer.DiscardApprover LENIENT_DISCARD_APPROVER
ADiscardApproverthat always returnstrue; use with extreme caution. It would be a very unusual situation for it to be appropriate to always transform a resource or operation regardless of the values in the model or operation.
-
-
Constructor Detail
-
DiscardAttributesTransformer
@Deprecated protected DiscardAttributesTransformer(AttributeDefinition... attributes)
Deprecated.use a variant that takes aDiscardAttributesTransformer.DiscardApproverCreates a new transformer.- Parameters:
attributes- the attributes to discard
-
DiscardAttributesTransformer
protected DiscardAttributesTransformer(DiscardAttributesTransformer.DiscardApprover discardApprover, AttributeDefinition... attributes)
Creates a new transformer.- Parameters:
discardApprover- approves whether or not transformation should be done. Cannot benullattributes- the attributes to discard
-
DiscardAttributesTransformer
@Deprecated protected DiscardAttributesTransformer(String... attributeNames)
Deprecated.use a variant that takes aDiscardAttributesTransformer.DiscardApproverCreates a new transformer.- Parameters:
attributeNames- the attributes to discard
-
DiscardAttributesTransformer
protected DiscardAttributesTransformer(DiscardAttributesTransformer.DiscardApprover discardApprover, String... attributeNames)
Creates a new transformer.- Parameters:
discardApprover- approves whether or not transformation should be done. Cannot benullattributeNames- the attributes to discard
-
DiscardAttributesTransformer
@Deprecated public DiscardAttributesTransformer(Set<String> attributeNames)
Deprecated.use a variant that takes aDiscardAttributesTransformer.DiscardApproverCreates a new transformer.- Parameters:
attributeNames- the attributes to discard
-
DiscardAttributesTransformer
public DiscardAttributesTransformer(DiscardAttributesTransformer.DiscardApprover discardApprover, Set<String> attributeNames)
Creates a new transformer.- Parameters:
discardApprover- approves whether or not transformation should be done. Cannot benullattributeNames- the attributes to discard
-
-
Method Detail
-
getWriteAttributeTransformer
public OperationTransformer getWriteAttributeTransformer()
-
getUndefineAttributeTransformer
public OperationTransformer getUndefineAttributeTransformer()
-
transformOperation
public OperationTransformer.TransformedOperation transformOperation(TransformationContext context, PathAddress address, org.jboss.dmr.ModelNode operation) throws OperationFailedException
Description copied from interface:OperationTransformerTransform the operation.- Specified by:
transformOperationin interfaceOperationTransformer- Parameters:
context- the operation contextaddress- the path addressoperation- the operation- Returns:
- the transformed operation
- Throws:
OperationFailedException
-
transformResource
public void transformResource(ResourceTransformationContext context, PathAddress address, Resource resource) throws OperationFailedException
Description copied from interface:ResourceTransformerTransform a resource.- Specified by:
transformResourcein interfaceResourceTransformer- Parameters:
context- the resource transformation contextaddress- the path addressresource- the resource to transform- Throws:
OperationFailedException
-
-