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 forOperationStepHandler
implementations that add managed resource.- Author:
- John Bailey
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
AbstractAddStepHandler.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 Resource
createResource(OperationContext context)
Create theResource
that theexecute(OperationContext, ModelNode)
method operates on.protected Resource
createResource(OperationContext context, org.jboss.dmr.ModelNode operation)
Create theResource
that theexecute(OperationContext, ModelNode)
method operates on.void
execute(OperationContext context, org.jboss.dmr.ModelNode operation)
Execute this step.Collection<? extends AttributeDefinition>
getAttributes()
protected void
performRuntime(OperationContext context, org.jboss.dmr.ModelNode operation, Resource resource)
Make any runtime changes necessary to effect the changes indicated by the givenoperation
.protected void
performRuntime(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 void
populateModel(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 void
populateModel(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 void
populateModel(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 void
recordCapabilitiesAndRequirements(OperationContext context, org.jboss.dmr.ModelNode operation, Resource resource)
Record any newcapabilities
that are available as a result of this operation, as well as any requirements for other capabilities that now exist.protected boolean
requiresRuntime(OperationContext context)
Gets whether aOperationContext.Stage.RUNTIME
step should be added to callperformRuntime(OperationContext, org.jboss.dmr.ModelNode, org.jboss.as.controller.registry.Resource)
}.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)
.
-
-
-
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:
getAttributes
in interfaceOperationDescriptor
-
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 anOperationFailedException
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 thecontext.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 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 theResource
that 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 theResource
that 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
- ifoperation
is invalid or populating the model otherwise fails
-
populateModel
protected void populateModel(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 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
- ifoperation
is invalid or populating the model otherwise fails
-
populateModel
protected void populateModel(org.jboss.dmr.ModelNode operation, org.jboss.dmr.ModelNode model) throws OperationFailedException
Populate 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
- ifoperation
is invalid or populating the model otherwise fails
-
recordCapabilitiesAndRequirements
protected void recordCapabilitiesAndRequirements(OperationContext context, org.jboss.dmr.ModelNode operation, Resource resource) throws OperationFailedException
Record any newcapabilities
that 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
AttributeDefinition
provided to the constructor toadd capability requirements
.- Parameters:
context
- the context. Will not benull
operation
- the operation that is executing Will not benull
resource
- 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.RUNTIME
step should be added to callperformRuntime(OperationContext, org.jboss.dmr.ModelNode, org.jboss.as.controller.registry.Resource)
}. This default implementation will returntrue
for a normal server running in normal (non admin-only) mode. If running on a host controller, it will returntrue
if 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:
true
ifperformRuntime
should be invoked;false
otherwise.
-
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 givenresource
parameter 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 theresource
parameter 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
- ifoperation
is 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 givenresource
parameter 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
- ifoperation
is 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.RUNTIME
will be automatically removed after this method executes. Called from theOperationContext.ResultHandler
orOperationContext.RollbackHandler
passed toOperationContext.completeStep(...)
.- Parameters:
context
- the operation contextoperation
- the operation being executedresource
- persistent configuration model node that corresponds to the address ofoperation
-
-