/* * #%L * Gravia :: Container :: WildFly :: Extension * %% * Copyright (C) 2010 - 2014 JBoss by Red Hat * %% * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * #L% */ package org.wildfly.extension.gravia.parser; import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.ADD; import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP; import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP_ADDR; import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.SUBSYSTEM; import static org.jboss.as.controller.parsing.ParseUtils.unexpectedElement; import java.util.List; import javax.xml.stream.XMLStreamConstants; import javax.xml.stream.XMLStreamException; import org.jboss.dmr.ModelNode; import org.jboss.staxmapper.XMLElementReader; import org.jboss.staxmapper.XMLExtendedStreamReader; /** * Parse Gravia subsystem configuration * * @author Thomas.Diesler@jboss.com * @since 23-Aug-2013 */ final class GraviaSubsystemParser implements Namespace10, XMLStreamConstants, XMLElementReader<List<ModelNode>> { static XMLElementReader<List<ModelNode>> INSTANCE = new GraviaSubsystemParser(); // hide ctor private GraviaSubsystemParser() { } @Override public void readElement(XMLExtendedStreamReader reader, List<ModelNode> operations) throws XMLStreamException { ModelNode address = new ModelNode(); address.add(SUBSYSTEM, GraviaExtension.SUBSYSTEM_NAME); address.protect(); ModelNode subsystemAdd = new ModelNode(); subsystemAdd.get(OP).set(ADD); subsystemAdd.get(OP_ADDR).set(address); operations.add(subsystemAdd); while (reader.hasNext() && reader.nextTag() != END_ELEMENT) { switch (Namespace.forUri(reader.getNamespaceURI())) { case VERSION_1_0: { final Element element = Element.forName(reader.getLocalName()); switch (element) { default: throw unexpectedElement(reader); } } default: continue; } } } }