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(Set<RuntimeCapability> capabilities, Collection<? extends AttributeDefinition> attributes)
AbstractAddStepHandler(Set<RuntimeCapability> capabilities, AttributeDefinition... attributes)
AbstractAddStepHandler(AbstractAddStepHandler.Parameters parameters)
AbstractAddStepHandler(AttributeDefinition... attributes)
Constructs an add handlerAbstractAddStepHandler(RuntimeCapability capability, Collection<? extends AttributeDefinition> attributes)
AbstractAddStepHandler(RuntimeCapability capability, AttributeDefinition... attributes)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated 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)
{@inheritDocCollection<? 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)
.protected void
rollbackRuntime(OperationContext context, org.jboss.dmr.ModelNode operation, org.jboss.dmr.ModelNode model, List<org.jboss.msc.service.ServiceController<?>> controllers)
Deprecated.
-
-
-
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)
.attributes to use inpopulateModel(OperationContext, org.jboss.dmr.ModelNode, org.jboss.as.controller.registry.Resource)
-
AbstractAddStepHandler
@Deprecated public AbstractAddStepHandler(RuntimeCapability capability, Collection<? extends AttributeDefinition> attributes)
Deprecated.Constructs an add handler- Parameters:
capability
- capability to register inrecordCapabilitiesAndRequirements(OperationContext, org.jboss.dmr.ModelNode, org.jboss.as.controller.registry.Resource)
null
is allowedattributes
- attributes to use inpopulateModel(OperationContext, org.jboss.dmr.ModelNode, org.jboss.as.controller.registry.Resource)
.attributes to use inpopulateModel(OperationContext, org.jboss.dmr.ModelNode, org.jboss.as.controller.registry.Resource)
-
AbstractAddStepHandler
@Deprecated public AbstractAddStepHandler(Set<RuntimeCapability> capabilities, Collection<? extends AttributeDefinition> attributes)
Deprecated.Constructs an add handler.- Parameters:
capabilities
- capabilities to register inrecordCapabilitiesAndRequirements(OperationContext, org.jboss.dmr.ModelNode, org.jboss.as.controller.registry.Resource)
null
is allowedattributes
- attributes to use inpopulateModel(OperationContext, org.jboss.dmr.ModelNode, org.jboss.as.controller.registry.Resource)
-
AbstractAddStepHandler
@Deprecated public AbstractAddStepHandler(RuntimeCapability capability, AttributeDefinition... attributes)
Deprecated.Constructs an add handler- Parameters:
capability
- capability to register inrecordCapabilitiesAndRequirements(OperationContext, org.jboss.dmr.ModelNode, org.jboss.as.controller.registry.Resource)
null
is allowedattributes
- 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
@Deprecated public AbstractAddStepHandler(Set<RuntimeCapability> capabilities, AttributeDefinition... attributes)
Deprecated.Constructs an add handler- Parameters:
capabilities
- capabilities to register inrecordCapabilitiesAndRequirements(OperationContext, org.jboss.dmr.ModelNode, org.jboss.as.controller.registry.Resource)
null
is allowedattributes
- 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
{@inheritDoc- 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(...)
.To provide compatible behavior with previous releases, this default implementation calls the deprecated
rollbackRuntime(OperationContext, org.jboss.dmr.ModelNode, org.jboss.dmr.ModelNode, java.util.List)
variant, passing in an empty list for thecontrollers
parameter. Subclasses that overrode that method are encouraged to instead override this one. Subclasses that override this method should not callsuper.rollbackRuntime(...).
- Parameters:
context
- the operation contextoperation
- the operation being executedresource
- persistent configuration model node that corresponds to the address ofoperation
-
rollbackRuntime
@Deprecated protected void rollbackRuntime(OperationContext context, org.jboss.dmr.ModelNode operation, org.jboss.dmr.ModelNode model, List<org.jboss.msc.service.ServiceController<?>> controllers)
Deprecated.Deprecated. Subclasses wishing for custom rollback behavior should instead overriderollbackRuntime(OperationContext, org.jboss.dmr.ModelNode, org.jboss.as.controller.registry.Resource)
.This default implementation does nothing. Subclasses that override this method should not call
super.performRuntime(...)
.- Parameters:
context
- the operation contextoperation
- the operation being executedmodel
- persistent configuration model node that corresponds to the address ofoperation
controllers
- will always be an empty list
-
-