public interface OperationContext extends ExpressionResolver
Modifier and Type | Interface and Description |
---|---|
static class |
OperationContext.AttachmentKey<T>
An attachment key instance.
|
static class |
OperationContext.ResultAction
The result action.
|
static interface |
OperationContext.ResultHandler
Handler for a callback to an
OperationStepHandler indicating that the result of the overall operation is
known and the handler can take any necessary actions to deal with that result. |
static interface |
OperationContext.RollbackHandler
Handler for a callback to an
OperationStepHandler indicating that the overall operation is being
rolled back and the handler should revert any change it has made. |
static class |
OperationContext.Stage
The stage at which a step should apply.
|
DEFAULT, EXPRESSION_PATTERN, REJECTING, TEST_RESOLVER
Modifier and Type | Method and Description |
---|---|
void |
acquireControllerLock()
Acquire the controlling
ModelController 's exclusive lock. |
void |
addResource(PathAddress address,
Resource toAdd)
Add a new resource, relative to the executed operation address.
|
void |
addStep(org.jboss.dmr.ModelNode response,
org.jboss.dmr.ModelNode operation,
OperationStepHandler step,
OperationContext.Stage stage)
Add an execution step to this operation process.
|
void |
addStep(org.jboss.dmr.ModelNode response,
org.jboss.dmr.ModelNode operation,
OperationStepHandler step,
OperationContext.Stage stage,
boolean addFirst)
Add an execution step to this operation process.
|
void |
addStep(org.jboss.dmr.ModelNode operation,
OperationStepHandler step,
OperationContext.Stage stage)
Add an execution step to this operation process, writing any output to the response object
associated with the current step.
|
void |
addStep(org.jboss.dmr.ModelNode operation,
OperationStepHandler step,
OperationContext.Stage stage,
boolean addFirst)
Add an execution step to this operation process, writing any output to the response object
associated with the current step.
|
void |
addStep(OperationStepHandler step,
OperationContext.Stage stage)
Add an execution step to this operation process.
|
void |
addStep(OperationStepHandler step,
OperationContext.Stage stage,
boolean addFirst)
Add an execution step to this operation process.
|
<T> T |
attach(OperationContext.AttachmentKey<T> key,
T value)
Attaches an arbitrary object to this context.
|
<T> T |
attachIfAbsent(OperationContext.AttachmentKey<T> key,
T value)
Attaches an arbitrary object to this context only if the object was not already attached.
|
AuthorizationResult |
authorize(org.jboss.dmr.ModelNode operation)
Check for authorization of the given operation.
|
AuthorizationResult |
authorize(org.jboss.dmr.ModelNode operation,
Set<Action.ActionEffect> effects)
Check for authorization of the given effects for the given operation.
|
AuthorizationResult |
authorize(org.jboss.dmr.ModelNode operation,
String attribute,
org.jboss.dmr.ModelNode currentValue)
Check for authorization to read or modify an attribute, checking all effects of the given operation
|
AuthorizationResult |
authorize(org.jboss.dmr.ModelNode operation,
String attribute,
org.jboss.dmr.ModelNode currentValue,
Set<Action.ActionEffect> effects)
Check for authorization to read or modify an attribute, limiting the check to the given effects of the operation
|
AuthorizationResult |
authorizeOperation(org.jboss.dmr.ModelNode operation)
Check for authorization to execute an operation.
|
ResourceAuthorization |
authorizeResource(boolean attributes,
boolean isDefaultResource)
Check for authorization for the resource associated with the currently executing operation step and,
optionally, its individual attributes
|
void |
completeStep(OperationContext.ResultHandler resultHandler)
Complete a step, while registering for
a notification when the overall
result of the operation is known. |
void |
completeStep(OperationContext.RollbackHandler rollbackHandler)
Complete a step, while registering for
a notification if the work done by the
caller needs to be rolled back}. |
Resource |
createResource(PathAddress address)
Create a new resource, relative to the executed operation address.
|
<T> T |
detach(OperationContext.AttachmentKey<T> key)
Detaches or removes the value from this context.
|
<T> T |
getAttachment(OperationContext.AttachmentKey<T> key)
Retrieves an object that has been attached to this context.
|
InputStream |
getAttachmentStream(int index)
Get a stream which is attached to the request.
|
int |
getAttachmentStreamCount()
Gets the number of streams attached to the request.
|
Environment |
getCallEnvironment()
Gets the caller environment for the current request.
|
Caller |
getCaller()
Obtain the
Caller for the current request. |
OperationContext.Stage |
getCurrentStage()
Get the current stage of execution.
|
org.jboss.dmr.ModelNode |
getFailureDescription()
Get the failure description response node, creating it if necessary.
|
Resource |
getOriginalRootResource()
Get a read-only reference of the entire management model BEFORE any changes were made by this context.
|
ProcessType |
getProcessType()
Get the type of process in which this operation is executing.
|
ImmutableManagementResourceRegistration |
getResourceRegistration()
Get a read only view of the managed resource registration.
|
ManagementResourceRegistration |
getResourceRegistrationForUpdate()
Get a mutable view of the managed resource registration.
|
org.jboss.dmr.ModelNode |
getResponseHeaders()
Get the response-headers response node, creating it if necessary.
|
org.jboss.dmr.ModelNode |
getResult()
Get the node into which the operation result should be written.
|
Resource |
getRootResource()
Deprecated.
|
ImmutableManagementResourceRegistration |
getRootResourceRegistration()
Get a read only view of the root managed resource registration.
|
RunningMode |
getRunningMode()
Gets the running mode of the process.
|
org.jboss.dmr.ModelNode |
getServerResults()
Get the node into which the details of server results in a multi-server managed domain operation should be written.
|
org.jboss.msc.service.ServiceRegistry |
getServiceRegistry(boolean modify)
Get the service registry.
|
org.jboss.msc.service.ServiceTarget |
getServiceTarget()
Get the service target.
|
boolean |
hasFailureDescription()
Returns whether
getFailureDescription() has been invoked. |
boolean |
hasResult()
Returns whether
getResult() has been invoked. |
boolean |
isBooting()
Determine whether the controller is currently performing boot tasks.
|
boolean |
isModelAffected()
Determine whether the model has thus far been affected by this operation.
|
boolean |
isNormalServer()
Convenience method to check if the
process type is a server type
and the running mode is RunningMode.NORMAL . |
boolean |
isResourceRegistryAffected()
Determine whether the
management resource registry has thus far been affected by this operation. |
boolean |
isResourceServiceRestartAllowed()
Gets whether
OperationContext.Stage.RUNTIME handlers can restart (or remove) runtime services in order to
make the operation take effect. |
boolean |
isRollbackOnly()
Determine whether the current operation is bound to be rolled back.
|
boolean |
isRollbackOnRuntimeFailure()
Gets whether any changes made by the operation should be rolled back if an error is introduced
by a
OperationContext.Stage.RUNTIME or OperationContext.Stage.VERIFY handler. |
boolean |
isRuntimeAffected()
Determine whether the runtime container has thus far been affected by this operation.
|
boolean |
markResourceRestarted(PathAddress resource,
Object owner)
Marks a resource to indicate that it's backing service(s) will be restarted.
|
org.jboss.dmr.ModelNode |
readModel(PathAddress address)
Deprecated.
|
org.jboss.dmr.ModelNode |
readModelForUpdate(PathAddress address)
Deprecated.
|
Resource |
readResource(PathAddress relativeAddress)
Get the resource for read only operations, relative to the executed operation address.
|
Resource |
readResource(PathAddress relativeAddress,
boolean recursive)
Get the resource for read only operations, relative to the executed operation address.
|
Resource |
readResourceForUpdate(PathAddress relativeAddress)
Get an addressable resource for update operations.
|
Resource |
readResourceFromRoot(PathAddress address)
Read an addressable resource from the root of the model.
|
Resource |
readResourceFromRoot(PathAddress address,
boolean recursive)
Read an addressable resource from the root of the model.
|
void |
reloadRequired()
Notify the context that the process requires a stop and re-start of its root service (but not a full process
restart) in order to ensure stable operation and/or to bring its running state in line with its persistent configuration.
|
Resource |
removeResource(PathAddress relativeAddress)
Remove a resource relative to the executed operation address.
|
void |
removeService(org.jboss.msc.service.ServiceController<?> controller)
Initiate a service removal.
|
org.jboss.msc.service.ServiceController<?> |
removeService(org.jboss.msc.service.ServiceName name)
Initiate a service removal.
|
void |
report(MessageSeverity severity,
String message)
Send a message to the client.
|
org.jboss.dmr.ModelNode |
resolveExpressions(org.jboss.dmr.ModelNode node)
Resolves any expressions in the passed in ModelNode.
|
void |
restartRequired()
Notify the context that the process must be terminated and replaced with a new process in order to ensure stable
operation and/or to bring the running state in line with the persistent configuration.
|
void |
revertReloadRequired()
Notify the context that a previous call to
reloadRequired() can be ignored (typically because the change
that led to the need for reload has been rolled back.) |
boolean |
revertResourceRestarted(PathAddress resource,
Object owner)
Removes the restarted marking on the specified resource, provided the passed owner is the one
originally used to obtain the mark.
|
void |
revertRestartRequired()
Notify the context that a previous call to
restartRequired() can be ignored (typically because the change
that led to the need for restart has been rolled back.) |
void |
runtimeUpdateSkipped()
Notify the context that an update to the runtime that would normally have been made could not be made due to
the current state of the process.
|
void |
setRollbackOnly()
Indicate that the operation should be rolled back, regardless of outcome.
|
void |
stepCompleted()
Called by an
OperationStepHandler to indicate it has completed its handling of a step and is
uninterested in the result of subsequent steps. |
void addStep(OperationStepHandler step, OperationContext.Stage stage) throws IllegalArgumentException
step
- the step to addstage
- the stage at which the operation appliesIllegalArgumentException
- if the step handler is not valid for this controller typevoid addStep(OperationStepHandler step, OperationContext.Stage stage, boolean addFirst) throws IllegalArgumentException
step
- the step to addstage
- the stage at which the operation appliesaddFirst
- add the handler before the othersIllegalArgumentException
- if the step handler is not valid for this controller typevoid addStep(org.jboss.dmr.ModelNode operation, OperationStepHandler step, OperationContext.Stage stage) throws IllegalArgumentException
operation
- the operation body to pass into the added stepstep
- the step to addstage
- the stage at which the operation appliesIllegalArgumentException
- if the step handler is not valid for this controller typevoid addStep(org.jboss.dmr.ModelNode operation, OperationStepHandler step, OperationContext.Stage stage, boolean addFirst) throws IllegalArgumentException
operation
- the operation body to pass into the added stepstep
- the step to addstage
- the stage at which the operation appliesaddFirst
- add the handler before the othersIllegalArgumentException
- if the step handler is not valid for this controller typevoid addStep(org.jboss.dmr.ModelNode response, org.jboss.dmr.ModelNode operation, OperationStepHandler step, OperationContext.Stage stage) throws IllegalArgumentException
response
- the response which the nested step should populateoperation
- the operation body to pass into the added stepstep
- the step to addstage
- the stage at which the operation appliesIllegalArgumentException
- if the step handler is not valid for this controller typevoid addStep(org.jboss.dmr.ModelNode response, org.jboss.dmr.ModelNode operation, OperationStepHandler step, OperationContext.Stage stage, boolean addFirst) throws IllegalArgumentException
response
- the response which the nested step should populateoperation
- the operation body to pass into the added stepstep
- the step to addstage
- the stage at which the operation appliesaddFirst
- add the handler before the othersIllegalArgumentException
- if the step handler is not valid for this controller typeInputStream getAttachmentStream(int index)
index
- the indexint getAttachmentStreamCount()
org.jboss.dmr.ModelNode getResult()
boolean hasResult()
getResult()
has been invoked.true
if getResult()
has been invokedorg.jboss.dmr.ModelNode getFailureDescription()
boolean hasFailureDescription()
getFailureDescription()
has been invoked.true
if getFailureDescription()
has been invokedorg.jboss.dmr.ModelNode getServerResults()
IllegalStateException
- if this process is not a ProcessType.HOST_CONTROLLER
org.jboss.dmr.ModelNode getResponseHeaders()
operation-requires-restart
or process-state
headers. Use
reloadRequired()
and restartRequired()
for that. (Some core operation step handlers used
for coordinating execution of operations across different processes in a managed domain may use this
method to manipulate the operation-requires-restart
or process-state
headers, but that is
an exception.)void completeStep(OperationContext.RollbackHandler rollbackHandler)
a notification
if the work done by the
caller needs to be rolled back}.rollbackHandler
- the handler for any rollback notification. Cannot be null
.void completeStep(OperationContext.ResultHandler resultHandler)
a notification
when the overall
result of the operation is known. Handlers that register for notifications will receive the notifications in
the reverse of the order in which their steps execute.resultHandler
- the handler for the result notification. Cannot be null
.void stepCompleted()
OperationStepHandler
to indicate it has completed its handling of a step and is
uninterested in the result of subsequent steps. This is a convenience method that is equivalent to a call to
completeStep(OperationContext.ResultHandler.NO_OP_RESULT_HANDLER)
.
A common user of this method would be a OperationContext.Stage.MODEL
handler. Typically such a handler would not need
to take any further action in the case of a successful result
for the overall operation.
If the operation result is a rollback
, the OperationContext
itself
will ensure any changes made to the model are discarded, again requiring no action on the part of the handler.
So a OperationContext.Stage.MODEL
handler typically can be uninterested in the result of the overall operation and can
use this method.
ProcessType getProcessType()
null
RunningMode getRunningMode()
null
boolean isBooting()
boolean isNormalServer()
process type
is a server type
and the running mode
is RunningMode.NORMAL
. The typical usage would
be for handlers that are only meant to execute on a normally running server, not on a host controller
or on a RunningMode.ADMIN_ONLY
server.true
if the process type
is a server type
and the running mode
is RunningMode.NORMAL
.boolean isRollbackOnly()
true
if the operation will be rolled backvoid setRollbackOnly()
boolean isRollbackOnRuntimeFailure()
OperationContext.Stage.RUNTIME
or OperationContext.Stage.VERIFY
handler.true
if the operation should rollback if there is a runtime stage failureboolean isResourceServiceRestartAllowed()
OperationContext.Stage.RUNTIME
handlers can restart (or remove) runtime services in order to
make the operation take effect. If false
and the operation cannot be effected without restarting
or removing services, the handler should invoke reloadRequired()
or restartRequired()
.true
if a service restart or removal is allowedvoid reloadRequired()
void restartRequired()
void revertReloadRequired()
reloadRequired()
can be ignored (typically because the change
that led to the need for reload has been rolled back.)void revertRestartRequired()
restartRequired()
can be ignored (typically because the change
that led to the need for restart has been rolled back.)void runtimeUpdateSkipped()
isBooting()
is true
must invoke this method if it is executed when isBooting()
is false
.ImmutableManagementResourceRegistration getResourceRegistration()
ManagementResourceRegistration getResourceRegistrationForUpdate()
ImmutableManagementResourceRegistration getRootResourceRegistration()
org.jboss.msc.service.ServiceRegistry getServiceRegistry(boolean modify) throws UnsupportedOperationException
ServiceController.setMode(REMOVE)
on a ServiceController
returned from this registry an IllegalStateException
will be thrown. To
remove a service call removeService(org.jboss.msc.service.ServiceName)
.modify
- true
if the operation may be modifying a service, false
otherwiseUnsupportedOperationException
- if the calling step is not a runtime operation steporg.jboss.msc.service.ServiceController<?> removeService(org.jboss.msc.service.ServiceName name) throws UnsupportedOperationException
name
- the service to removeUnsupportedOperationException
- if the calling step is not a runtime operation stepvoid removeService(org.jboss.msc.service.ServiceController<?> controller) throws UnsupportedOperationException
controller
- the service controller to removeUnsupportedOperationException
- if the calling step is not a runtime operation steporg.jboss.msc.service.ServiceTarget getServiceTarget() throws UnsupportedOperationException
UnsupportedOperationException
- if the calling step is not a runtime operation step@Deprecated org.jboss.dmr.ModelNode readModel(PathAddress address)
readResource(PathAddress)
address
- the (possibly empty) address to read@Deprecated org.jboss.dmr.ModelNode readModelForUpdate(PathAddress address)
readResourceForUpdate(PathAddress)
address
- the (possibly empty) address to readvoid acquireControllerLock()
ModelController
's exclusive lock. Holding this lock prevent other operations
from mutating the model, the management resource registry
or the runtime
service registry until the lock is released. The lock is automatically released when the
execute method
of the handler
that invoked this method returns.
This method should be little used. The model controller's exclusive lock is acquired automatically when any of the operations in this interface that imply mutating the model, management resource registry or service registry are invoked. The only use for this method are special situations where an exclusive lock is needed but none of those methods will be invoked.
Resource createResource(PathAddress address) throws UnsupportedOperationException
address
- the (possibly empty) address where the resource should be created. Address is relative to the
address of the operation being executedIllegalStateException
- if a resource already exists at the given addressUnsupportedOperationException
- if the calling operation is not a model operationvoid addResource(PathAddress address, Resource toAdd)
address
- the (possibly empty) address where the resource should be added. Address is relative to the
address of the operation being executedtoAdd
- the new resourceIllegalStateException
- if a resource already exists at the given addressUnsupportedOperationException
- if the calling operation is not a model operationResource readResource(PathAddress relativeAddress)
readResource(PathAddress, boolean)
instead.relativeAddress
- the (possibly empty) address where the resource should be added. The address is relative to the
address of the operation being executedResource readResource(PathAddress relativeAddress, boolean recursive)
relativeAddress
- the (possibly empty) address where the resource should be added. The address is relative to the
address of the operation being executedrecursive
- whether the model should be read recursively or notResource readResourceFromRoot(PathAddress address)
readResourceFromRoot(PathAddress, boolean)
instead.address
- the (possibly empty) addressResource readResourceFromRoot(PathAddress address, boolean recursive)
address
- the (possibly empty) addressrecursive
- whether the model should be read recursively or notResource readResourceForUpdate(PathAddress relativeAddress)
relativeAddress
- the (possibly empty) address where the resource should be added. The address is relative to the
address of the operation being executedResource removeResource(PathAddress relativeAddress) throws UnsupportedOperationException
relativeAddress
- the (possibly empty) address where the resource should be removed. The address is relative to the
address of the operation being executedUnsupportedOperationException
- if the calling operation is not a model operation@Deprecated Resource getRootResource()
readResourceFromRoot(PathAddress, boolean)
Resource getOriginalRootResource()
boolean isModelAffected()
true
if the model was affected, false
otherwiseboolean isResourceRegistryAffected()
management resource registry
has thus far been affected by this operation.true
if the management resource registry was affected, false
otherwiseboolean isRuntimeAffected()
true
if the container was affected, false
otherwiseOperationContext.Stage getCurrentStage()
void report(MessageSeverity severity, String message)
severity
- the message severitymessage
- the messageboolean markResourceRestarted(PathAddress resource, Object owner)
revertReloadRequired()
.
This is to ensure that only the "owner" will be successful in reverting the mark.resource
- the resource that will be restartedowner
- the instance representing ownership of the markboolean revertResourceRestarted(PathAddress resource, Object owner)
markResourceRestarted(PathAddress, Object)
resource
- the resource being revertedowner
- the owner of the mark for the resourceorg.jboss.dmr.ModelNode resolveExpressions(org.jboss.dmr.ModelNode node) throws OperationFailedException
resolveExpressions
in interface ExpressionResolver
node
- the ModelNode containing expressions.OperationFailedException
- if there is a value of type ModelType.EXPRESSION
in the node tree and
there is no system property or environment variable that matches the expression, or if a security
manager exists and its checkPermission
method doesn't allow
access to the relevant system property or environment variable<T> T getAttachment(OperationContext.AttachmentKey<T> key)
T
- the value type of the attachment.key
- the key to the attachment.null
.<T> T attach(OperationContext.AttachmentKey<T> key, T value)
T
- the value type of the attachment.key
- they attachment key used to ensure uniqueness and used for retrieval of the value.value
- the value to store.null
if there was no previous value.<T> T attachIfAbsent(OperationContext.AttachmentKey<T> key, T value)
T
- the value type of the attachment.key
- they attachment key used to ensure uniqueness and used for retrieval of the value.value
- the value to store.null
if there was no previous value.<T> T detach(OperationContext.AttachmentKey<T> key)
T
- the value type of the attachment.key
- the key to the attachment.null
.AuthorizationResult authorize(org.jboss.dmr.ModelNode operation)
operation
- the operation. Cannot be null
AuthorizationResult authorize(org.jboss.dmr.ModelNode operation, Set<Action.ActionEffect> effects)
operation
- the operation. Cannot be null
effects
- the relevant effects. If empty, all effects associated with the operation are tested.ResourceAuthorization authorizeResource(boolean attributes, boolean isDefaultResource)
attributes
- true
if the result should include attribute authorizationsisDefaultResource
- true
ifAuthorizationResult authorize(org.jboss.dmr.ModelNode operation, String attribute, org.jboss.dmr.ModelNode currentValue)
operation
- the operation that will read or modifyattribute
- the attribute namecurrentValue
- the current value of the attributeAuthorizationResult authorize(org.jboss.dmr.ModelNode operation, String attribute, org.jboss.dmr.ModelNode currentValue, Set<Action.ActionEffect> effects)
operation
- the operation that will read or modifyattribute
- the attribute namecurrentValue
- the current value of the attributeeffects
- the effects to check, or, if empty, all effectsAuthorizationResult authorizeOperation(org.jboss.dmr.ModelNode operation)
operation
- the operation. Cannot be null
Caller getCaller()
Caller
for the current request.Environment getCallEnvironment()
Copyright © 2015 JBoss by Red Hat. All rights reserved.