Class AbstractWriteAttributeHandler<T>

java.lang.Object
org.jboss.as.controller.AbstractWriteAttributeHandler<T>
Type Parameters:
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).
All Implemented Interfaces:
OperationStepHandler
Direct Known Subclasses:
ModelOnlyWriteAttributeHandler, ReloadRequiredWriteAttributeHandler, RestartParentWriteAttributeHandler

public abstract class AbstractWriteAttributeHandler<T> extends Object implements OperationStepHandler
Abstract handler for the write aspect of a read-write attribute.
Author:
Brian Stansberry (c) 2011 Red Hat Inc.
  • Constructor Details

    • AbstractWriteAttributeHandler

      protected AbstractWriteAttributeHandler()
    • AbstractWriteAttributeHandler

      @Deprecated(forRemoval=true) protected AbstractWriteAttributeHandler(AttributeDefinition... definitions)
      Deprecated, for removal: This API element is subject to removal in a future version.
    • AbstractWriteAttributeHandler

      @Deprecated(forRemoval=true) protected AbstractWriteAttributeHandler(Collection<AttributeDefinition> definitions)
      Deprecated, for removal: This API element is subject to removal in a future version.
  • Method Details

    • execute

      public void execute(OperationContext context, org.jboss.dmr.ModelNode operation) throws OperationFailedException
      Description copied from interface: OperationStepHandler
      Execute this step. If the operation fails, context.getFailureDescription() must be called, or an OperationFailedException must be thrown. If the operation succeeded and the operation provides a return value, context.getResult() should be called and the result populated with the outcome. If the handler wishes to take further action once the result of the overall operation execution is known, one of the context.completeStep variants should be called to register a callback. The callback will not be invoked if this method throws an exception.

      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.

      Specified by:
      execute in interface OperationStepHandler
      Parameters:
      context - the operation context
      operation - the operation being executed
      Throws:
      OperationFailedException - if the operation failed before calling context.completeStep()
    • applyUpdateToRuntime

      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
      Hook to allow subclasses to make runtime changes to effect the attribute value change.
      Parameters:
      context - the context of the operation
      operation - the operation
      attributeName - the name of the attribute being modified
      resolvedValue - the new value for the attribute, after any ValueExpression has been resolved
      currentValue - the existing value for the attribute
      handbackHolder - holder for an arbitrary object to pass to revertUpdateToRuntime(OperationContext, ModelNode, String, ModelNode, ModelNode, Object) if the operation needs to be rolled back
      Returns:
      true if the server requires reload to effect the attribute value change; false if not
      Throws:
      OperationFailedException
    • revertUpdateToRuntime

      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
      Parameters:
      context - the context of the operation
      operation - the operation
      attributeName - the name of the attribute being modified
      valueToRestore - the previous value for the attribute, before this operation was executed
      valueToRevert - the new value for the attribute that should be reverted
      handback - an object, if any, passed in to the handbackHolder by the applyUpdateToRuntime implementation
      Throws:
      OperationFailedException
    • recordCapabilitiesAndRequirements

      protected void recordCapabilitiesAndRequirements(OperationContext context, AttributeDefinition attributeDefinition, org.jboss.dmr.ModelNode newValue, org.jboss.dmr.ModelNode oldValue)
      Record any new requirements for other capabilities that now exist as a result of this operation, or remove any existing requirements that no longer exist.
      Parameters:
      context - the context. Will not be null
      attributeDefinition - the definition of the attribute being modified. Will not be null
      newValue - the new value of the attribute
      oldValue - the previous value of the attribute
    • finishModelStage

      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
      Hook to allow subclasses to do any final 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.

      Parameters:
      context - the operation context
      operation - the operation
      attributeName - the name of the attribute being modified
      newValue - the new value for the attribute
      oldValue - the previous value for the attribute
      model - the updated model resource
      Throws:
      OperationFailedException
    • validateUpdatedModel

      protected void validateUpdatedModel(OperationContext context, Resource model) throws OperationFailedException
      Hook to allow subclasses to validate the model following the application of the new attribute value. This default implementation does nothing.
      Parameters:
      context - the operation context
      model - the updated model resource
      Throws:
      OperationFailedException
    • requiresRuntime

      protected boolean requiresRuntime(OperationContext context)
      Gets whether a 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.
      Parameters:
      context - operation context
      Returns:
      true if a runtime stage handler should be added; false otherwise.
    • getAttributeDefinition

      @Deprecated(forRemoval=true) protected AttributeDefinition getAttributeDefinition(String attributeName)
      Deprecated, for removal: This API element is subject to removal in a future version.
      No longer used.
      Gets the AttributeDefinition provided to the constructor (if present) whose name matches the given attributeName.
      Parameters:
      attributeName - the attribute name
      Returns:
      the attribute definition of attributeName