public abstract class DiscardAttributesTransformer extends Object implements 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.
Modifier and Type | Class and Description |
---|---|
static class |
DiscardAttributesTransformer.AttributeValueDiscardApprover
A
DiscardApprover 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.
|
OperationTransformer.TransformedOperation
Modifier and Type | Field and Description |
---|---|
static DiscardAttributesTransformer.DiscardApprover |
LENIENT_DISCARD_APPROVER
A
DiscardApprover that always returns true ; 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. |
DEFAULT, DEFAULT_REJECTION_POLICY, DISCARD, SUCCESSFUL_RESULT
DEFAULT, DISCARD
Modifier | Constructor and Description |
---|---|
protected |
DiscardAttributesTransformer(AttributeDefinition... attributes)
Deprecated.
use a variant that takes a
DiscardAttributesTransformer.DiscardApprover |
protected |
DiscardAttributesTransformer(DiscardAttributesTransformer.DiscardApprover discardApprover,
AttributeDefinition... attributes)
Creates a new transformer.
|
|
DiscardAttributesTransformer(DiscardAttributesTransformer.DiscardApprover discardApprover,
Set<String> attributeNames)
Creates a new transformer.
|
protected |
DiscardAttributesTransformer(DiscardAttributesTransformer.DiscardApprover discardApprover,
String... attributeNames)
Creates a new transformer.
|
|
DiscardAttributesTransformer(Set<String> attributeNames)
Deprecated.
use a variant that takes a
DiscardAttributesTransformer.DiscardApprover |
protected |
DiscardAttributesTransformer(String... attributeNames)
Deprecated.
use a variant that takes a
DiscardAttributesTransformer.DiscardApprover |
Modifier and Type | Method and 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.
|
public static final DiscardAttributesTransformer.DiscardApprover LENIENT_DISCARD_APPROVER
DiscardApprover
that always returns true
; 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.@Deprecated protected DiscardAttributesTransformer(AttributeDefinition... attributes)
DiscardAttributesTransformer.DiscardApprover
attributes
- the attributes to discardprotected DiscardAttributesTransformer(DiscardAttributesTransformer.DiscardApprover discardApprover, AttributeDefinition... attributes)
discardApprover
- approves whether or not transformation should be done. Cannot be null
attributes
- the attributes to discard@Deprecated protected DiscardAttributesTransformer(String... attributeNames)
DiscardAttributesTransformer.DiscardApprover
attributeNames
- the attributes to discardprotected DiscardAttributesTransformer(DiscardAttributesTransformer.DiscardApprover discardApprover, String... attributeNames)
discardApprover
- approves whether or not transformation should be done. Cannot be null
attributeNames
- the attributes to discard@Deprecated public DiscardAttributesTransformer(Set<String> attributeNames)
DiscardAttributesTransformer.DiscardApprover
attributeNames
- the attributes to discardpublic DiscardAttributesTransformer(DiscardAttributesTransformer.DiscardApprover discardApprover, Set<String> attributeNames)
discardApprover
- approves whether or not transformation should be done. Cannot be null
attributeNames
- the attributes to discardpublic OperationTransformer getWriteAttributeTransformer()
public OperationTransformer getUndefineAttributeTransformer()
public OperationTransformer.TransformedOperation transformOperation(TransformationContext context, PathAddress address, org.jboss.dmr.ModelNode operation) throws OperationFailedException
OperationTransformer
transformOperation
in interface OperationTransformer
context
- the operation contextaddress
- the path addressoperation
- the operationOperationFailedException
public void transformResource(ResourceTransformationContext context, PathAddress address, Resource resource) throws OperationFailedException
ResourceTransformer
transformResource
in interface ResourceTransformer
context
- the resource transformation contextaddress
- the path addressresource
- the resource to transformOperationFailedException
Copyright © 2023 JBoss by Red Hat. All rights reserved.