Class RestartParentResourceHandlerBase

java.lang.Object
org.jboss.as.controller.RestartParentResourceHandlerBase
All Implemented Interfaces:
OperationStepHandler
Direct Known Subclasses:
RestartParentResourceAddHandler, RestartParentResourceRemoveHandler

public abstract class RestartParentResourceHandlerBase extends Object implements OperationStepHandler
Simple remove handler that, if allowed, restarts a parent resource when a child is removed. Otherwise the server is put into a forced reload.
Author:
Jason T. Greene
  • Constructor Details

    • RestartParentResourceHandlerBase

      protected RestartParentResourceHandlerBase(String parentKeyName)
  • 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()
    • requiresRuntime

      protected boolean requiresRuntime(OperationContext context)
      Gets whether this operation needs to update the runtime. The default implementation returns true if {@link OperationContext#getProcessType()#isHostController()} is false.
      Parameters:
      context - the operation context
      Returns:
      true if the operation should update the runtime; false if it only updates the configuration model
    • isResourceServiceRestartAllowed

      protected boolean isResourceServiceRestartAllowed(OperationContext context, org.jboss.msc.service.ServiceController<?> service)
      Gets whether a restart of the parent resource's services is allowed. This default implementation checks whether the context allows resource service restarts; subclasses could also check the state of the service.
      Parameters:
      context - the operation context
      service - the parent service
      Returns:
      true if a restart is allowed; false
    • removeServices

      protected void removeServices(OperationContext context, org.jboss.msc.service.ServiceName parentService, org.jboss.dmr.ModelNode parentModel) throws OperationFailedException
      Removes services. This default implementation simply instructs the context to remove the parentService. Subclasses could use the provided parentModel to identify and remove other services.
      Parameters:
      context - the operation context
      parentService - the name of the parent service
      parentModel - the model associated with the parent resource, including nodes for any child resources
      Throws:
      OperationFailedException - if there is a problem removing the services
    • updateModel

      protected abstract void updateModel(OperationContext context, org.jboss.dmr.ModelNode operation) throws OperationFailedException
      Performs the update to the persistent configuration model.
      Parameters:
      context - the operation context
      operation - the operation
      Throws:
      OperationFailedException - if there is a problem updating the model
    • rollbackRuntime

      protected void rollbackRuntime(OperationContext context, org.jboss.dmr.ModelNode operation, Resource resource)
      Rollback the update.
      Parameters:
      context - the operation context
      operation - the operation
      resource - the resource
    • recreateParentService

      protected void recreateParentService(OperationContext context, org.jboss.dmr.ModelNode parentModel) throws OperationFailedException
      Recreate the parent service(s) using the given model.
      Parameters:
      context - the operation context relative to the parent resource
      parentModel - the current configuration model for the parent resource and its children
      Throws:
      OperationFailedException - if there is a problem installing the services
    • recreateParentService

      @Deprecated(forRemoval=true) protected void recreateParentService(OperationContext context, PathAddress parentAddress, org.jboss.dmr.ModelNode parentModel) throws OperationFailedException
      Deprecated, for removal: This API element is subject to removal in a future version.
      Recreate the parent service(s) using the given model.
      Parameters:
      context - the operation context
      parentAddress - the address of the parent resource
      parentModel - the current configuration model for the parent resource and its children
      Throws:
      OperationFailedException - if there is a problem installing the services
    • getParentServiceName

      protected abstract org.jboss.msc.service.ServiceName getParentServiceName(PathAddress parentAddress)
      Gets the name of the parent service.
      Parameters:
      parentAddress - the address of the parent resource
      Returns:
      the service name
    • getParentAddress

      protected PathAddress getParentAddress(PathAddress address)