use of org.jboss.as.controller.parsing.ParseUtils.unexpectedElement in project wildfly by wildfly.
the class Messaging13SubsystemParser method processContext.
private void processContext(XMLExtendedStreamReader reader, ModelNode context) throws XMLStreamException {
while (reader.hasNext() && reader.nextTag() != END_ELEMENT) {
final Element element = Element.forName(reader.getLocalName());
switch(element) {
case PROPERTY:
int count = reader.getAttributeCount();
String key = null;
String value = null;
for (int n = 0; n < count; n++) {
String attrName = reader.getAttributeLocalName(n);
Attribute attribute = Attribute.forName(attrName);
switch(attribute) {
case KEY:
key = reader.getAttributeValue(n);
break;
case VALUE:
value = reader.getAttributeValue(n);
break;
default:
throw unexpectedAttribute(reader, n);
}
}
context.get(key).set(value);
ParseUtils.requireNoContent(reader);
break;
default:
throw ParseUtils.unexpectedElement(reader);
}
}
}
use of org.jboss.as.controller.parsing.ParseUtils.unexpectedElement in project wildfly by wildfly.
the class Messaging13SubsystemParser method processJmsBridge.
private void processJmsBridge(XMLExtendedStreamReader reader, ModelNode subsystemAddress, List<ModelNode> list) throws XMLStreamException {
String bridgeName = null;
String moduleName = null;
final int count = reader.getAttributeCount();
for (int n = 0; n < count; n++) {
String attrName = reader.getAttributeLocalName(n);
Attribute attribute = Attribute.forName(attrName);
switch(attribute) {
case NAME:
bridgeName = reader.getAttributeValue(n);
break;
case MODULE:
moduleName = reader.getAttributeValue(n);
break;
default:
throw unexpectedAttribute(reader, n);
}
}
if (bridgeName == null || bridgeName.length() == 0) {
bridgeName = DEFAULT;
}
final ModelNode address = subsystemAddress.clone();
address.add(JMS_BRIDGE, bridgeName);
address.protect();
final ModelNode operation = new ModelNode();
operation.get(OP).set(ADD);
operation.get(OP_ADDR).set(address);
list.add(operation);
if (moduleName != null && moduleName.length() > 0) {
JMSBridgeDefinition.MODULE.parseAndSetParameter(moduleName, operation, reader);
}
while (reader.hasNext() && reader.nextTag() != END_ELEMENT) {
final Element element = Element.forName(reader.getLocalName());
switch(element) {
case SOURCE:
case TARGET:
processJmsBridgeResource(reader, operation, element.getLocalName());
break;
case QUALITY_OF_SERVICE:
case FAILURE_RETRY_INTERVAL:
case MAX_RETRIES:
case MAX_BATCH_SIZE:
case MAX_BATCH_TIME:
case SUBSCRIPTION_NAME:
case CLIENT_ID:
case ADD_MESSAGE_ID_IN_HEADER:
handleElementText(reader, element, operation);
break;
case SELECTOR:
requireSingleAttribute(reader, CommonAttributes.STRING);
final String selector = readStringAttributeElement(reader, CommonAttributes.STRING);
SELECTOR.parseAndSetParameter(selector, operation, reader);
break;
default:
throw ParseUtils.unexpectedElement(reader);
}
}
}
use of org.jboss.as.controller.parsing.ParseUtils.unexpectedElement in project wildfly by wildfly.
the class MessagingSubsystemParser method processConnectorService.
private static void processConnectorService(XMLExtendedStreamReader reader, ModelNode address, List<ModelNode> updates) throws XMLStreamException {
requireSingleAttribute(reader, CommonAttributes.NAME);
String name = reader.getAttributeValue(0);
final ModelNode serviceAddress = address.clone().add(CommonAttributes.CONNECTOR_SERVICE, name);
final ModelNode add = org.jboss.as.controller.operations.common.Util.getEmptyOperation(ADD, serviceAddress);
updates.add(add);
EnumSet<Element> required = EnumSet.of(Element.FACTORY_CLASS);
Set<Element> seen = EnumSet.noneOf(Element.class);
while (reader.hasNext() && reader.nextTag() != END_ELEMENT) {
final Element element = Element.forName(reader.getLocalName());
if (!seen.add(element) && element != Element.PARAM) {
throw ParseUtils.duplicateNamedElement(reader, element.getLocalName());
}
required.remove(element);
switch(element) {
case FACTORY_CLASS:
{
handleElementText(reader, element, add);
break;
}
case PARAM:
{
String[] attrs = ParseUtils.requireAttributes(reader, Attribute.KEY.getLocalName(), Attribute.VALUE.getLocalName());
final String key = attrs[0];
final String value = attrs[1];
final ModelNode paramAdd = org.jboss.as.controller.operations.common.Util.getEmptyOperation(ADD, serviceAddress.clone().add(CommonAttributes.PARAM, key));
ConnectorServiceParamDefinition.VALUE.parseAndSetParameter(value, paramAdd, reader);
updates.add(paramAdd);
requireNoContent(reader);
break;
}
default:
{
throw ParseUtils.unexpectedElement(reader);
}
}
}
if (!required.isEmpty()) {
throw missingRequired(reader, required);
}
}
use of org.jboss.as.controller.parsing.ParseUtils.unexpectedElement in project wildfly by wildfly.
the class MessagingSubsystemParser method processJMSQueue.
static void processJMSQueue(final XMLExtendedStreamReader reader, ModelNode address, List<ModelNode> updates) throws XMLStreamException {
requireSingleAttribute(reader, CommonAttributes.NAME);
final String name = reader.getAttributeValue(0);
final ModelNode queue = new ModelNode();
queue.get(OP).set(ADD);
queue.get(OP_ADDR).set(address).add(JMS_QUEUE, name);
while (reader.hasNext() && reader.nextTag() != END_ELEMENT) {
final Element element = Element.forName(reader.getLocalName());
switch(element) {
case ENTRY:
{
final String entry = readStringAttributeElement(reader, CommonAttributes.NAME);
CommonAttributes.DESTINATION_ENTRIES.parseAndAddParameterElement(entry, queue, reader);
break;
}
case SELECTOR:
{
if (queue.has(SELECTOR.getName())) {
throw ParseUtils.duplicateNamedElement(reader, Element.SELECTOR.getLocalName());
}
requireSingleAttribute(reader, CommonAttributes.STRING);
final String selector = readStringAttributeElement(reader, CommonAttributes.STRING);
SELECTOR.parseAndSetParameter(selector, queue, reader);
break;
}
case DURABLE:
{
if (queue.has(DURABLE.getName())) {
throw ParseUtils.duplicateNamedElement(reader, Element.DURABLE.getLocalName());
}
handleElementText(reader, element, queue);
break;
}
default:
{
throw ParseUtils.unexpectedElement(reader);
}
}
}
updates.add(queue);
}
use of org.jboss.as.controller.parsing.ParseUtils.unexpectedElement in project wildfly by wildfly.
the class MessagingSubsystemParser method processBridge.
protected void processBridge(XMLExtendedStreamReader reader, ModelNode address, List<ModelNode> updates) throws XMLStreamException {
requireSingleAttribute(reader, CommonAttributes.NAME);
String name = reader.getAttributeValue(0);
ModelNode bridgeAdd = org.jboss.as.controller.operations.common.Util.getEmptyOperation(ADD, address.clone().add(CommonAttributes.BRIDGE, name));
EnumSet<Element> required = EnumSet.of(Element.QUEUE_NAME);
Set<Element> seen = EnumSet.noneOf(Element.class);
while (reader.hasNext() && reader.nextTag() != END_ELEMENT) {
final Element element = Element.forName(reader.getLocalName());
if (!seen.add(element)) {
throw ParseUtils.duplicateNamedElement(reader, element.getLocalName());
}
required.remove(element);
switch(element) {
case QUEUE_NAME:
case HA:
case TRANSFORMER_CLASS_NAME:
case USER:
case PASSWORD:
handleElementText(reader, element, bridgeAdd);
break;
case CONFIRMATION_WINDOW_SIZE:
handleElementText(reader, element, "bridge", bridgeAdd);
break;
case FILTER:
{
String string = readStringAttributeElement(reader, CommonAttributes.STRING);
FILTER.parseAndSetParameter(string, bridgeAdd, reader);
break;
}
case RETRY_INTERVAL_MULTIPLIER:
case RETRY_INTERVAL:
// Use the "default" variant
handleElementText(reader, element, DEFAULT, bridgeAdd);
break;
case FORWARDING_ADDRESS:
case RECONNECT_ATTEMPTS:
case USE_DUPLICATE_DETECTION:
handleElementText(reader, element, "bridge", bridgeAdd);
break;
case STATIC_CONNECTORS:
checkOtherElementIsNotAlreadyDefined(reader, seen, Element.STATIC_CONNECTORS, Element.DISCOVERY_GROUP_REF);
processStaticConnectors(reader, bridgeAdd, false);
break;
case DISCOVERY_GROUP_REF:
{
checkOtherElementIsNotAlreadyDefined(reader, seen, Element.DISCOVERY_GROUP_REF, Element.STATIC_CONNECTORS);
final String groupRef = readStringAttributeElement(reader, BridgeDefinition.DISCOVERY_GROUP_NAME.getXmlName());
BridgeDefinition.DISCOVERY_GROUP_NAME.parseAndSetParameter(groupRef, bridgeAdd, reader);
break;
}
case FAILOVER_ON_SERVER_SHUTDOWN:
{
MessagingLogger.ROOT_LOGGER.deprecatedXMLElement(element.toString());
skipElementText(reader);
break;
}
default:
{
throw ParseUtils.unexpectedElement(reader);
}
}
}
checkOnlyOneOfElements(reader, seen, Element.STATIC_CONNECTORS, Element.DISCOVERY_GROUP_REF);
if (!required.isEmpty()) {
throw missingRequired(reader, required);
}
updates.add(bridgeAdd);
}
Aggregations