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.DiscardApprover
to 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
DiscardUndefinedAttributesTransformer
instead.A typical use case for this transformer would be in combination with
DiscardUndefinedAttributesTransformer
. First this transformer would run, with aDiscardAttributesTransformer.DiscardApprover
checking 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 theDiscardUndefinedAttributesTransformer
would run and would log a warning or fail operations if any of the attributes were left. So this transformer cleans if possible, andDiscardUndefinedAttributesTransformer
deals with any problems left after cleaning.- Author:
- Kabir Khan
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
DiscardAttributesTransformer.AttributeValueDiscardApprover
ADiscardApprover
that checks the value of a provided attribute in order to decide whether transformation is allowed.static interface
DiscardAttributesTransformer.DiscardApprover
Approves 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.DiscardApprover
LENIENT_DISCARD_APPROVER
ADiscardApprover
that 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 protected
DiscardAttributesTransformer(DiscardAttributesTransformer.DiscardApprover discardApprover, String... attributeNames)
Creates a new transformer.DiscardAttributesTransformer(DiscardAttributesTransformer.DiscardApprover discardApprover, Set<String> attributeNames)
Creates a new transformer.protected
DiscardAttributesTransformer(DiscardAttributesTransformer.DiscardApprover discardApprover, AttributeDefinition... attributes)
Creates a new transformer.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description OperationTransformer
getUndefineAttributeTransformer()
OperationTransformer
getWriteAttributeTransformer()
OperationTransformer.TransformedOperation
transformOperation(TransformationContext context, PathAddress address, org.jboss.dmr.ModelNode operation)
Transform the operation.void
transformResource(ResourceTransformationContext context, PathAddress address, Resource resource)
Transform a resource.
-
-
-
Field Detail
-
LENIENT_DISCARD_APPROVER
public static final DiscardAttributesTransformer.DiscardApprover LENIENT_DISCARD_APPROVER
ADiscardApprover
that 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
protected DiscardAttributesTransformer(DiscardAttributesTransformer.DiscardApprover discardApprover, AttributeDefinition... attributes)
Creates a new transformer.- Parameters:
discardApprover
- approves whether or not transformation should be done. Cannot benull
attributes
- 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 benull
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 benull
attributeNames
- 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:OperationTransformer
Transform the operation.- Specified by:
transformOperation
in 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:ResourceTransformer
Transform a resource.- Specified by:
transformResource
in interfaceResourceTransformer
- Parameters:
context
- the resource transformation contextaddress
- the path addressresource
- the resource to transform- Throws:
OperationFailedException
-
-