Class DiscardAttributesTransformer
- All Implemented Interfaces:
OperationTransformer,ResourceTransformer
DiscardAttributesTransformer.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 a DiscardAttributesTransformer.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 the
DiscardUndefinedAttributesTransformer would run and would log a warning or fail operations if any of
the attributes were left. So this transformer cleans if possible, and DiscardUndefinedAttributesTransformer
deals with any problems left after cleaning.
- Author:
- Kabir Khan
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classADiscardApproverthat checks the value of a provided attribute in order to decide whether transformation is allowed.static interfaceApproves the transformation of the resource or operation.Nested classes/interfaces inherited from interface org.jboss.as.controller.transform.OperationTransformer
OperationTransformer.TransformedOperation -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final DiscardAttributesTransformer.DiscardApproverADiscardApproverthat 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_RESULTFields inherited from interface org.jboss.as.controller.transform.ResourceTransformer
DEFAULT, DISCARD -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedDiscardAttributesTransformer(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
Modifier and TypeMethodDescriptiontransformOperation(TransformationContext context, PathAddress address, org.jboss.dmr.ModelNode operation) Transform the operation.voidtransformResource(ResourceTransformationContext context, PathAddress address, Resource resource) Transform a resource.
-
Field Details
-
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 Details
-
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
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
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 Details
-
getWriteAttributeTransformer
-
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
-