/** * Creates an add operation using the specified address and parameters * @param address a path address * @param parameters a map of values per attribute * @return an add operation */ public static ModelNode createAddOperation(PathAddress address, Map<Attribute, ModelNode> parameters) { ModelNode operation = Util.createAddOperation(address); for (Map.Entry<Attribute, ModelNode> entry : parameters.entrySet()) { operation.get(entry.getKey().getName()).set(entry.getValue()); } return operation; }
protected void parseRemote(final XMLExtendedStreamReader reader, List<ModelNode> operations) throws XMLStreamException { final int count = reader.getAttributeCount(); ModelNode operation = Util.createAddOperation(SUBSYSTEM_PATH.append(SERVICE, REMOTE)); final EnumSet<EJB3SubsystemXMLAttribute> required = EnumSet.of(EJB3SubsystemXMLAttribute.CONNECTOR_REF, EJB3SubsystemXMLAttribute.THREAD_POOL_NAME); for (int i = 0; i < count; i++) { requireNoNamespaceAttribute(reader, i); final String value = reader.getAttributeValue(i); final EJB3SubsystemXMLAttribute attribute = EJB3SubsystemXMLAttribute.forName(reader.getAttributeLocalName(i)); required.remove(attribute); switch (attribute) { case CONNECTOR_REF: EJB3RemoteResourceDefinition.CONNECTOR_REF.parseAndSetParameter(value, operation, reader); break; case THREAD_POOL_NAME: EJB3RemoteResourceDefinition.THREAD_POOL_NAME.parseAndSetParameter(value, operation, reader); break; default: throw unexpectedAttribute(reader, i); } } if (!required.isEmpty()) { throw missingRequired(reader, required); } operation.get(EJB3SubsystemModel.EXECUTE_IN_WORKER).set(new ModelNode(false)); requireNoContent(reader); operations.add(operation); }
private void parseRemoteNaming(final XMLExtendedStreamReader reader, final List<ModelNode> operations, PathAddress parent) throws XMLStreamException { requireNoAttributes(reader); requireNoContent(reader); operations.add(Util.createAddOperation(parent.append(NamingSubsystemModel.SERVICE, NamingSubsystemModel.REMOTE_NAMING))); }
private void parseAsync(final XMLExtendedStreamReader reader, List<ModelNode> operations) throws XMLStreamException { final int count = reader.getAttributeCount(); //String threadPoolName = null; ModelNode operation = Util.createAddOperation(SUBSYSTEM_PATH.append(SERVICE, ASYNC)); final EnumSet<EJB3SubsystemXMLAttribute> required = EnumSet.of(EJB3SubsystemXMLAttribute.THREAD_POOL_NAME); for (int i = 0; i < count; i++) { requireNoNamespaceAttribute(reader, i); final String value = reader.getAttributeValue(i); final EJB3SubsystemXMLAttribute attribute = EJB3SubsystemXMLAttribute.forName(reader.getAttributeLocalName(i)); required.remove(attribute); switch (attribute) { case THREAD_POOL_NAME: EJB3AsyncResourceDefinition.THREAD_POOL_NAME.parseAndSetParameter(value, operation, reader); break; default: throw unexpectedAttribute(reader, i); } } if (!required.isEmpty()) { throw missingRequired(reader, required); } requireNoContent(reader); operations.add(operation); }
@Override public ModelNode transformOperation(ModelNode operation) { if (operation.hasDefined(PROPERTIES)) { final ModelNode addOperation = operation.clone(); List<Property> properties = addOperation.remove(PROPERTIES).asPropertyList(); List<ModelNode> operations = new ArrayList<>(properties.size() + 1); operations.add(addOperation); PathAddress address = this.addressResolver.apply(addOperation); for (final Property property : properties) { String key = property.getName(); ModelNode value = property.getValue(); ModelNode propertyAddOperation = Util.createAddOperation(address.append(PathElement.pathElement(PROPERTY, key))); propertyAddOperation.get(VALUE).set(value); operations.add(propertyAddOperation); } return Operations.createCompositeOperation(operations); } return operation; } }
private void parsePrefix(final XMLExtendedStreamReader reader, final ModelNode prefix, final List<ModelNode> operations) throws XMLStreamException { ParseUtils.requireAttributes(reader, Attribute.PATH.getLocalName()); String path = reader.getAttributeValue(null, Attribute.PATH.getLocalName()); PathAddress pathOpAddress = PathAddress.pathAddress(prefix.get(OP_ADDR)).append(ModelKeys.PREFIX, path); ModelNode pathOp = Util.createAddOperation(pathOpAddress); PrefixResource.PATH.parseAndSetParameter(path, pathOp, reader); ParseUtils.requireNoContent(reader); operations.add(pathOp); }
private void parseOffHeapMemory(XMLExtendedStreamReader reader, PathAddress cacheAddress, Map<PathAddress, ModelNode> operations) throws XMLStreamException { PathAddress address = cacheAddress.append(OffHeapMemoryResourceDefinition.PATH); ModelNode operation = Util.createAddOperation(address); operations.put(address, operation); for (int i = 0; i < reader.getAttributeCount(); i++) { XMLAttribute attribute = XMLAttribute.forName(reader.getAttributeLocalName(i)); switch (attribute) { case CAPACITY: { readAttribute(reader, i, operation, OffHeapMemoryResourceDefinition.Attribute.CAPACITY); break; } default: { this.parseBinaryMemoryAttribute(reader, i, operation); } } } ParseUtils.requireNoContent(reader); }
private void parseSimpleElectionPolicy(XMLExtendedStreamReader reader, PathAddress policyAddress, Map<PathAddress, ModelNode> operations) throws XMLStreamException { PathAddress address = policyAddress.append(SimpleElectionPolicyResourceDefinition.PATH); ModelNode operation = Util.createAddOperation(address); operations.put(address, operation); for (int i = 0; i < reader.getAttributeCount(); ++i) { XMLAttribute attribute = XMLAttribute.forName(reader, i); switch (attribute) { case POSITION: { readAttribute(reader, i, operation, SimpleElectionPolicyResourceDefinition.Attribute.POSITION); break; } default: { throw ParseUtils.unexpectedAttribute(reader, i); } } } this.parsePreferences(reader, operation); }
private void parseLookupBinding(final XMLExtendedStreamReader reader, List<ModelNode> operations, PathAddress parentAddress) throws XMLStreamException { final int attCount = reader.getAttributeCount(); String name = null; final ModelNode bindingAdd = Util.createAddOperation(); bindingAdd.get(BINDING_TYPE).set(LOOKUP); final EnumSet<NamingSubsystemXMLAttribute> required = EnumSet.of(NamingSubsystemXMLAttribute.NAME, NamingSubsystemXMLAttribute.LOOKUP); for (int i = 0; i < attCount; i++) { requireNoNamespaceAttribute(reader, i); final String value = reader.getAttributeValue(i); final NamingSubsystemXMLAttribute attribute = NamingSubsystemXMLAttribute.forName(reader.getAttributeLocalName(i)); required.remove(attribute); switch (attribute) { break; default: throw unexpectedAttribute(reader, i); bindingAdd.get(OP_ADDR).set(parentAddress.append(BINDING, name).toModelNode()); operations.add(bindingAdd);
private void parseRemoteCacheContainerSecurity(XMLExtendedStreamReader reader, PathAddress cacheAddress, Map<PathAddress, ModelNode> operations) throws XMLStreamException { PathAddress address = cacheAddress.append(SecurityResourceDefinition.PATH); ModelNode operation = Util.createAddOperation(address); operations.put(address, operation); for (int i = 0; i < reader.getAttributeCount(); i++) { XMLAttribute attribute = XMLAttribute.forName(reader.getAttributeLocalName(i)); switch (attribute) { case SSL_CONTEXT: { readAttribute(reader, i, operation, SecurityResourceDefinition.Attribute.SSL_CONTEXT); break; } default: { throw ParseUtils.unexpectedAttribute(reader, i); } } } ParseUtils.requireNoContent(reader); }
/** {@inheritDoc} */ @Override public void readElement(final XMLExtendedStreamReader reader, final List<ModelNode> list) throws XMLStreamException { // Require no attributes or content requireNoAttributes(reader); requireNoContent(reader); list.add(Util.createAddOperation(PathAddress.pathAddress(WeldExtension.PATH_SUBSYSTEM))); } }
@Override public TransformedOperation transformOperation(TransformationContext context, PathAddress address, ModelNode operation) throws OperationFailedException { if (operation.get(NAME).asString().equals(PROPERTIES)) { ModelNode newValue = context.readResourceFromRoot(resolvedAddress).getModel().get(PROPERTIES).clone(); ModelNode addOp = Util.createAddOperation(legacyAddress.append(PathElement.pathElement(PROPERTY, key))); addOp.get(VALUE).set(value); operations.add(addOp); } else { final ModelNode oldPropValue = oldMap.get(key); operations.add(writeOp); operations.add(removeOperation); initialValue.set(newValue.clone());
/** * Creates an indexed add operation using the specified address and parameters * @param address a path address * @param parameters a map of values per attribute * @return an add operation */ public static ModelNode createAddOperation(PathAddress address, int index, Map<Attribute, ModelNode> parameters) { ModelNode operation = Util.createAddOperation(address); operation.get(ModelDescriptionConstants.ADD_INDEX).set(index); for (Map.Entry<Attribute, ModelNode> entry : parameters.entrySet()) { operation.get(entry.getKey().getName()).set(entry.getValue()); } return operation; }
private void parseJDBCStoreStringTable(XMLExtendedStreamReader reader, PathAddress storeAddress, Map<PathAddress, ModelNode> operations) throws XMLStreamException { PathAddress address = storeAddress.append(StringTableResourceDefinition.PATH); ModelNode operation = Util.createAddOperation(address); operations.put(storeAddress.getParent().append(StoreResourceDefinition.WILDCARD_PATH).append(StringTableResourceDefinition.PATH), operation); for (int i = 0; i < reader.getAttributeCount(); i++) { XMLAttribute attribute = XMLAttribute.forName(reader.getAttributeLocalName(i)); switch (attribute) { case PREFIX: { readAttribute(reader, i, operation, StringTableResourceDefinition.Attribute.PREFIX); break; } default: { this.parseJDBCStoreTableAttribute(reader, i, operation); } } } this.parseJDBCStoreTableElements(reader, operation); }
private void parseLookupBinding(final XMLExtendedStreamReader reader, List<ModelNode> operations, PathAddress parentAddress) throws XMLStreamException { final int attCount = reader.getAttributeCount(); String name = null; final ModelNode bindingAdd = Util.createAddOperation(); bindingAdd.get(BINDING_TYPE).set(LOOKUP); final EnumSet<NamingSubsystemXMLAttribute> required = EnumSet.of(NamingSubsystemXMLAttribute.NAME, NamingSubsystemXMLAttribute.LOOKUP); for (int i = 0; i < attCount; i++) { requireNoNamespaceAttribute(reader, i); final String value = reader.getAttributeValue(i); final NamingSubsystemXMLAttribute attribute = NamingSubsystemXMLAttribute.forName(reader.getAttributeLocalName(i)); required.remove(attribute); switch (attribute) { break; default: throw unexpectedAttribute(reader, i); bindingAdd.get(OP_ADDR).set(parentAddress.append(BINDING, name).toModelNode()); operations.add(bindingAdd);
private List<ModelNode> parseJuddiServer(XMLExtendedStreamReader reader, PathAddress parent) throws XMLStreamException { List<ModelNode> result = new ArrayList<ModelNode>(); Set<Attribute> required = EnumSet.of(Attribute.PUBLISH_URL, Attribute.QUERY_URL); int count = reader.getAttributeCount(); for (int i = 0; i < count; i++) { requireNoNamespaceAttribute(reader, i); final String attrValue = reader.getAttributeValue(i); final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i)); required.remove(attribute); switch (attribute) { case PUBLISH_URL: { ModelNode propOp = Util.createAddOperation(parent.append(ModelDescriptionConstants.PROPERTY, "javax.xml.registry.lifeCycleManagerURL")); VALUE.parseAndSetParameter(attrValue, propOp, reader); result.add(propOp); break; } case QUERY_URL: { ModelNode propOp = Util.createAddOperation(parent.append(ModelDescriptionConstants.PROPERTY, "javax.xml.registry.queryManagerURL")); VALUE.parseAndSetParameter(attrValue, propOp, reader); result.add(propOp); break; } default: throw unexpectedAttribute(reader, i); } } if (required.size() > 0) { throw missingRequired(reader, required); } requireNoContent(reader); return result; }
private void parseAuthentication(List<ModelNode> list, PathAddress parentAddress, XMLExtendedStreamReader reader) throws XMLStreamException { requireNoAttributes(reader); PathAddress address = parentAddress.append(AUTHENTICATION, CLASSIC); ModelNode op = Util.createAddOperation(address); list.add(op); parseLoginModules(reader, address, list); }
final ModelNode eeSubSystem = Util.createAddOperation(PathAddress.pathAddress(EeExtension.PATH_SUBSYSTEM)); list.add(eeSubSystem); case GLOBAL_MODULES: { final ModelNode model = parseGlobalModules(reader); eeSubSystem.get(GlobalModulesDefinition.GLOBAL_MODULES).set(model); break;
private void addOpenjdkSubsystem(final PathAddress address, final ModelNode model, final Map<PathAddress, ModelNode> migrateOperations) { final ModelNode operation = Util.createAddOperation(address); for (final Property property : model.asPropertyList()) { if (property.getValue().isDefined()) { operation.get(property.getName()).set(property.getValue()); } } migrateOperations.put(address, operation); }
private void parseJDBCStoreBinaryTable(XMLExtendedStreamReader reader, PathAddress storeAddress, Map<PathAddress, ModelNode> operations) throws XMLStreamException { PathAddress address = storeAddress.append(BinaryTableResourceDefinition.PATH); ModelNode operation = Util.createAddOperation(address); operations.put(storeAddress.getParent().append(StoreResourceDefinition.WILDCARD_PATH).append(BinaryTableResourceDefinition.PATH), operation); for (int i = 0; i < reader.getAttributeCount(); i++) { XMLAttribute attribute = XMLAttribute.forName(reader.getAttributeLocalName(i)); switch (attribute) { case PREFIX: { readAttribute(reader, i, operation, BinaryTableResourceDefinition.Attribute.PREFIX); break; } default: { this.parseJDBCStoreTableAttribute(reader, i, operation); } } } this.parseJDBCStoreTableElements(reader, operation); }