void parseSocketBindingGroup_1_1( final XMLExtendedStreamReader reader, final Set<String> interfaces, final ModelNode address, final Namespace expectedNs, final List<ModelNode> updates) throws XMLStreamException { final Set<String> includedGroups = new HashSet<String>(); // both outbound-socket-bindings and socket-binding names final Set<String> uniqueBindingNames = new HashSet<String>(); // Handle attributes final String[] attrValues = requireAttributes( reader, Attribute.NAME.getLocalName(), Attribute.DEFAULT_INTERFACE.getLocalName()); final String socketBindingGroupName = attrValues[0]; final String defaultInterface = attrValues[1]; final ModelNode groupAddress = new ModelNode().set(address); groupAddress.add(SOCKET_BINDING_GROUP, socketBindingGroupName); final ModelNode bindingGroupUpdate = new ModelNode(); bindingGroupUpdate.get(OP_ADDR).set(groupAddress); bindingGroupUpdate.get(OP).set(ADD); SocketBindingGroupResourceDefinition.DEFAULT_INTERFACE.parseAndSetParameter( defaultInterface, bindingGroupUpdate, reader); if (bindingGroupUpdate .get(SocketBindingGroupResourceDefinition.DEFAULT_INTERFACE.getName()) .getType() != ModelType.EXPRESSION && !interfaces.contains(defaultInterface)) { throw MESSAGES.unknownInterface( defaultInterface, Attribute.DEFAULT_INTERFACE.getLocalName(), Element.INTERFACES.getLocalName(), reader.getLocation()); } final ModelNode includes = bindingGroupUpdate.get(INCLUDES); includes.setEmptyList(); updates.add(bindingGroupUpdate); // Handle elements while (reader.nextTag() != END_ELEMENT) { requireNamespace(reader, expectedNs); final Element element = Element.forName(reader.getLocalName()); switch (element) { /* This will be reintroduced for 7.2.0, leave commented out case INCLUDE: { final String includedGroup = readStringAttributeElement(reader, Attribute.SOCKET_BINDING_GROUP.getLocalName()); if (!includedGroups.add(includedGroup)) { throw MESSAGES.alreadyDeclared(Attribute.SOCKET_BINDING_GROUP.getLocalName(), includedGroup, reader.getLocation()); } SocketBindingGroupResourceDefinition.INCLUDES.parseAndAddParameterElement(includedGroup, bindingGroupUpdate, reader.getLocation()); break; } */ case SOCKET_BINDING: { final String bindingName = parseSocketBinding(reader, interfaces, groupAddress, updates); if (!uniqueBindingNames.add(bindingName)) { throw MESSAGES.alreadyDeclared( Element.SOCKET_BINDING.getLocalName(), Element.OUTBOUND_SOCKET_BINDING.getLocalName(), bindingName, Element.SOCKET_BINDING_GROUP.getLocalName(), socketBindingGroupName, reader.getLocation()); } break; } case OUTBOUND_SOCKET_BINDING: { final String bindingName = parseOutboundSocketBinding(reader, interfaces, groupAddress, updates); if (!uniqueBindingNames.add(bindingName)) { throw MESSAGES.alreadyDeclared( Element.SOCKET_BINDING.getLocalName(), Element.OUTBOUND_SOCKET_BINDING.getLocalName(), bindingName, Element.SOCKET_BINDING_GROUP.getLocalName(), socketBindingGroupName, reader.getLocation()); } break; } default: throw unexpectedElement(reader); } } }
private void parseSocketBindingGroup( final XMLExtendedStreamReader reader, final Set<String> interfaces, final ModelNode address, final Namespace expectedNs, final List<ModelNode> updates) throws XMLStreamException { // unique names for both socket-binding and outbound-socket-binding(s) final Set<String> uniqueBindingNames = new HashSet<String>(); ModelNode op = Util.getEmptyOperation(ADD, null); // Handle attributes String socketBindingGroupName = null; final EnumSet<Attribute> required = EnumSet.of(Attribute.NAME, Attribute.DEFAULT_INTERFACE); 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); } final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i)); switch (attribute) { case NAME: { socketBindingGroupName = value; required.remove(attribute); break; } case DEFAULT_INTERFACE: { SocketBindingGroupResourceDefinition.DEFAULT_INTERFACE.parseAndSetParameter( value, op, reader); required.remove(attribute); break; } case PORT_OFFSET: { SocketBindingGroupResourceDefinition.PORT_OFFSET.parseAndSetParameter( value, op, reader); break; } default: throw ParseUtils.unexpectedAttribute(reader, i); } } if (!required.isEmpty()) { throw missingRequired(reader, required); } ModelNode groupAddress = address.clone().add(SOCKET_BINDING_GROUP, socketBindingGroupName); op.get(OP_ADDR).set(groupAddress); updates.add(op); // Handle elements while (reader.nextTag() != END_ELEMENT) { requireNamespace(reader, expectedNs); final Element element = Element.forName(reader.getLocalName()); switch (element) { case SOCKET_BINDING: { // FIXME JBAS-8825 final String bindingName = parseSocketBinding(reader, interfaces, groupAddress, updates); if (!uniqueBindingNames.add(bindingName)) { throw ControllerLogger.ROOT_LOGGER.alreadyDeclared( Element.SOCKET_BINDING.getLocalName(), Element.OUTBOUND_SOCKET_BINDING.getLocalName(), bindingName, Element.SOCKET_BINDING_GROUP.getLocalName(), socketBindingGroupName, reader.getLocation()); } break; } case OUTBOUND_SOCKET_BINDING: { final String bindingName = parseOutboundSocketBinding(reader, interfaces, groupAddress, updates); if (!uniqueBindingNames.add(bindingName)) { throw ControllerLogger.ROOT_LOGGER.alreadyDeclared( Element.SOCKET_BINDING.getLocalName(), Element.OUTBOUND_SOCKET_BINDING.getLocalName(), bindingName, Element.SOCKET_BINDING_GROUP.getLocalName(), socketBindingGroupName, reader.getLocation()); } break; } default: throw unexpectedElement(reader); } } }