本文整理汇总了Java中org.jboss.dmr.Property类的典型用法代码示例。如果您正苦于以下问题:Java Property类的具体用法?Java Property怎么用?Java Property使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Property类属于org.jboss.dmr包,在下文中一共展示了Property类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getChildrenTypes
import org.jboss.dmr.Property; //导入依赖的package包/类
public Set<String> getChildrenTypes() {
Set<String> result = new HashSet<>();
if(hasChildrenDefined())
{
ModelNode children = get(CHILDREN);
List<Property> items = children.asPropertyList();
for (Property item : items) {
Set<String> keys = item.getValue().get(MODEL_DESCRIPTION).keys();
if(keys.contains("*")) // regular resources (opposed to singletons, that carry distinct names)
{
result.add(item.getName());
}
}
}
return result;
}
示例2: getSingletonChildrenTypes
import org.jboss.dmr.Property; //导入依赖的package包/类
public Set<String> getSingletonChildrenTypes() {
Set<String> result = new HashSet<>();
if(hasChildrenDefined())
{
ModelNode children = get(CHILDREN);
List<Property> items = children.asPropertyList();
for (Property item : items) {
Set<String> keys = item.getValue().get(MODEL_DESCRIPTION).keys();
if(!keys.contains("*")) // singleton resources
{
result.addAll(keys.stream().map(key -> item.getName() + "=" + key).collect(Collectors.toList()));
}
}
}
return result;
}
示例3: getChildDescription
import org.jboss.dmr.Property; //导入依赖的package包/类
/**
* Looks for the description of a specific child resource.
* @param type The type of the child resource
* @param name The name of the instance
* @return the description of the specific child resource or {@link #EMPTY} if no such resource exists.
*/
public ResourceDescription getChildDescription(String type, String name) {
if (hasChildrenDefined()) {
List<Property> children = get("children").asPropertyList();
for (Property child : children) {
if (type.equals(child.getName()) && child.getValue().hasDefined(MODEL_DESCRIPTION)) {
List<Property> modelDescriptions = child.getValue().get(MODEL_DESCRIPTION).asPropertyList();
for (Property modelDescription : modelDescriptions) {
if (name.equals(modelDescription.getName())) {
return new ResourceDescription(modelDescription.getValue());
}
}
}
}
}
return EMPTY;
}
示例4: fromDmr
import org.jboss.dmr.Property; //导入依赖的package包/类
public void fromDmr(Object entity, String javaName, ModelType dmrType, Class<?> propertyType, ModelNode dmrPayload) throws Exception {
Method target = entity.getClass().getMethod(javaName, propertyType);
@SuppressWarnings("unchecked")
List<Property> properties = dmrPayload.isDefined() ? dmrPayload.asPropertyList() : EMPTY_LIST;
if(properties.isEmpty())
{
target.invoke(entity, EMPTY_MAP);
}
else
{
Map<String, Object> map = new HashMap<>(properties.size());
for (Property prop : properties) {
map.put(prop.getName(), toJavaValue(prop.getValue().getType(), prop.getValue()));
}
target.invoke(entity, map);
}
}
示例5: forServer
import org.jboss.dmr.Property; //导入依赖的package包/类
/**
* Returns the part of the operation result that is in fact a result of an operation performed on one single server
* in a domain. The server is identified by the {@code host} name and the {@code server} name. It's not needed
* to specify the server group, because one host can only belong to one server group.
* @throws IllegalArgumentException if {@code this} is not an operation result from domain or if no such
* {@code host} + {@code server} combination is present in {@code this}
*/
public final ModelNodeResult forServer(String host, String server) {
if (!isFromDomain()) {
throw new IllegalArgumentException("Can't call forServer on a result that isn't from domain");
}
List<Property> serverGroups = this.get(Constants.SERVER_GROUPS).asPropertyList();
for (Property serverGroup : serverGroups) {
ModelNode response = serverGroup.getValue().get(Constants.HOST, host, server, Constants.RESPONSE);
if (response.isDefined()) {
return new ModelNodeResult(response);
}
}
throw new IllegalArgumentException("No such host or server: host = " + host + ", server = " + server);
}
示例6: isResultUnknownOrNotFound
import org.jboss.dmr.Property; //导入依赖的package包/类
static boolean isResultUnknownOrNotFound(ModelNodeResult result) {
result.assertFailed();
ModelNode failureDescription = result.get(Constants.FAILURE_DESCRIPTION);
if (failureDescription.hasDefined(Constants.HOST_FAILURE_DESCRIPTIONS)) {
List<Property> hostFailures = failureDescription.get(Constants.HOST_FAILURE_DESCRIPTIONS).asPropertyList();
for (Property hostFailure : hostFailures) {
if (isFailureDesriptionUnknownOrNotFound(hostFailure.getValue().asString())) {
return true;
}
}
return false;
} else {
if (failureDescription.hasDefined(Constants.DOMAIN_FAILURE_DESCRIPTION)) {
failureDescription = failureDescription.get(Constants.DOMAIN_FAILURE_DESCRIPTION);
}
return isFailureDesriptionUnknownOrNotFound(failureDescription.asString());
}
}
示例7: convertParameters
import org.jboss.dmr.Property; //导入依赖的package包/类
private static String convertParameters(ModelNode op) {
StringBuilder result = new StringBuilder();
boolean first = true;
for (Property parameter : op.asPropertyList()) {
String name = parameter.getName();
if (Constants.OP.equals(name)
|| Constants.OP_ADDR.equals(name)
|| Constants.OPERATION_HEADERS.equals(name)) {
continue;
}
if (!first) {
result.append(", ");
}
first = false;
result.append(name).append("=").append(convertValue(parameter.getValue()));
}
if (result.length() > 0) {
return "(" + result.toString() + ")";
}
return "";
}
示例8: assertResourceCount
import org.jboss.dmr.Property; //导入依赖的package包/类
protected void assertResourceCount(ModelControllerClient mcc, ModelNode address, String childType,
int expectedCount) throws IOException {
ModelNode request = new ModelNode();
request.get(ModelDescriptionConstants.ADDRESS).set(address);
request.get(ModelDescriptionConstants.OP).set(ModelDescriptionConstants.READ_CHILDREN_RESOURCES_OPERATION);
request.get(ModelDescriptionConstants.CHILD_TYPE).set(childType);
request.get(ModelDescriptionConstants.INCLUDE_RUNTIME).set(true);
ModelNode response = mcc.execute(request);
if (response.hasDefined(ModelDescriptionConstants.OUTCOME)
&& response.get(ModelDescriptionConstants.OUTCOME)
.asString().equals(ModelDescriptionConstants.SUCCESS)) {
ModelNode result = response.get(ModelDescriptionConstants.RESULT);
List<Property> nodes = result.asPropertyList();
AssertJUnit.assertEquals("Number of child nodes of [" + address + "] " + response, expectedCount,
nodes.size());
} else if (expectedCount != 0) {
AssertJUnit
.fail("Path [" + address + "] has no child nodes, expected [" + expectedCount + "]: " + response);
}
}
示例9: getSystemProperties
import org.jboss.dmr.Property; //导入依赖的package包/类
/**
* This returns the system properties that are set in the AS JVM. This is not the system properties
* in the JVM of this client object - it is actually the system properties in the remote
* JVM of the AS instance that the client is talking to.
*
* @return the AS JVM's system properties
* @throws Exception any error
*/
public Properties getSystemProperties() throws Exception {
final String[] address = { CORE_SERVICE, PLATFORM_MBEAN, "type", "runtime" };
final ModelNode op = createReadAttributeRequest(true, "system-properties", Address.root().add(address));
final ModelNode results = execute(op);
if (isSuccess(results)) {
// extract the DMR representation into a java Properties object
final Properties sysprops = new Properties();
final ModelNode node = getResults(results);
final List<Property> propertyList = node.asPropertyList();
for (Property property : propertyList) {
final String name = property.getName();
final ModelNode value = property.getValue();
if (name != null) {
sysprops.put(name, value != null ? value.asString() : "");
}
}
return sysprops;
} else {
throw new FailureException(results, "Failed to get system properties");
}
}
示例10: fromModelNode
import org.jboss.dmr.Property; //导入依赖的package包/类
/**
* Obtains the address from the given ModelNode which is assumed to be a property list that
* contains all the address parts and only the address parts.
*
* @param node address node
* @return the address
*/
public static Address fromModelNode(ModelNode node) {
// Rather than just store node as this.addressNode, we want to make sure it can be used as a valid address.
// This also builds our own instance of ModelNode rather than use the one the caller gave us.
Address address = Address.root();
// if the node is not defined, this simply represents the root address
if (!node.isDefined()) {
return address;
}
try {
List<Property> addressList = node.asPropertyList();
for (Property addressProperty : addressList) {
String resourceType = addressProperty.getName();
String resourceName = addressProperty.getValue().asString();
address.add(resourceType, resourceName);
}
return address;
} catch (Exception e) {
throw new IllegalArgumentException("Node cannot be used as an address: " + node.toJSONString(true));
}
}
示例11: add
import org.jboss.dmr.Property; //导入依赖的package包/类
/**
* Appends the given address to this address.
* This lets you build up addresses in a step-wise fashion.
*
* @param address new address to appen to this address.
*
* @return this address (which now has the new address appended).
*/
public Address add(Address address) {
// if address is null or is the root address then there is nothing to append
if (address == null || address.isRoot()) {
return this;
}
// if we are the root address then the given address just is our new address,
// otherwise, append all parts from "address" to us.
if (isRoot()) {
this.addressNode = address.addressNode.clone();
} else {
List<Property> parts = address.addressNode.asPropertyList();
for (Property part : parts) {
this.addressNode.add(part);
}
}
return this;
}
示例12: toAddressParts
import org.jboss.dmr.Property; //导入依赖的package包/类
/**
* @return returns the address split into its individual parts.
* e.g. "/one=two" will return a 2-element array {"one", "two"}.
*/
public String[] toAddressParts() {
if (isRoot()) {
return new String[0];
}
List<Property> properties = addressNode.asPropertyList();
String[] parts = new String[properties.size() * 2];
int i = 0;
for (Property property : properties) {
String name = property.getName();
String value = property.getValue().asString();
parts[i++] = name;
parts[i++] = value;
}
return parts;
}
示例13: generateReport
import org.jboss.dmr.Property; //导入依赖的package包/类
private void generateReport() {
StringBuilder sb = new StringBuilder();
ModelVersion legacyVersion = Tools.createModelVersion(legacyModelVersions.get(Tools.CORE, Tools.STANDALONE));
ModelVersion currentVersion = Tools.createModelVersion(currentModelVersions.get(Tools.CORE, Tools.STANDALONE));
String currentEAPVersion = currentModelVersions.get(Tools.CORE, "product").get(PRODUCT_VERSION).asString();
String legacyEAPVersion = legacyModelVersions.get(Tools.CORE, "product").get(PRODUCT_VERSION).asString();
sb.append("| Subsystem | ")
.append(legacyEAPVersion).append(" - *").append(legacyVersion).append("* | ")
.append(currentEAPVersion).append(" - *").append(currentVersion).append("* |\n");
sb.append("| --- | --- | --- | \n");
for (Property entry : legacyModelVersions.get(SUBSYSTEM).asPropertyList()) {
ModelVersion legacy = Tools.createModelVersion(entry.getValue());
ModelVersion current = Tools.createModelVersion(currentModelVersions.get(SUBSYSTEM, entry.getName()));
boolean diff = !legacy.equals(current);
String name = diff ? ("**" + entry.getName() + "**") : entry.getName();
sb.append("| ")
.append(name).append(" | ")
.append(legacy).append(" | ")
.append(current).append(" | ")
.append("\n");
}
System.out.println(sb.toString());
}
示例14: canAppearNext
import org.jboss.dmr.Property; //导入依赖的package包/类
private boolean canAppearNext(Property prop) {
if (presentProperties.contains(prop.getName())) {
return false;
}
// If user typed something, complete if possible.
// Invalid properties will be exposed in this case.
if (radical != null && !radical.isEmpty()) {
return prop.getName().startsWith(radical);
}
// The invalid alternatives
if (invalidProperties.contains(prop.getName())) {
return false;
}
return true;
}
示例15: compareAttributes
import org.jboss.dmr.Property; //导入依赖的package包/类
public static double compareAttributes(Property attr1, Property attr2) {
double res = 1d;
res *= compareStrings(attr1.getName(), attr2.getName());
ModelNode node1 = attr1.getValue();
ModelNode node2 = attr2.getValue();
boolean expressions1 = node1.get(ModelDescriptionConstants.EXPRESSIONS_ALLOWED).asBoolean(false);
boolean expressions2 = node2.get(ModelDescriptionConstants.EXPRESSIONS_ALLOWED).asBoolean(false);
boolean nullable1 = node1.get(ModelDescriptionConstants.NILLABLE).asBoolean(true);
boolean nullable2 = node2.get(ModelDescriptionConstants.NILLABLE).asBoolean(true);
res *= compareStrings(node1.getType().name(), node2.getType().name());
res *= compareStrings(node1.get(ModelDescriptionConstants.DESCRIPTION).asString(), node2.get(ModelDescriptionConstants.DESCRIPTION).asString());
res *= expressions1 == expressions2 ? 1d : 0.9d;
res *= nullable1 == nullable2 ? 1d : 0.9d;
return res;
}