Class AbstractAddStepHandler
- java.lang.Object
-
- org.jboss.as.controller.AbstractAddStepHandler
-
- All Implemented Interfaces:
OperationDescriptor,OperationStepHandler
- Direct Known Subclasses:
AbstractBoottimeAddStepHandler,InterfaceAddHandler,ManagementInterfaceAddStepHandler,ModelOnlyAddStepHandler,ReloadRequiredAddStepHandler
public class AbstractAddStepHandler extends Object implements OperationStepHandler, OperationDescriptor
Base class forOperationStepHandlerimplementations that add managed resource.- Author:
- John Bailey
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classAbstractAddStepHandler.Parameters
-
Field Summary
Fields Modifier and Type Field Description protected Collection<? extends AttributeDefinition>attributes
-
Constructor Summary
Constructors Constructor Description AbstractAddStepHandler()Constructs an add handler.AbstractAddStepHandler(Collection<? extends AttributeDefinition> attributes)Constructs an add handlerAbstractAddStepHandler(AbstractAddStepHandler.Parameters parameters)AbstractAddStepHandler(AttributeDefinition... attributes)Constructs an add handler
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected ResourcecreateResource(OperationContext context)Create theResourcethat theexecute(OperationContext, ModelNode)method operates on.protected ResourcecreateResource(OperationContext context, org.jboss.dmr.ModelNode operation)Create theResourcethat theexecute(OperationContext, ModelNode)method operates on.voidexecute(OperationContext context, org.jboss.dmr.ModelNode operation)Execute this step.Collection<? extends AttributeDefinition>getAttributes()protected voidperformRuntime(OperationContext context, org.jboss.dmr.ModelNode operation, Resource resource)Make any runtime changes necessary to effect the changes indicated by the givenoperation.protected voidperformRuntime(OperationContext context, org.jboss.dmr.ModelNode operation, org.jboss.dmr.ModelNode model)Make any runtime changes necessary to effect the changes indicated by the givenoperation.protected voidpopulateModel(OperationContext context, org.jboss.dmr.ModelNode operation, Resource resource)Populate the given resource in the persistent configuration model based on the values in the given operation.protected voidpopulateModel(org.jboss.dmr.ModelNode operation, Resource resource)Populate the given resource in the persistent configuration model based on the values in the given operation.protected voidpopulateModel(org.jboss.dmr.ModelNode operation, org.jboss.dmr.ModelNode model)Populate the given node in the persistent configuration model based on the values in the given operation.protected voidrecordCapabilitiesAndRequirements(OperationContext context, org.jboss.dmr.ModelNode operation, Resource resource)Record any newcapabilitiesthat are available as a result of this operation, as well as any requirements for other capabilities that now exist.protected booleanrequiresRuntime(OperationContext context)Gets whether aOperationContext.Stage.RUNTIMEstep should be added to callperformRuntime(OperationContext, org.jboss.dmr.ModelNode, org.jboss.as.controller.registry.Resource)}.protected voidrollbackRuntime(OperationContext context, org.jboss.dmr.ModelNode operation, Resource resource)Rollback runtime changes made inperformRuntime(OperationContext, org.jboss.dmr.ModelNode, org.jboss.as.controller.registry.Resource).
-
-
-
Field Detail
-
attributes
protected final Collection<? extends AttributeDefinition> attributes
-
-
Constructor Detail
-
AbstractAddStepHandler
public AbstractAddStepHandler()
Constructs an add handler.
-
AbstractAddStepHandler
public AbstractAddStepHandler(Collection<? extends AttributeDefinition> attributes)
Constructs an add handler- Parameters:
attributes- attributes to use inpopulateModel(OperationContext, org.jboss.dmr.ModelNode, org.jboss.as.controller.registry.Resource)
-
AbstractAddStepHandler
public AbstractAddStepHandler(AttributeDefinition... attributes)
Constructs an add handler- Parameters:
attributes- attributes to use inpopulateModel(OperationContext, org.jboss.dmr.ModelNode, org.jboss.as.controller.registry.Resource)
-
AbstractAddStepHandler
public AbstractAddStepHandler(AbstractAddStepHandler.Parameters parameters)
-
-
Method Detail
-
getAttributes
public Collection<? extends AttributeDefinition> getAttributes()
- Specified by:
getAttributesin interfaceOperationDescriptor
-
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()
-
createResource
protected Resource createResource(OperationContext context, org.jboss.dmr.ModelNode operation)
Create theResourcethat theexecute(OperationContext, ModelNode)method operates on. This method is invoked duringOperationContext.Stage.MODEL.This default implementation uses the
default resource creation facility exposed by the context. Subclasses wishing to create a custom resource type can override this method.- Parameters:
context- the operation contextoperation- the operation
-
createResource
protected Resource createResource(OperationContext context)
Create theResourcethat theexecute(OperationContext, ModelNode)method operates on. This method is invoked duringOperationContext.Stage.MODEL.This default implementation uses the
default resource creation facility exposed by the context. Subclasses wishing to create a custom resource type can override this method.- Parameters:
context- the operation context
-
populateModel
protected void populateModel(OperationContext context, org.jboss.dmr.ModelNode operation, Resource resource) throws OperationFailedException
Populate the given resource in the persistent configuration model based on the values in the given operation. This method isinvoked duringOperationContext.Stage.MODEL.This default implementation simply calls
populateModel(ModelNode, org.jboss.as.controller.registry.Resource).- Parameters:
context- the operation contextoperation- the operationresource- the resource that corresponds to the address ofoperation- Throws:
OperationFailedException- ifoperationis invalid or populating the model otherwise fails
-
populateModel
protected void populateModel(org.jboss.dmr.ModelNode operation, Resource resource) throws OperationFailedExceptionPopulate the given resource in the persistent configuration model based on the values in the given operation. This method is invoked duringOperationContext.Stage.MODEL.This default implementation simply calls
populateModel(ModelNode, org.jboss.dmr.ModelNode).- Parameters:
operation- the operationresource- the resource that corresponds to the address ofoperation- Throws:
OperationFailedException- ifoperationis invalid or populating the model otherwise fails
-
populateModel
protected void populateModel(org.jboss.dmr.ModelNode operation, org.jboss.dmr.ModelNode model) throws OperationFailedExceptionPopulate the given node in the persistent configuration model based on the values in the given operation. This method is invoked duringOperationContext.Stage.MODEL.This default implementation invokes
AttributeDefinition.validateAndSet(org.jboss.dmr.ModelNode, org.jboss.dmr.ModelNode)on any attributes passed to the constructor.- Parameters:
operation- the operationmodel- persistent configuration model node that corresponds to the address ofoperation- Throws:
OperationFailedException- ifoperationis invalid or populating the model otherwise fails
-
recordCapabilitiesAndRequirements
protected void recordCapabilitiesAndRequirements(OperationContext context, org.jboss.dmr.ModelNode operation, Resource resource) throws OperationFailedException
Record any newcapabilitiesthat are available as a result of this operation, as well as any requirements for other capabilities that now exist. This method is invoked duringOperationContext.Stage.MODEL.Any changes made by this method will automatically be discarded if the operation rolls back.
This default implementation registers any capabilities provided to the constructor and asks any
AttributeDefinitionprovided to the constructor toadd capability requirements.- Parameters:
context- the context. Will not benulloperation- the operation that is executing Will not benullresource- the resource that has been added. Will reflect any updates made bypopulateModel(OperationContext, org.jboss.dmr.ModelNode, org.jboss.as.controller.registry.Resource). Will not benull- Throws:
OperationFailedException
-
requiresRuntime
protected boolean requiresRuntime(OperationContext context)
Gets whether aOperationContext.Stage.RUNTIMEstep should be added to callperformRuntime(OperationContext, org.jboss.dmr.ModelNode, org.jboss.as.controller.registry.Resource)}. This default implementation will returntruefor a normal server running in normal (non admin-only) mode. If running on a host controller, it will returntrueif it is the active copy of the host controller subsystem. Subclasses that perform no runtime update could override and returnfalse. This method is invoked duringOperationContext.Stage.MODEL.- Parameters:
context- operation context- Returns:
trueifperformRuntimeshould be invoked;falseotherwise.
-
performRuntime
protected void performRuntime(OperationContext context, org.jboss.dmr.ModelNode operation, Resource resource) throws OperationFailedException
Make any runtime changes necessary to effect the changes indicated by the givenoperation. Executes afterpopulateModel(org.jboss.dmr.ModelNode, org.jboss.dmr.ModelNode), so the givenresourceparameter will reflect any changes made in that method. This method is invoked duringOperationContext.Stage.RUNTIME. Subclasses that wish to make changes to runtime services should override either this method or theperformRuntime(OperationContext, org.jboss.dmr.ModelNode, org.jboss.dmr.ModelNode)variant. Override this one if you wish to make use of theresourceparameter beyond simplyaccessing its model property.This default implementation simply calls the
performRuntime(OperationContext, org.jboss.dmr.ModelNode, org.jboss.dmr.ModelNode)variant. Subclasses that override this method should not callsuper.performRuntime(...).- Parameters:
context- the operation contextoperation- the operation being executedresource- persistent configuration resource that corresponds to the address ofoperation- Throws:
OperationFailedException- ifoperationis invalid or updating the runtime otherwise fails
-
performRuntime
protected void performRuntime(OperationContext context, org.jboss.dmr.ModelNode operation, org.jboss.dmr.ModelNode model) throws OperationFailedException
Make any runtime changes necessary to effect the changes indicated by the givenoperation. Executes afterpopulateModel(org.jboss.dmr.ModelNode, org.jboss.dmr.ModelNode), so the givenresourceparameter will reflect any changes made in that method. This method is invoked duringOperationContext.Stage.RUNTIME. Subclasses that wish to make changes to runtime services should override this method or theperformRuntime(OperationContext, org.jboss.dmr.ModelNode, org.jboss.as.controller.registry.Resource)variant.- Parameters:
context- the operation contextoperation- the operation being executedmodel- persistent configuration model from the resource that corresponds to the address ofoperation- Throws:
OperationFailedException- ifoperationis invalid or updating the runtime otherwise fails
-
rollbackRuntime
protected void rollbackRuntime(OperationContext context, org.jboss.dmr.ModelNode operation, Resource resource)
Rollback runtime changes made inperformRuntime(OperationContext, org.jboss.dmr.ModelNode, org.jboss.as.controller.registry.Resource). Any services that were added inOperationContext.Stage.RUNTIMEwill be automatically removed after this method executes. Called from theOperationContext.ResultHandlerorOperationContext.RollbackHandlerpassed toOperationContext.completeStep(...).- Parameters:
context- the operation contextoperation- the operation being executedresource- persistent configuration model node that corresponds to the address ofoperation
-
-