T
- the type of an object that, if stored by the
applyUpdateToRuntime(OperationContext, ModelNode, String, ModelNode, ModelNode, HandbackHolder)
implementation, will be passed to
revertUpdateToRuntime(OperationContext, ModelNode, String, ModelNode, ModelNode, Object)
.public abstract class AbstractWriteAttributeHandler<T> extends Object implements OperationStepHandler
read-write attribute
.Modifier and Type | Class and Description |
---|---|
static class |
AbstractWriteAttributeHandler.HandbackHolder<T>
Holder subclasses can use to pass an object between
applyUpdateToRuntime(OperationContext, ModelNode, String, ModelNode, ModelNode, HandbackHolder)
and revertUpdateToRuntime(OperationContext, ModelNode, String, ModelNode, ModelNode, Object) . |
Modifier | Constructor and Description |
---|---|
protected |
AbstractWriteAttributeHandler(AttributeDefinition... definitions) |
protected |
AbstractWriteAttributeHandler(Collection<AttributeDefinition> definitions) |
Modifier and Type | Method and Description |
---|---|
protected abstract boolean |
applyUpdateToRuntime(OperationContext context,
org.jboss.dmr.ModelNode operation,
String attributeName,
org.jboss.dmr.ModelNode resolvedValue,
org.jboss.dmr.ModelNode currentValue,
AbstractWriteAttributeHandler.HandbackHolder<T> handbackHolder)
Hook to allow subclasses to make runtime changes to effect the attribute value change.
|
void |
execute(OperationContext context,
org.jboss.dmr.ModelNode operation)
Execute this step.
|
protected void |
finishModelStage(OperationContext context,
org.jboss.dmr.ModelNode operation,
String attributeName,
org.jboss.dmr.ModelNode newValue,
org.jboss.dmr.ModelNode oldValue,
Resource model)
Hook to allow subclasses to do any final
OperationContext.Stage.MODEL processing following the
application of the new attribute value. |
protected AttributeDefinition |
getAttributeDefinition(String attributeName)
Gets the
AttributeDefinition provided to the constructor (if present) whose
name matches the given attributeName . |
protected boolean |
requiresRuntime(OperationContext context)
Gets whether a
OperationContext.Stage.RUNTIME handler should be added. |
protected abstract void |
revertUpdateToRuntime(OperationContext context,
org.jboss.dmr.ModelNode operation,
String attributeName,
org.jboss.dmr.ModelNode valueToRestore,
org.jboss.dmr.ModelNode valueToRevert,
T handback)
Hook to allow subclasses to revert runtime changes made in
applyUpdateToRuntime(OperationContext, ModelNode, String, ModelNode, ModelNode, HandbackHolder) . |
protected void |
validateResolvedValue(String attributeName,
org.jboss.dmr.ModelNode resolvedValue)
Deprecated.
the
AttributeDefinition provided to the constructor will validate |
protected void |
validateUnresolvedValue(String attributeName,
org.jboss.dmr.ModelNode unresolvedValue)
Deprecated.
the
AttributeDefinition provided to the constructor will validate |
protected void |
validateUpdatedModel(OperationContext context,
Resource model)
Hook to allow subclasses to validate the model following the application of the new attribute value.
|
protected AbstractWriteAttributeHandler(AttributeDefinition... definitions)
protected AbstractWriteAttributeHandler(Collection<AttributeDefinition> definitions)
public void execute(OperationContext context, org.jboss.dmr.ModelNode operation) throws OperationFailedException
OperationStepHandler
context.getFailureDescription()
must be called, before calling one of the
context.completeStep variants
,
or an OperationFailedException
must be thrown.
If the operation succeeded, context.getResult()
should
be called and the result populated with the outcome, after which one of the
context.completeStep variants
must be called.
When this method is invoked the thread context classloader
will
be set to be the defining class loader of the class that implements this interface.
execute
in interface OperationStepHandler
context
- the operation contextoperation
- the operation being executedOperationFailedException
- if the operation failed before calling context.completeStep()
protected abstract boolean applyUpdateToRuntime(OperationContext context, org.jboss.dmr.ModelNode operation, String attributeName, org.jboss.dmr.ModelNode resolvedValue, org.jboss.dmr.ModelNode currentValue, AbstractWriteAttributeHandler.HandbackHolder<T> handbackHolder) throws OperationFailedException
context
- the context of the operationoperation
- the operationattributeName
- the name of the attribute being modifiedresolvedValue
- the new value for the attribute, after ModelNode.resolve()
has been called on itcurrentValue
- the existing value for the attributehandbackHolder
- holder for an arbitrary object to pass to
revertUpdateToRuntime(OperationContext, ModelNode, String, ModelNode, ModelNode, Object)
if
the operation needs to be rolled backtrue
if the server requires reload to effect the attribute
value change; false
if notOperationFailedException
protected abstract void revertUpdateToRuntime(OperationContext context, org.jboss.dmr.ModelNode operation, String attributeName, org.jboss.dmr.ModelNode valueToRestore, org.jboss.dmr.ModelNode valueToRevert, T handback) throws OperationFailedException
applyUpdateToRuntime(OperationContext, ModelNode, String, ModelNode, ModelNode, HandbackHolder)
.context
- the context of the operationoperation
- the operationattributeName
- the name of the attribute being modifiedvalueToRestore
- the previous value for the attribute, before this operation was executedvalueToRevert
- the new value for the attribute that should be revertedhandback
- an object, if any, passed in to the handbackHolder
by the applyUpdateToRuntime
implementationOperationFailedException
@Deprecated protected void validateUnresolvedValue(String attributeName, org.jboss.dmr.ModelNode unresolvedValue) throws OperationFailedException
AttributeDefinition
provided to the constructor will validateattributeName
- the name of the attribute being updatedunresolvedValue
- the unresolved valueOperationFailedException
@Deprecated protected void validateResolvedValue(String attributeName, org.jboss.dmr.ModelNode resolvedValue) throws OperationFailedException
AttributeDefinition
provided to the constructor will validateattributeName
- the name of the attribute being updatedresolvedValue
- the resolved valueOperationFailedException
protected void finishModelStage(OperationContext context, org.jboss.dmr.ModelNode operation, String attributeName, org.jboss.dmr.ModelNode newValue, org.jboss.dmr.ModelNode oldValue, Resource model) throws OperationFailedException
OperationContext.Stage.MODEL
processing following the
application of the new attribute value. This default implementation calls
validateUpdatedModel(OperationContext, Resource)
.
NOTE: Implementations must not call
OperationContext.completeStep(OperationContext.ResultHandler)
or any of its variants. The method that
calls this one handles step completion.
context
- the operation contextoperation
- the operationattributeName
- the name of the attribute being modifiednewValue
- the new value for the attributeoldValue
- the previous value for the attributemodel
- the updated model resourceOperationFailedException
protected void validateUpdatedModel(OperationContext context, Resource model) throws OperationFailedException
context
- the operation contextmodel
- the updated model resourceOperationFailedException
protected boolean requiresRuntime(OperationContext context)
OperationContext.Stage.RUNTIME
handler should be added. This default implementation
returns true if the process is a normal server
and the process
is not booting
. The rationale for the latter check is if the process is
booting, the resource being modified will have been added as a previous step in the same context, and
the Stage.RUNTIME handling for that add will see a model the reflects the changes made by this handler and
will apply them to the runtime.context
- operation contexttrue
if a runtime stage handler should be added; false
otherwise.protected AttributeDefinition getAttributeDefinition(String attributeName)
AttributeDefinition
provided to the constructor (if present) whose
name
matches the given attributeName
.attributeName
- the attribute namenull
if no matching definition is foundCopyright © 2014 JBoss by Red Hat. All rights reserved.