Java Code Examples for org.jboss.dmr.Property#getValue()
The following examples show how to use
org.jboss.dmr.Property#getValue() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ThreadsParser.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
private void writeQueuelessThreadPool(final XMLExtendedStreamWriter writer, final Property property, final String elementName, final boolean includeName, final boolean blocking) throws XMLStreamException { writer.writeStartElement(elementName); ModelNode node = property.getValue(); if (includeName) { writer.writeAttribute(Attribute.NAME.getLocalName(), property.getName()); } writeCountElement(PoolAttributeDefinitions.MAX_THREADS, node, writer); writeTime(writer, node, Element.KEEPALIVE_TIME); writeRef(writer, node, Element.THREAD_FACTORY, THREAD_FACTORY); if (!blocking) { writeRef(writer, node, Element.HANDOFF_EXECUTOR, HANDOFF_EXECUTOR); } writer.writeEndElement(); }
Example 2
Source File: SystemPropertiesXml.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
void writeProperties(final XMLExtendedStreamWriter writer, final ModelNode modelNode, Element element, boolean standalone) throws XMLStreamException { final List<Property> properties = modelNode.asPropertyList(); if (properties.size() > 0) { writer.writeStartElement(element.getLocalName()); for (Property prop : properties) { writer.writeStartElement(Element.PROPERTY.getLocalName()); writer.writeAttribute(NAME, prop.getName()); ModelNode sysProp = prop.getValue(); SystemPropertyResourceDefinition.VALUE.marshallAsAttribute(sysProp, writer); if (!standalone) { SystemPropertyResourceDefinition.BOOT_TIME.marshallAsAttribute(sysProp, writer); } writer.writeEndElement(); } writer.writeEndElement(); } }
Example 3
Source File: LoggingSubsystemTestCase.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
@Override public ModelNode fixModel(final ModelNode modelNode) { // Recursively remove the attributes if (modelNode.getType() == ModelType.OBJECT) { for (Property property : modelNode.asPropertyList()) { final String name = property.getName(); final ModelNode value = property.getValue(); if (value.isDefined()) { if (value.getType() == ModelType.OBJECT) { modelNode.get(name).set(fixModel(value)); } else if (value.getType() == ModelType.STRING) { if (name.equals(attribute.getName())) { modelNode.get(name).set(value.asString().replace(from, to)); } } } } } return modelNode; }
Example 4
Source File: ThreadsParser.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
public void writeBoundedQueueThreadPool(final XMLExtendedStreamWriter writer, final Property property, final String elementName, final boolean includeName, final boolean blocking) throws XMLStreamException { writer.writeStartElement(elementName); ModelNode node = property.getValue(); if (includeName) { writer.writeAttribute(Attribute.NAME.getLocalName(), property.getName()); } PoolAttributeDefinitions.ALLOW_CORE_TIMEOUT.marshallAsAttribute(node, writer); writeCountElement(PoolAttributeDefinitions.CORE_THREADS, node, writer); writeCountElement(PoolAttributeDefinitions.QUEUE_LENGTH, node, writer); writeCountElement(PoolAttributeDefinitions.MAX_THREADS, node, writer); writeTime(writer, node, Element.KEEPALIVE_TIME); writeRef(writer, node, Element.THREAD_FACTORY, THREAD_FACTORY); if (!blocking) { writeRef(writer, node, Element.HANDOFF_EXECUTOR, HANDOFF_EXECUTOR); } writer.writeEndElement(); }
Example 5
Source File: ManagedServerBootCmdFactory.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
private void addSystemProperties(final ModelNode source, final Map<String, String> props, boolean boottimeOnly) { if (source.hasDefined(SYSTEM_PROPERTY)) { for (Property prop : source.get(SYSTEM_PROPERTY).asPropertyList()) { ModelNode propResource = prop.getValue(); try { if (boottimeOnly && !SystemPropertyResourceDefinition.BOOT_TIME.resolveModelAttribute(expressionResolver, propResource).asBoolean()) { continue; } } catch (OperationFailedException e) { throw new IllegalStateException(e); } String val = propResource.hasDefined(VALUE) ? propResource.get(VALUE).asString() : null; props.put(prop.getName(), val); } } }
Example 6
Source File: ArgumentValueParsingTestCase.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
@Test public void testObjectWithPropertyList() throws Exception { final ModelNode value = parse("a=b,c=[d=e,f=g]"); assertNotNull(value); assertEquals(ModelType.OBJECT, value.getType()); final List<Property> list = value.asPropertyList(); assertEquals(2, list.size()); Property prop = list.get(0); assertNotNull(prop); assertEquals("a", prop.getName()); assertEquals("b", prop.getValue().asString()); prop = list.get(1); assertNotNull(prop); assertEquals("c", prop.getName()); final ModelNode c = prop.getValue(); assertEquals(ModelType.LIST, c.getType()); final List<Property> propList = c.asPropertyList(); assertEquals(2, propList.size()); prop = propList.get(0); assertEquals("d", prop.getName()); assertEquals("e", prop.getValue().asString()); prop = propList.get(1); assertEquals("f", prop.getName()); assertEquals("g", prop.getValue().asString()); }
Example 7
Source File: ManagedServerOperationsFactory.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
private void addSystemProperties(final ModelNode source, final Map<String, String> props, boolean boottimeOnly) { if (source.hasDefined(SYSTEM_PROPERTY)) { for (Property prop : source.get(SYSTEM_PROPERTY).asPropertyList()) { ModelNode propResource = prop.getValue(); try { if (boottimeOnly && !SystemPropertyResourceDefinition.BOOT_TIME.resolveModelAttribute(domainController.getExpressionResolver(), propResource).asBoolean()) { continue; } } catch (OperationFailedException e) { throw new IllegalStateException(e); } String val = propResource.hasDefined(VALUE) ? propResource.get(VALUE).asString() : null; props.put(prop.getName(), val); } } }
Example 8
Source File: ManagementVersionTestCase.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
private void extensionsTest(String address, ModelControllerClient client) throws Exception { ModelNode op = createOpNode(address, "read-children-resources"); op.get("child-type").set("extension"); op.get("recursive").set(true); op.get("include-runtime").set(true); ModelNode result = executeOperation(op, client); for (Property extension : result.asPropertyList()) { String extensionName = extension.getName(); ModelNode subsystems = extension.getValue().get("subsystem"); Assert.assertEquals(extensionName + " has no subsystems", ModelType.OBJECT, subsystems.getType()); for (Property subsystem : subsystems.asPropertyList()) { String subsystemName = subsystem.getName(); ModelNode value = subsystem.getValue(); Assert.assertEquals(subsystemName + " has major version", ModelType.INT, value.get("management-major-version").getType()); Assert.assertEquals(subsystemName + " has minor version", ModelType.INT, value.get("management-minor-version").getType()); Assert.assertEquals(subsystemName + " has namespaces", ModelType.LIST, value.get("xml-namespaces").getType()); Assert.assertTrue(subsystemName + " has positive major version", value.get("management-major-version").asInt() > 0); Assert.assertTrue(subsystemName + " has non-negative minor version", value.get("management-minor-version").asInt() >= 0); Assert.assertTrue(subsystemName + " has more than zero namespaces", value.get("xml-namespaces").asInt() > 0); } } }
Example 9
Source File: DomainServerUtils.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
public static Set<ServerIdentity> getServersForGroup(String groupName, ModelNode hostModel, final String localHostName, final Map<String, ProxyController> serverProxies) { Set<ServerIdentity> result; if (hostModel.hasDefined(SERVER_CONFIG)) { result = new HashSet<ServerIdentity>(); for (Property prop : hostModel.get(SERVER_CONFIG).asPropertyList()) { String serverName = prop.getName(); if (serverProxies.get(serverName) == null) { continue; } ModelNode server = prop.getValue(); String serverGroupName = server.require(GROUP).asString(); if (groupName != null && !groupName.equals(serverGroupName)) { continue; } ServerIdentity groupedServer = new ServerIdentity(localHostName, serverGroupName, serverName); result.add(groupedServer); } } else { result = Collections.emptySet(); } return result; }
Example 10
Source File: CoreJBossASClient.java From hawkular-agent with Apache License 2.0 | 6 votes |
/** * 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"); } }
Example 11
Source File: ServerOperationResolver.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
private Map<Set<ServerIdentity>, ModelNode> getServerInterfaceOperations(ModelNode operation, PathAddress address, ModelNode hostModel, boolean forDomain) { String pathName = address.getElement(0).getValue(); Map<Set<ServerIdentity>, ModelNode> result; if (forDomain && hostModel.hasDefined(INTERFACE) && hostModel.get(INTERFACE).keys().contains(pathName)) { // Host will take precedence; ignore the domain result = Collections.emptyMap(); } else if (forDomain && ADD.equals(operation.get(OP).asString()) && !InterfaceDefinition.isOperationDefined(operation)) { // don't create named interfaces result = Collections.emptyMap(); } else if (hostModel.hasDefined(SERVER_CONFIG)) { Set<ServerIdentity> servers = new HashSet<ServerIdentity>(); for (Property prop : hostModel.get(SERVER_CONFIG).asPropertyList()) { String serverName = prop.getName(); if (serverProxies.get(serverName) == null) { continue; } ModelNode server = prop.getValue(); String serverGroupName = server.require(GROUP).asString(); if (server.hasDefined(INTERFACE) && server.get(INTERFACE).keys().contains(pathName)) { // Server takes precedence; ignore domain continue; } ServerIdentity groupedServer = new ServerIdentity(localHostName, serverGroupName, serverName); servers.add(groupedServer); } ModelNode serverOp = operation.clone(); serverOp.get(OP_ADDR).setEmptyList().add(INTERFACE, pathName); result = Collections.singletonMap(servers, serverOp); } else { result = Collections.emptyMap(); } return result; }
Example 12
Source File: ManagedServerBootCmdFactory.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
/** * Resolve expressions in the given model (if there are any) * * @param unresolved node with possibly unresolved expressions. Cannot be {@code null} * @param expressionResolver resolver to use. Cannot be {@code null} * @param excludePostBootSystemProps {@code true} if child system-property nodes should be checked * for the 'boot-time' attribute, with resolution being * skipped if that is set to 'false'. WFCORE-450 * * @return a clone of {@code unresolved} with all expression resolved */ static ModelNode resolveExpressions(final ModelNode unresolved, final ExpressionResolver expressionResolver, boolean excludePostBootSystemProps) { ModelNode toResolve = unresolved.clone(); ModelNode sysProps = null; if (excludePostBootSystemProps && toResolve.hasDefined(SYSTEM_PROPERTY)) { sysProps = toResolve.remove(SYSTEM_PROPERTY); } try { ModelNode result = expressionResolver.resolveExpressions(toResolve); if (sysProps != null) { ModelNode resolvedSysProps = new ModelNode().setEmptyObject(); for (Property property : sysProps.asPropertyList()) { ModelNode val = property.getValue(); boolean bootTime = SystemPropertyResourceDefinition.BOOT_TIME.resolveModelAttribute(expressionResolver, val).asBoolean(); if (bootTime) { val.get(VALUE).set(SystemPropertyResourceDefinition.VALUE.resolveModelAttribute(expressionResolver, val)); } // store the resolved boot-time to save re-resolving later val.get(BOOT_TIME).set(bootTime); resolvedSysProps.get(property.getName()).set(val); } result.get(SYSTEM_PROPERTY).set(resolvedSysProps); } return result; } catch (OperationFailedException e) { // Fail throw new IllegalStateException(e.getMessage(), e); } }
Example 13
Source File: ManagedServerOperationsFactory.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
private void addRoleMappings(ModelNode accessControl, ModelNode baseAddress, ModelNodeList updates) { if (accessControl.hasDefined(ROLE_MAPPING)) { for (Property roleProp : accessControl.get(ROLE_MAPPING).asPropertyList()) { ModelNode roleAddress = baseAddress.clone().add(ROLE_MAPPING, roleProp.getName()); updates.add(Util.getEmptyOperation(ADD, roleAddress)); ModelNode roleMapping = roleProp.getValue(); convertSimpleResources(roleMapping, INCLUDE, roleAddress, updates); convertSimpleResources(roleMapping, EXCLUDE, roleAddress, updates); } } }
Example 14
Source File: ManagedServerOperationsFactory.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
private static void convertAttributesToParams(ModelNode value, ModelNode addOp) { if (value.isDefined()) { for (Property prop : value.asPropertyList()) { ModelNode attrVal = prop.getValue(); if (attrVal.isDefined()) { addOp.get(prop.getName()).set(attrVal); } } } }
Example 15
Source File: ArgumentValueParsingTestCase.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
@Test public void testListOfObjects() throws Exception { final ModelNode value = parse("[{a=b},{c=[d=e,f={g=h}]}]"); assertNotNull(value); assertEquals(ModelType.LIST, value.getType()); final List<ModelNode> list = value.asList(); assertEquals(2, list.size()); ModelNode item = list.get(0); assertNotNull(item); assertEquals(1, item.keys().size()); assertEquals("b", item.get("a").asString()); item = list.get(1); assertNotNull(item); assertEquals(1, item.keys().size()); item = item.get("c"); assertTrue(item.isDefined()); assertEquals(ModelType.LIST, item.getType()); final List<Property> propList = item.asPropertyList(); assertEquals(2, propList.size()); Property prop = propList.get(0); assertEquals("d", prop.getName()); assertEquals("e", prop.getValue().asString()); prop = propList.get(1); assertEquals("f", prop.getName()); final ModelNode gh = prop.getValue(); assertEquals(1, gh.keys().size()); assertEquals("h", gh.get("g").asString()); }
Example 16
Source File: AccessControlXml.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
private void writeHostScopedRoles(XMLExtendedStreamWriter writer, ModelNode scopedRoles) throws XMLStreamException { writer.writeStartElement(Element.HOST_SCOPED_ROLES.getLocalName()); for (Property property : scopedRoles.asPropertyList()) { writer.writeStartElement(Element.ROLE.getLocalName()); writer.writeAttribute(Attribute.NAME.getLocalName(), property.getName()); ModelNode value = property.getValue(); HostScopedRolesResourceDefinition.BASE_ROLE.marshallAsAttribute(value, writer); HostScopedRolesResourceDefinition.HOSTS.marshallAsElement(value, writer); writer.writeEndElement(); } writer.writeEndElement(); }
Example 17
Source File: ServerOperationResolver.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
private Map<Set<ServerIdentity>, ModelNode> getServerPathOperations(ModelNode operation, PathAddress address, ModelNode hostModel, boolean forDomain) { String pathName = address.getElement(0).getValue(); Map<Set<ServerIdentity>, ModelNode> result; if (forDomain && hostModel.hasDefined(PATH) && hostModel.get(PATH).keys().contains(pathName)) { // Host will take precedence; ignore the domain result = Collections.emptyMap(); } else if (ADD.equals(operation.get(OP).asString()) && !operation.hasDefined(PATH)) { // don't push named only paths result = Collections.emptyMap(); } else if (hostModel.hasDefined(SERVER_CONFIG)) { Set<ServerIdentity> servers = new HashSet<ServerIdentity>(); for (Property prop : hostModel.get(SERVER_CONFIG).asPropertyList()) { String serverName = prop.getName(); if (serverProxies.get(serverName) == null) { continue; } ModelNode server = prop.getValue(); String serverGroupName = server.require(GROUP).asString(); if (server.hasDefined(PATH) && server.get(PATH).keys().contains(pathName)) { // Server takes precedence; ignore domain continue; } ServerIdentity groupedServer = new ServerIdentity(localHostName, serverGroupName, serverName); servers.add(groupedServer); } ModelNode serverOp = operation.clone(); serverOp.get(OP_ADDR).setEmptyList().add(PATH, pathName); result = Collections.singletonMap(servers, serverOp); } else { result = Collections.emptyMap(); } return result; }
Example 18
Source File: CoreResourceManagementTestCase.java From wildfly-core with GNU Lesser General Public License v2.1 | 4 votes |
private void testCannotInvokeManagedServerOperationsComposite(ModelNode stepAddress) throws Exception { final DomainClient masterClient = domainMasterLifecycleUtil.getDomainClient(); ModelNode composite = new ModelNode(); composite.get(OP).set(CompositeOperationHandler.NAME); composite.get(OP_ADDR).setEmptyList(); composite.get(OPERATION_HEADERS, ROLLBACK_ON_RUNTIME_FAILURE).set(false); ModelNode goodServerOp = new ModelNode(); goodServerOp.get(OP).set(READ_RESOURCE_OPERATION); goodServerOp.get(OP_ADDR).set(stepAddress); composite.get(STEPS).add(goodServerOp); composite.get(STEPS).add(getAddWorkerOperation(stepAddress.clone().add("worker", ("cannot-" + workerName++)))); ModelNode result = masterClient.execute(composite); validateFailedResponse(result); Set<String> keys = new HashSet<String>(result.get(RESULT).keys()); keys.remove(SERVER_GROUPS); Assert.assertEquals(2, keys.size()); String errorCode = getNotAuthorizedErrorCode(); List<Property> steps = result.get(RESULT).asPropertyList(); int i = 0; for (Property property : steps) { if (property.getName().equals(SERVER_GROUPS)) { continue; } ModelNode stepResult = property.getValue(); Assert.assertEquals(FAILED, stepResult.get(OUTCOME).asString()); if (i == 0) { Assert.assertFalse(stepResult.hasDefined(FAILURE_DESCRIPTION)); } if (i++ == 1) { ModelNode desc = validateFailedResponse(stepResult); Assert.assertTrue(desc.toString() + " does not contain " + errorCode, desc.toString().contains(errorCode)); } i++; } }
Example 19
Source File: CoreResourceManagementTestCase.java From wildfly-core with GNU Lesser General Public License v2.1 | 4 votes |
private void testCannotInvokeManagedServerOperationsComposite(String host, String server, ModelNode stepAddress) throws Exception { final DomainClient masterClient = domainMasterLifecycleUtil.getDomainClient(); ModelNode composite = new ModelNode(); composite.get(OP).set(CompositeOperationHandler.NAME); composite.get(OP_ADDR).add(HOST, host); composite.get(OP_ADDR).add(SERVER, server); composite.get(OPERATION_HEADERS, ROLLBACK_ON_RUNTIME_FAILURE).set(false); ModelNode goodServerOp = new ModelNode(); goodServerOp.get(OP).set(READ_RESOURCE_OPERATION); goodServerOp.get(OP_ADDR).set(stepAddress); composite.get(STEPS).add(goodServerOp); composite.get(STEPS).add(getAddWorkerOperation(stepAddress.clone().add("worker", ("cannot-" + workerName++)))); ModelNode result = masterClient.execute(composite); validateFailedResponse(result); Set<String> keys = new HashSet<String>(result.get(RESULT).keys()); keys.remove(SERVER_GROUPS); Assert.assertEquals(2, keys.size()); String errorCode = getNotAuthorizedErrorCode(); List<Property> steps = result.get(RESULT).asPropertyList(); int i = 0; for (Property property : steps) { if (property.getName().equals(SERVER_GROUPS)) { continue; } ModelNode stepResult = property.getValue(); Assert.assertEquals(FAILED, stepResult.get(OUTCOME).asString()); if (i == 0) { Assert.assertFalse(stepResult.hasDefined(FAILURE_DESCRIPTION)); } if (i++ == 1) { ModelNode desc = validateFailedResponse(stepResult); Assert.assertTrue(desc.toString() + " does not contain " + errorCode, desc.toString().contains(errorCode)); } i++; } }
Example 20
Source File: ManagedServerOperationsFactory.java From wildfly-core with GNU Lesser General Public License v2.1 | 4 votes |
private void addDeployments(List<ModelNode> updates) { if (serverGroup.hasDefined(DEPLOYMENT)) { HostFileRepository remoteRepository = null; if (!domainController.getLocalHostInfo().isMasterDomainController()) { remoteRepository = domainController.getRemoteFileRepository(); } for (Property deployment : serverGroup.get(DEPLOYMENT).asPropertyList()) { String name = deployment.getName(); ModelNode details = deployment.getValue(); ModelNode domainDeployment = domainModel.require(DEPLOYMENT).require(name); ModelNode deploymentContent = domainDeployment.require(CONTENT).clone(); PathAddress addr = PathAddress.pathAddress(PathElement.pathElement(DEPLOYMENT, name)); if (remoteRepository != null) { // Make sure we have a copy of the deployment in the local repo for (ModelNode content : deploymentContent.asList()) { if ((content.hasDefined(HASH))) { byte[] hash = content.require(HASH).asBytes(); ContentReference reference = ModelContentReference.fromModelAddress(addr, hash); File[] files = domainController.getLocalFileRepository().getDeploymentFiles(reference); if (files == null || files.length == 0) { remoteRepository.getDeploymentFiles(reference); } } } } ModelNode addOp = Util.getEmptyOperation(ADD, addr.toModelNode()); addOp.get(RUNTIME_NAME).set(details.get(RUNTIME_NAME)); addOp.get(CONTENT).set(deploymentContent); if (!details.hasDefined(ENABLED)) { addOp.get(ENABLED).set(true); // TODO this seems wrong } else { addOp.get(ENABLED).set(details.get(ENABLED)); } updates.add(addOp); } } }