Package org.jboss.as.controller
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 Summary
Constructors Modifier Constructor Description protectedRestartParentResourceHandlerBase(String parentKeyName)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidexecute(OperationContext context, org.jboss.dmr.ModelNode operation)Execute this step.protected PathAddressgetParentAddress(PathAddress address)protected abstract org.jboss.msc.service.ServiceNamegetParentServiceName(PathAddress parentAddress)Gets the name of the parent service.protected booleanisResourceServiceRestartAllowed(OperationContext context, org.jboss.msc.service.ServiceController<?> service)Gets whether a restart of the parent resource's services is allowed.protected voidrecreateParentService(OperationContext context, PathAddress parentAddress, org.jboss.dmr.ModelNode parentModel)Recreate the parent service(s) using the given model.protected voidremoveServices(OperationContext context, org.jboss.msc.service.ServiceName parentService, org.jboss.dmr.ModelNode parentModel)Removes services.protected booleanrequiresRuntime(OperationContext context)Gets whether this operation needs to update the runtime.protected voidrollbackRuntime(OperationContext context, org.jboss.dmr.ModelNode operation, Resource resource)Rollback the update.protected abstract voidupdateModel(OperationContext context, org.jboss.dmr.ModelNode operation)Performs the update to the persistent configuration model.
-
-
-
Constructor Detail
-
RestartParentResourceHandlerBase
protected RestartParentResourceHandlerBase(String parentKeyName)
-
-
Method Detail
-
execute
public void execute(OperationContext context, org.jboss.dmr.ModelNode operation) throws OperationFailedException
Description copied from interface:OperationStepHandlerExecute this step. If the operation fails,context.getFailureDescription()must be called, or anOperationFailedExceptionmust 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 thecontext.completeStep variantsshould 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 classloaderwill be set to be the defining class loader of the class that implements this interface.- Specified by:
executein interfaceOperationStepHandler- Parameters:
context- the operation contextoperation- the operation being executed- Throws:
OperationFailedException- if the operation failed before callingcontext.completeStep()
-
requiresRuntime
protected boolean requiresRuntime(OperationContext context)
Gets whether this operation needs to update the runtime. The default implementation returnstrueif {@link OperationContext#getProcessType()#isHostController()} is false.- Parameters:
context- the operation context- Returns:
trueif the operation should update the runtime;falseif 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 whetherthe context allows resource service restarts; subclasses could also check the state of theservice.- Parameters:
context- the operation contextservice- the parent service- Returns:
trueif 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 simplyinstructs the context to remove the parentService. Subclasses could use the providedparentModelto identify and remove other services.- Parameters:
context- the operation contextparentService- the name of the parent serviceparentModel- 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 contextoperation- 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 contextoperation- the operationresource- the resource
-
recreateParentService
protected void recreateParentService(OperationContext context, PathAddress parentAddress, org.jboss.dmr.ModelNode parentModel) throws OperationFailedException
Recreate the parent service(s) using the given model.- Parameters:
context- the operation contextparentAddress- the address of the parent resourceparentModel- 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)
-
-