Java Code Examples for org.jboss.dmr.ModelNode#clone()
The following examples show how to use
org.jboss.dmr.ModelNode#clone() .
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: HostXml_10.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
private void parseServersAttributes(final XMLExtendedStreamReader reader, final ModelNode parentAddress, final List<ModelNode> list) throws XMLStreamException { // Handle attributes final int count = reader.getAttributeCount(); for (int i = 0; i < count; i++) { final String value = reader.getAttributeValue(i); if (!isNoNamespaceAttribute(reader, i)) { throw unexpectedAttribute(reader, i); } else { final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i)); switch (attribute) { case DIRECTORY_GROUPING: { final ModelNode address = parentAddress.clone(); list.add(Util.getWriteAttributeOperation(address, DIRECTORY_GROUPING, HostResourceDefinition.DIRECTORY_GROUPING.parse(value,reader))); break; } default: throw unexpectedAttribute(reader, i); } } } }
Example 2
Source File: AttributeTransformationRequirementChecker.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
/** * Check an attribute for expressions. * * @param node the attribute value * @return whether an expression was found or not */ private boolean checkForExpression(final ModelNode node) { if (!node.isDefined()) { return false; } final ModelNode resolved = node.clone(); if (node.getType() == ModelType.EXPRESSION || node.getType() == ModelType.STRING) { return checkForExpression(resolved.asString()); } else if (node.getType() == ModelType.OBJECT) { for (Property prop : resolved.asPropertyList()) { if(checkForExpression(prop.getValue())) { return true; } } } else if (node.getType() == ModelType.LIST) { for (ModelNode current : resolved.asList()) { if(checkForExpression(current)) { return true; } } } else if (node.getType() == ModelType.PROPERTY) { return checkForExpression(resolved.asProperty().getValue()); } return false; }
Example 3
Source File: HostXml_14.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
private void parseNativeManagementInterface(XMLExtendedStreamReader reader, ModelNode address, List<ModelNode> list) throws XMLStreamException { final ModelNode operationAddress = address.clone(); operationAddress.add(MANAGEMENT_INTERFACE, NATIVE_INTERFACE); final ModelNode addOp = Util.getEmptyOperation(ADD, operationAddress); // Handle attributes parseNativeManagementInterfaceAttributes(reader, addOp); // Handle elements while (reader.hasNext() && reader.nextTag() != END_ELEMENT) { requireNamespace(reader, namespace); final Element element = Element.forName(reader.getLocalName()); switch (element) { case SOCKET: parseNativeManagementSocket(reader, addOp); break; default: throw unexpectedElement(reader); } } list.add(addOp); }
Example 4
Source File: ManagementXml_4.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
private void parsePlugIns(final XMLExtendedStreamReader reader, final ModelNode realmAddress, final List<ModelNode> list) throws XMLStreamException { while (reader.hasNext() && reader.nextTag() != END_ELEMENT) { requireNamespace(reader, namespace); final Element element = Element.forName(reader.getLocalName()); switch (element) { case PLUG_IN: { ModelNode plugIn = new ModelNode(); plugIn.get(OP).set(ADD); String moduleValue = readStringAttributeElement(reader, Attribute.MODULE.getLocalName()); final ModelNode newAddress = realmAddress.clone(); newAddress.add(PLUG_IN, moduleValue); plugIn.get(OP_ADDR).set(newAddress); list.add(plugIn); break; } default: { throw unexpectedElement(reader); } } } }
Example 5
Source File: HostXml_7.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
private void parseNativeManagementInterface(XMLExtendedStreamReader reader, ModelNode address, List<ModelNode> list) throws XMLStreamException { final ModelNode operationAddress = address.clone(); operationAddress.add(MANAGEMENT_INTERFACE, NATIVE_INTERFACE); final ModelNode addOp = Util.getEmptyOperation(ADD, operationAddress); // Handle attributes parseNativeManagementInterfaceAttributes(reader, addOp); // Handle elements while (reader.hasNext() && reader.nextTag() != END_ELEMENT) { requireNamespace(reader, namespace); final Element element = Element.forName(reader.getLocalName()); switch (element) { case SOCKET: parseNativeManagementSocket(reader, addOp); break; default: throw unexpectedElement(reader); } } list.add(addOp); }
Example 6
Source File: StandaloneXml_8.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
private void parseNativeRemotingManagementInterface(final XMLExtendedStreamReader reader, final ModelNode address, final List<ModelNode> list) throws XMLStreamException { requireNoAttributes(reader); //requireNoContent(reader); final ModelNode connector = new ModelNode(); connector.get(OP).set(ADD); ModelNode operationAddress = address.clone(); operationAddress.add(MANAGEMENT_INTERFACE, NATIVE_REMOTING_INTERFACE); connector.get(OP_ADDR).set(operationAddress); list.add(connector); reader.discardRemainder(); }
Example 7
Source File: ChainedOperationBuilderTestCase.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
@Test public void testDefaultOperationOneInChain() throws Exception { ChainedTransformationDescriptionBuilder chainedBuilder = TransformationDescriptionBuilder.Factory.createChainedInstance(PATH, V2_0_0); chainedBuilder.createBuilder(V2_0_0, V1_0_0) .getAttributeBuilder() .addRejectCheck(RejectAttributeChecker.SIMPLE_EXPRESSIONS, "attr1") .setValueConverter(new SimpleAttributeConverter("old", "new"), "attr2"); TransformationDescription.Tools.register(chainedBuilder.build(V1_0_0).get(V1_0_0), transformersSubRegistration); final PathAddress address = PathAddress.EMPTY_ADDRESS.append(PATH); ModelNode original = new ModelNode(); original.get(OP_ADDR).set(address.toModelNode()); original.get(OP).set(ADD); original.get("attr1").set(new ValueExpression("${no.no}")); original.get("attr2").set("old"); original.get("attr3").set("whatever"); OperationTransformer.TransformedOperation op = transformOperation(original, ModelVersion.create(1)); Assert.assertTrue(op.rejectOperation(success())); ModelNode expected = original.clone(); expected.get("attr2").set("new"); assertRejectedOperation(original, expected); ModelNode originalNotRejected = original.clone(); originalNotRejected.get("attr1").set("accepted"); expected = originalNotRejected.clone(); expected.get("attr2").set("new"); assertNotRejectedOperation(originalNotRejected, expected); }
Example 8
Source File: DeploymentResult.java From wildfly-maven-plugin with GNU Lesser General Public License v2.1 | 5 votes |
/** * Creates a new deployment result based on the DMR result from the deployment operation. * * @param result the DMR result from the operation */ DeploymentResult(final ModelNode result) { successful = Operations.isSuccessfulOutcome(result); if (successful) { failureMessage = null; } else { failureMessage = Operations.getFailureDescription(result).asString(); } this.result = result.clone(); this.result.protect(); }
Example 9
Source File: StandaloneXml_11.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
private void parseHttpManagementInterface(XMLExtendedStreamReader reader, ModelNode address, List<ModelNode> list) throws XMLStreamException { final ModelNode operationAddress = address.clone(); operationAddress.add(MANAGEMENT_INTERFACE, HTTP_INTERFACE); final ModelNode addOp = Util.getEmptyOperation(ADD, operationAddress); // Handle attributes parseHttpManagementInterfaceAttributes(reader, addOp); // Handle elements while (reader.hasNext() && reader.nextTag() != END_ELEMENT) { requireNamespace(reader, namespace); final Element element = Element.forName(reader.getLocalName()); switch (element) { case SOCKET: throw ControllerLogger.ROOT_LOGGER.unsupportedElement(reader.getName(),reader.getLocation(), SOCKET_BINDING); case SOCKET_BINDING: parseHttpManagementSocketBinding(reader, addOp); break; case HTTP_UPGRADE: parseHttpUpgrade(reader, addOp); break; case CONSTANT_HEADERS: parseConstantHeaders(reader, addOp); break; default: throw unexpectedElement(reader); } } list.add(addOp); }
Example 10
Source File: InMemoryAuditLogHandlerResourceDefinition.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
@Override protected void executeRuntimeStep(OperationContext context, ModelNode operation) throws OperationFailedException { final String name = Util.getNameFromAddress(operation.require(OP_ADDR)); ModelNode result = context.getResult().setEmptyList(); List<ModelNode> items = this.auditLogger.listLastEntries(name); for (int i = (items.size() - 1); i >= 0; i--) { ModelNode entry = items.get(i); ModelNode configurationChange = entry.clone(); result.add(configurationChange); } }
Example 11
Source File: FailedOperationTransformationConfig.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
@Override public ModelNode correctWriteAttributeOperation(ModelNode operation) { ModelNode op = operation.clone(); for (AttributesPathAddressConfig<?> link : list) { op = link.correctWriteAttributeOperation(op); } return op; }
Example 12
Source File: StandaloneXml_12.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
private void parseHttpManagementInterface(XMLExtendedStreamReader reader, ModelNode address, List<ModelNode> list) throws XMLStreamException { final ModelNode operationAddress = address.clone(); operationAddress.add(MANAGEMENT_INTERFACE, HTTP_INTERFACE); final ModelNode addOp = Util.getEmptyOperation(ADD, operationAddress); // Handle attributes parseHttpManagementInterfaceAttributes(reader, addOp); // Handle elements while (reader.hasNext() && reader.nextTag() != END_ELEMENT) { requireNamespace(reader, namespace); final Element element = Element.forName(reader.getLocalName()); switch (element) { case SOCKET: throw ControllerLogger.ROOT_LOGGER.unsupportedElement(reader.getName(),reader.getLocation(), SOCKET_BINDING); case SOCKET_BINDING: parseHttpManagementSocketBinding(reader, addOp); break; case HTTP_UPGRADE: parseHttpUpgrade(reader, addOp); break; case CONSTANT_HEADERS: parseConstantHeaders(reader, addOp); break; default: throw unexpectedElement(reader); } } list.add(addOp); }
Example 13
Source File: StandaloneXml_4.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
private void parseNativeRemotingManagementInterface(final XMLExtendedStreamReader reader, final ModelNode address, final List<ModelNode> list) throws XMLStreamException { requireNoAttributes(reader); //requireNoContent(reader); final ModelNode connector = new ModelNode(); connector.get(OP).set(ADD); ModelNode operationAddress = address.clone(); operationAddress.add(MANAGEMENT_INTERFACE, NATIVE_REMOTING_INTERFACE); connector.get(OP_ADDR).set(operationAddress); list.add(connector); reader.discardRemainder(); }
Example 14
Source File: StandaloneXml_12.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
private void parseNativeRemotingManagementInterface(final XMLExtendedStreamReader reader, final ModelNode address, final List<ModelNode> list) throws XMLStreamException { requireNoAttributes(reader); //requireNoContent(reader); final ModelNode connector = new ModelNode(); connector.get(OP).set(ADD); ModelNode operationAddress = address.clone(); operationAddress.add(MANAGEMENT_INTERFACE, NATIVE_REMOTING_INTERFACE); connector.get(OP_ADDR).set(operationAddress); list.add(connector); reader.discardRemainder(); }
Example 15
Source File: HostControllerExecutionSupport.java From wildfly-core with GNU Lesser General Public License v2.1 | 4 votes |
@Override public ModelNode getFormattedDomainResult(ModelNode resultNode) { return resultNode.clone(); }
Example 16
Source File: HostXml_12.java From wildfly-core with GNU Lesser General Public License v2.1 | 4 votes |
private ModelNode parseDiscoveryOptionAttributes(final XMLExtendedStreamReader reader, final ModelNode address, final List<ModelNode> list, final Set<String> discoveryOptionNames) throws XMLStreamException { // OP_ADDR will be set after parsing the NAME attribute final ModelNode discoveryOptionAddress = address.clone(); discoveryOptionAddress.add(CORE_SERVICE, DISCOVERY_OPTIONS); final ModelNode addOp = Util.getEmptyOperation(ADD, new ModelNode()); list.add(addOp); final Set<Attribute> required = EnumSet.of(Attribute.NAME, Attribute.CODE); final int count = reader.getAttributeCount(); for (int i = 0; i < count; i++) { requireNoNamespaceAttribute(reader, i); final String value = reader.getAttributeValue(i); final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i)); required.remove(attribute); switch (attribute) { case NAME: { if (!discoveryOptionNames.add(value)) { throw ParseUtils.duplicateNamedElement(reader, value); } addOp.get(OP_ADDR).set(discoveryOptionAddress).add(DISCOVERY_OPTION, value); break; } case CODE: { DiscoveryOptionResourceDefinition.CODE.parseAndSetParameter(value, addOp, reader); break; } case MODULE: { DiscoveryOptionResourceDefinition.MODULE.parseAndSetParameter(value, addOp, reader); break; } default: throw unexpectedAttribute(reader, i); } } if (required.size() > 0) { throw missingRequired(reader, required); } return addOp; }
Example 17
Source File: BpmPlatformParser1_1.java From camunda-bpm-platform with Apache License 2.0 | 4 votes |
protected void parseProcessEngine(XMLExtendedStreamReader reader, List<ModelNode> operations, ModelNode parentAddress, List<String> discoveredEngineNames) throws XMLStreamException, ParserException { String engineName = null; //Add the 'add' operation for each 'process-engine' child ModelNode addProcessEngineOp = new ModelNode(); addProcessEngineOp.get(OP).set(ADD); for (int i = 0; i < reader.getAttributeCount(); i++) { Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i)); switch(attribute) { case NAME: { engineName = rawAttributeText(reader, NAME.getLocalName()); if (engineName != null && !engineName.equals("null")) { SubsystemAttributeDefinitons.NAME.parseAndSetParameter(engineName, addProcessEngineOp, reader); } else { throw missingRequiredElement(reader, Collections.singleton(NAME.getLocalName())); } break; } case DEFAULT: { final String value = rawAttributeText(reader, DEFAULT.getLocalName()); if (value != null) { SubsystemAttributeDefinitons.DEFAULT.parseAndSetParameter(value, addProcessEngineOp, reader); } break; } default: throw unexpectedAttribute(reader, i); } } ModelNode processEngineAddress = parentAddress.clone(); processEngineAddress.add(ModelConstants.PROCESS_ENGINES, engineName); addProcessEngineOp.get(OP_ADDR).set(processEngineAddress); if(discoveredEngineNames.contains(engineName)) { throw new ProcessEngineException("A process engine with name '" + engineName + "' already exists. The process engine name must be unique."); } else { discoveredEngineNames.add(engineName); } operations.add(addProcessEngineOp); parseAdditionalProcessEngineSettings(reader, operations, addProcessEngineOp); }
Example 18
Source File: HostXml_Legacy.java From wildfly-core with GNU Lesser General Public License v2.1 | 4 votes |
private void parseHttpManagementInterface1_0(final XMLExtendedStreamReader reader, final ModelNode address, final List<ModelNode> list) throws XMLStreamException { final ModelNode mgmtSocket = new ModelNode(); mgmtSocket.get(OP).set(ADD); ModelNode operationAddress = address.clone(); operationAddress.add(MANAGEMENT_INTERFACE, HTTP_INTERFACE); mgmtSocket.get(OP_ADDR).set(operationAddress); // Handle attributes boolean hasInterfaceName = false; final int count = reader.getAttributeCount(); for (int i = 0; i < count; i++) { if (!isNoNamespaceAttribute(reader, i)) { throw unexpectedAttribute(reader, i); } else { final String value = reader.getAttributeValue(i); final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i)); switch (attribute) { case INTERFACE: { HttpManagementResourceDefinition.INTERFACE.parseAndSetParameter(value, mgmtSocket, reader); hasInterfaceName = true; break; } case PORT: { HttpManagementResourceDefinition.HTTP_PORT.parseAndSetParameter(value, mgmtSocket, reader); break; } case SECURE_PORT: { HttpManagementResourceDefinition.HTTPS_PORT.parseAndSetParameter(value, mgmtSocket, reader); break; } case MAX_THREADS: { // ignore xsd mistake break; } case SECURITY_REALM: { HttpManagementResourceDefinition.SECURITY_REALM.parseAndSetParameter(value, mgmtSocket, reader); break; } default: throw unexpectedAttribute(reader, i); } } } requireNoContent(reader); if (!hasInterfaceName) { throw missingRequired(reader, Collections.singleton(Attribute.INTERFACE.getLocalName())); } list.add(mgmtSocket); }
Example 19
Source File: BpmPlatformParser1_1.java From camunda-bpm-platform with Apache License 2.0 | 4 votes |
protected void parseJobExecutor(XMLExtendedStreamReader reader, List<ModelNode> operations, ModelNode parentAddress) throws XMLStreamException { // Add the 'add' operation for 'job-executor' parent ModelNode addJobExecutorOp = new ModelNode(); addJobExecutorOp.get(OP).set(ADD); ModelNode jobExecutorAddress = parentAddress.clone(); jobExecutorAddress.add(ModelConstants.JOB_EXECUTOR, ModelConstants.DEFAULT); addJobExecutorOp.get(OP_ADDR).set(jobExecutorAddress); operations.add(addJobExecutorOp); // iterate deeper while (reader.hasNext()) { switch (reader.nextTag()) { case END_ELEMENT: { if (Element.forName(reader.getLocalName()) == Element.JOB_EXECUTOR) { // should mean we're done, so ignore it. return; } } case START_ELEMENT: { switch (Element.forName(reader.getLocalName())) { case JOB_AQUISITIONS: { parseJobAcquisitions(reader, operations, addJobExecutorOp); break; } case THREAD_POOL_NAME: { parseElement(SubsystemAttributeDefinitons.THREAD_POOL_NAME, addJobExecutorOp, reader); break; } case CORE_THREADS: { parseElement(SubsystemAttributeDefinitons.CORE_THREADS, addJobExecutorOp, reader); break; } case MAX_THREADS: { parseElement(SubsystemAttributeDefinitons.MAX_THREADS, addJobExecutorOp, reader); break; } case QUEUE_LENGTH: { parseElement(SubsystemAttributeDefinitons.QUEUE_LENGTH, addJobExecutorOp, reader); break; } case KEEPALIVE_TIME: { parseElement(SubsystemAttributeDefinitons.KEEPALIVE_TIME, addJobExecutorOp, reader); break; } case ALLOW_CORE_TIMEOUT: { parseElement(SubsystemAttributeDefinitons.ALLOW_CORE_TIMEOUT, addJobExecutorOp, reader); break; } default: { throw unexpectedElement(reader); } } break; } } } }
Example 20
Source File: CommandExecutor.java From wildfly-core with GNU Lesser General Public License v2.1 | 4 votes |
Response(String command, ModelNode dmrRequest, OperationResponse response) { this.command = command; this.dmrRequest = dmrRequest.clone(); this.response = response; }