public abstract class AbstractResourcePathCommand<REQ extends org.hawkular.cmdgw.api.ResourcePathRequest,RESP extends org.hawkular.cmdgw.api.ResourcePathResponse> extends Object implements Command<REQ,RESP>
Commands initiated by subclasses of ResourcePathRequest.| Modifier and Type | Field and Description |
|---|---|
protected String |
entityType
A natural language name of entity the present command is creating, removing or updating.
|
protected String |
operationName
A natural language name of the operation the present command is performing, such as
Updade, Add
or Remove. |
| Constructor and Description |
|---|
AbstractResourcePathCommand(String operationName,
String entityType) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
assertLocalOrRemoteServer(ManagedServer managedServer) |
protected void |
assertLocalServer(ManagedServer managedServer) |
protected void |
assertNotRename(org.jboss.dmr.ModelNode adr,
String newName) |
protected org.jboss.as.controller.client.ModelControllerClient |
createControllerClient(ManagedServer managedServer,
CommandContext context)
Returns a freshly opened
ModelControllerClient. |
protected abstract RESP |
createResponse() |
org.hawkular.bus.common.BasicMessageWithExtraData<RESP> |
execute(org.hawkular.bus.common.BasicMessageWithExtraData<REQ> envelope,
CommandContext context)
Performs the command for the server.
|
protected abstract void |
execute(org.jboss.as.controller.client.ModelControllerClient controllerClient,
ManagedServer managedServer,
String modelNodePath,
org.hawkular.bus.common.BasicMessageWithExtraData<REQ> envelope,
RESP response,
CommandContext context)
Do whatever with the already validated parameters.
|
protected String |
getOperationName(org.hawkular.bus.common.BasicMessageWithExtraData<REQ> envelope) |
protected void |
success(org.hawkular.bus.common.BasicMessageWithExtraData<REQ> envelope,
RESP response) |
protected void |
validate(org.hawkular.bus.common.BasicMessageWithExtraData<REQ> envelope)
Checks if the
request has resourcePath field set. |
protected void |
validate(org.hawkular.bus.common.BasicMessageWithExtraData<REQ> envelope,
String managedServerName,
ManagedServer managedServer)
|
protected abstract void |
validate(String modelNodePath,
org.hawkular.bus.common.BasicMessageWithExtraData<REQ> envelope)
modelNodePath validation for subclasses. |
protected final String entityType
entityType is
supposed to be used in log and exception messages primarily. This field should have values like
"Datasource", "JDBC Driver" or similar.protected final String operationName
Updade, Add
or Remove. operationName is supposed to be used in log and exception messages primarily.protected String getOperationName(org.hawkular.bus.common.BasicMessageWithExtraData<REQ> envelope)
public org.hawkular.bus.common.BasicMessageWithExtraData<RESP> execute(org.hawkular.bus.common.BasicMessageWithExtraData<REQ> envelope, CommandContext context) throws Exception
Commandexecute in interface Command<REQ extends org.hawkular.cmdgw.api.ResourcePathRequest,RESP extends org.hawkular.cmdgw.api.ResourcePathResponse>envelope - the request that describes what needs to be executed eventually with attached BinaryDatacontext - contains data that can help commands do their jobException - if failed to execute the commandprotected abstract void execute(org.jboss.as.controller.client.ModelControllerClient controllerClient,
ManagedServer managedServer,
String modelNodePath,
org.hawkular.bus.common.BasicMessageWithExtraData<REQ> envelope,
RESP response,
CommandContext context)
throws Exception
controllerClient - a subclass of JBossASClient returned by
createControllerClient(ManagedServer, CommandContext)managedServer - a ManagedServer instance acquired from ResourcePathRequest.getResourcePath()modelNodePath - a DMR path acquired from ResourcePathRequest.getResourcePath()envelope - the requestresponse - the responsecontext - the CommandContextException - if anything goes wrongprotected org.jboss.as.controller.client.ModelControllerClient createControllerClient(ManagedServer managedServer, CommandContext context)
ModelControllerClient.context - the CommandContextmanagedServer - a ManagedServer instance acquired from ResourcePathRequest.getResourcePath()ModelControllerClientprotected abstract void validate(String modelNodePath, org.hawkular.bus.common.BasicMessageWithExtraData<REQ> envelope)
modelNodePath validation for subclasses.modelNodePath - a DMR path to checkenvelope - the request the modelNodePath comes fromprotected void validate(org.hawkular.bus.common.BasicMessageWithExtraData<REQ> envelope)
request has resourcePath field set. Subclasses may want to add more request
validations in their overrides.envelope - the request to validateprotected void validate(org.hawkular.bus.common.BasicMessageWithExtraData<REQ> envelope, String managedServerName, ManagedServer managedServer)
managedServerName - the name of the managedServermanagedServer - the managed server to validateprotected abstract RESP createResponse()
ResourcePathResponse subclassprotected void success(org.hawkular.bus.common.BasicMessageWithExtraData<REQ> envelope, RESP response)
protected void assertLocalOrRemoteServer(ManagedServer managedServer)
protected void assertLocalServer(ManagedServer managedServer)
protected void assertNotRename(org.jboss.dmr.ModelNode adr,
String newName)
Copyright © 2015 Red Hat, Inc.. All rights reserved.