public class Operations extends Object
final ModelControllerClient client = ModelControllerClient.Factory.create(hostname, port);
final ModelNode address = new ModelNode().setEmptyList();
// Read the server state
final ModelNode op = Operations.createReadAttributeOperation(address, "server-state");
final ModelNode result = client.execute(op);
if (Operations.isSuccessfulOutcome(result)) {
System.out.printf("Server state: %s%n", Operations.readResult(result));
} else {
System.out.printf("Failure! %s%n", Operations.getFailureDescription(result));
}
Modifier and Type | Class and Description |
---|---|
static class |
Operations.CompositeOperationBuilder
A builder for building composite operations.
|
Constructor and Description |
---|
Operations() |
Modifier and Type | Method and Description |
---|---|
static ModelNode |
createAddOperation(ModelNode address)
Creates an add operation.
|
static ModelNode |
createAddress(Iterable<String> pairs)
Creates an address that can be used as the address for an operation.
|
static ModelNode |
createAddress(String... pairs)
Creates an address that can be used as the address for an operation.
|
static ModelNode |
createCompositeOperation()
Creates a composite operation with an empty address and empty steps that will rollback on a runtime failure.
|
static ModelNode |
createOperation(String operation)
Creates a generic operation with an empty (root) address.
|
static ModelNode |
createOperation(String operation,
ModelNode address)
Creates an operation.
|
static ModelNode |
createReadAttributeOperation(ModelNode address,
String attributeName)
Creates an operation to read the attribute represented by the
attributeName parameter. |
static ModelNode |
createReadResourceOperation(ModelNode address)
Creates a non-recursive operation to read a resource.
|
static ModelNode |
createReadResourceOperation(ModelNode address,
boolean recursive)
Creates an operation to read a resource.
|
static ModelNode |
createRemoveOperation(ModelNode address)
Creates a remove operation.
|
static ModelNode |
createUndefineAttributeOperation(ModelNode address,
String attributeName)
Creates an operation to undefine an attribute value represented by the
attributeName parameter. |
static ModelNode |
createWriteAttributeOperation(ModelNode address,
String attributeName,
boolean value)
Creates an operation to write an attribute value represented by the
attributeName parameter. |
static ModelNode |
createWriteAttributeOperation(ModelNode address,
String attributeName,
int value)
Creates an operation to write an attribute value represented by the
attributeName parameter. |
static ModelNode |
createWriteAttributeOperation(ModelNode address,
String attributeName,
long value)
Creates an operation to write an attribute value represented by the
attributeName parameter. |
static ModelNode |
createWriteAttributeOperation(ModelNode address,
String attributeName,
ModelNode value)
Creates an operation to write an attribute value represented by the
attributeName parameter. |
static ModelNode |
createWriteAttributeOperation(ModelNode address,
String attributeName,
String value)
Creates an operation to write an attribute value represented by the
attributeName parameter. |
static ModelNode |
getFailureDescription(ModelNode result)
Parses the result and returns the failure description.
|
static ModelNode |
getOperationAddress(ModelNode op)
Returns the address for the operation.
|
static String |
getOperationName(ModelNode op)
Returns the name of the operation.
|
static boolean |
isSuccessfulOutcome(ModelNode outcome)
Checks the result for a successful operation outcome.
|
static ModelNode |
readResult(ModelNode result)
Reads the result of an operation and returns the result.
|
public static boolean isSuccessfulOutcome(ModelNode outcome)
outcome
- the result of executing an operationtrue
if the operation was successful, otherwise false
public static ModelNode getFailureDescription(ModelNode result)
result
- the result of executing an operationIllegalArgumentException
- if the outcome of the operation was successfulpublic static ModelNode createAddress(String... pairs)
ModelNode
of type ModelType.LIST
.
The string is split into key/value pairs. If the final key does not have a value an *
is used to
indicate a wildcard for the address.
pairs
- the key/value pairs to usepublic static ModelNode createAddress(Iterable<String> pairs)
ModelNode
of type ModelType.LIST
.
The string is split into key/value pairs. If the final key does not have a value an *
is used to
indicate a wildcard for the address.
pairs
- the key/value pairs to usepublic static ModelNode getOperationAddress(ModelNode op)
op
- the operationpublic static String getOperationName(ModelNode op)
op
- the operationIllegalArgumentException
- if the operation was not defined.public static ModelNode createAddOperation(ModelNode address)
address
- the address for the operationpublic static ModelNode createRemoveOperation(ModelNode address)
address
- the address for the operationpublic static ModelNode createCompositeOperation()
ClientConstants.ROLLBACK_ON_RUNTIME_FAILURE
is set to true
to rollback all
operations if one fails.public static ModelNode createReadAttributeOperation(ModelNode address, String attributeName)
attributeName
parameter.address
- the address to create the read attribute forattributeName
- the name of the parameter to readpublic static ModelNode createReadResourceOperation(ModelNode address)
address
- the address to create the read forpublic static ModelNode createReadResourceOperation(ModelNode address, boolean recursive)
address
- the address to create the read forrecursive
- whether to search recursively or notpublic static ModelNode createUndefineAttributeOperation(ModelNode address, String attributeName)
attributeName
parameter.address
- the address to create the write attribute forattributeName
- the name attribute to undefinepublic static ModelNode createWriteAttributeOperation(ModelNode address, String attributeName, boolean value)
attributeName
parameter.address
- the address to create the write attribute forattributeName
- the name of the attribute to writevalue
- the value to set the attribute topublic static ModelNode createWriteAttributeOperation(ModelNode address, String attributeName, int value)
attributeName
parameter.address
- the address to create the write attribute forattributeName
- the name of the attribute to writevalue
- the value to set the attribute topublic static ModelNode createWriteAttributeOperation(ModelNode address, String attributeName, long value)
attributeName
parameter.address
- the address to create the write attribute forattributeName
- the name of the attribute to writevalue
- the value to set the attribute topublic static ModelNode createWriteAttributeOperation(ModelNode address, String attributeName, String value)
attributeName
parameter.address
- the address to create the write attribute forattributeName
- the name of the attribute to writevalue
- the value to set the attribute topublic static ModelNode createWriteAttributeOperation(ModelNode address, String attributeName, ModelNode value)
attributeName
parameter.address
- the address to create the write attribute forattributeName
- the name of the attribute to writevalue
- the value to set the attribute topublic static ModelNode createOperation(String operation)
operation
- the operation to createpublic static ModelNode createOperation(String operation, ModelNode address)
operation
- the operation nameaddress
- the address for the operationIllegalArgumentException
- if the address is not of type ModelType.LIST
public static ModelNode readResult(ModelNode result)
ClientConstants.RESULT
attribute, a new undefined ModelNode
is returned.result
- the result of executing an operationCopyright © 2018 JBoss by Red Hat. All rights reserved.