org.jboss.as.controller.parsing.Namespace Java Examples

The following examples show how to use org.jboss.as.controller.parsing.Namespace. 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_4.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Override
public void readElement(final XMLExtendedStreamReader reader, final List<ModelNode> operationList)
        throws XMLStreamException {
    final ModelNode address = new ModelNode().setEmptyList();
    if (Element.forName(reader.getLocalName()) != Element.HOST) {
        throw unexpectedElement(reader);
    }

    // Instead of having to list the remaining versions we just check it is actually a valid version.
    for (Namespace current : Namespace.domainValues()) {
        if (namespace.equals(current)) {
            readHostElement(reader, address, operationList);
            return;
        }
    }
    throw unexpectedElement(reader);
}
 
Example #2
Source File: ConfigurationPersisterFactory.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
public static ExtensibleConfigurationPersister createHostXmlConfigurationPersister(final ConfigurationFile file, final HostControllerEnvironment environment,
                                                                                   final ExecutorService executorService, final ExtensionRegistry hostExtensionRegistry,
                                                                                   final LocalHostControllerInfo localHostControllerInfo) {
    String defaultHostname = localHostControllerInfo.getLocalHostName();
    if (environment.getRunningModeControl().isReloaded()) {
        if (environment.getRunningModeControl().getReloadHostName() != null) {
            defaultHostname = environment.getRunningModeControl().getReloadHostName();
        }
    }
    HostXml hostXml = new HostXml(defaultHostname, environment.getRunningModeControl().getRunningMode(),
            environment.isUseCachedDc(), Module.getBootModuleLoader(), executorService, hostExtensionRegistry);
    BackupXmlConfigurationPersister persister = new BackupXmlConfigurationPersister(file, new QName(Namespace.CURRENT.getUriString(), "host"), hostXml, hostXml, false);
    for (Namespace namespace : Namespace.domainValues()) {
        if (!namespace.equals(Namespace.CURRENT)) {
            persister.registerAdditionalRootElement(new QName(namespace.getUriString(), "host"), hostXml);
        }
    }
    hostExtensionRegistry.setWriterRegistry(persister);
    return persister;
}
 
Example #3
Source File: VaultXml.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
void parseVault(final XMLExtendedStreamReader reader, final ModelNode address, final Namespace expectedNs, final List<ModelNode> list) throws XMLStreamException {
    switch (expectedNs) {
        case DOMAIN_1_0:
            throw unexpectedElement(reader);
        case DOMAIN_1_1:
        case DOMAIN_1_2:
        case DOMAIN_1_3:
        case DOMAIN_1_4:
        case DOMAIN_1_5:
            parseVault_1_1(reader, address, expectedNs, list);
            break;
        default:
            if (expectedNs.getMajorVersion() == 2) {
                parseVault_1_1(reader, address, expectedNs, list);
            } else {
                parseVault_1_6_and_3_0(reader, address, expectedNs, list);
            }
    }
}
 
Example #4
Source File: HostXml_13.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Override
public void readElement(final XMLExtendedStreamReader reader, final List<ModelNode> operationList)
        throws XMLStreamException {
    final ModelNode address = new ModelNode().setEmptyList();
    if (Element.forName(reader.getLocalName()) != Element.HOST) {
        throw unexpectedElement(reader);
    }

    // Instead of having to list the remaining versions we just check it is actually a valid version.
    for (Namespace current : Namespace.domainValues()) {
        if (namespace.equals(current)) {
            readHostElement(reader, address, operationList);
            return;
        }
    }
    throw unexpectedElement(reader);
}
 
Example #5
Source File: HostXml_14.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Override
public void readElement(final XMLExtendedStreamReader reader, final List<ModelNode> operationList)
        throws XMLStreamException {
    final ModelNode address = new ModelNode().setEmptyList();
    if (Element.forName(reader.getLocalName()) != Element.HOST) {
        throw unexpectedElement(reader);
    }

    // Instead of having to list the remaining versions we just check it is actually a valid version.
    for (Namespace current : Namespace.domainValues()) {
        if (namespace.equals(current)) {
            readHostElement(reader, address, operationList);
            return;
        }
    }
    throw unexpectedElement(reader);
}
 
Example #6
Source File: DomainXml_Legacy.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
private void readDomainElementAttributes_1_0(XMLExtendedStreamReader reader, ModelNode address, List<ModelNode> list) throws XMLStreamException {
    final int count = reader.getAttributeCount();
    for (int i = 0; i < count; i++) {
        switch (Namespace.forUri(reader.getAttributeNamespace(i))) {
            case XML_SCHEMA_INSTANCE: {
                switch (Attribute.forName(reader.getAttributeLocalName(i))) {
                    case SCHEMA_LOCATION: {
                        parseSchemaLocations(reader, address, list, i);
                        break;
                    }
                    case NO_NAMESPACE_SCHEMA_LOCATION: {
                        // todo, jeez
                        break;
                    }
                    default: {
                        throw unexpectedAttribute(reader, i);
                    }
                }
                break;
            }
            default:
                throw unexpectedAttribute(reader, i);
        }
    }
}
 
Example #7
Source File: HostXml_7.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Override
public void readElement(final XMLExtendedStreamReader reader, final List<ModelNode> operationList)
        throws XMLStreamException {
    final ModelNode address = new ModelNode().setEmptyList();
    if (Element.forName(reader.getLocalName()) != Element.HOST) {
        throw unexpectedElement(reader);
    }

    // Instead of having to list the remaining versions we just check it is actually a valid version.
    for (Namespace current : Namespace.domainValues()) {
        if (namespace.equals(current)) {
            readHostElement(reader, address, operationList);
            return;
        }
    }
    throw unexpectedElement(reader);
}
 
Example #8
Source File: StandaloneRootResourceTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Test
public void testNoNameSetInXml() throws Exception {
    String originalXml = "<server xmlns=\"" + Namespace.CURRENT.getUriString() + "\"/>";
    KernelServices kernelServices = createKernelServicesBuilder()
            .setXml(originalXml)
            .build();
    Assert.assertTrue(kernelServices.isSuccessfulBoot());

    ModelNode read = Util.createOperation(READ_ATTRIBUTE_OPERATION, PathAddress.EMPTY_ADDRESS);
    read.get(NAME).set(NAME);
    Assert.assertEquals(getDefaultServerName(), kernelServices.executeForResult(read).asString());

    //Add and remove a system property so that some ops get executed on the model to trigger persistence, as it is there are none
    ModelNode add = Util.createAddOperation(PathAddress.pathAddress(PathElement.pathElement(ModelDescriptionConstants.SYSTEM_PROPERTY, "test")));
    add.get(VALUE).set("123");
    ModelTestUtils.checkOutcome(kernelServices.executeOperation(add));
    ModelNode remove = Util.createRemoveOperation(PathAddress.pathAddress(PathElement.pathElement(ModelDescriptionConstants.SYSTEM_PROPERTY, "test")));
    ModelTestUtils.checkOutcome(kernelServices.executeOperation(remove));

    String persistedXml = kernelServices.getPersistedSubsystemXml();
    ModelTestUtils.compareXml(originalXml, persistedXml);
}
 
Example #9
Source File: HostXml_6.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Override
public void readElement(final XMLExtendedStreamReader reader, final List<ModelNode> operationList)
        throws XMLStreamException {
    final ModelNode address = new ModelNode().setEmptyList();
    if (Element.forName(reader.getLocalName()) != Element.HOST) {
        throw unexpectedElement(reader);
    }

    // Instead of having to list the remaining versions we just check it is actually a valid version.
    for (Namespace current : Namespace.domainValues()) {
        if (namespace.equals(current)) {
            readHostElement(reader, address, operationList);
            return;
        }
    }
    throw unexpectedElement(reader);
}
 
Example #10
Source File: DomainXml_10.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
private void parseManagementClientContent(XMLExtendedStreamReader reader, ModelNode address, Namespace expectedNs, List<ModelNode> list) throws XMLStreamException {
    requireNoAttributes(reader);

    boolean rolloutPlansAdded = false;
    while (reader.nextTag() != END_ELEMENT) {
        requireNamespace(reader, expectedNs);
        Element element = Element.forName(reader.getLocalName());
        switch (element) {
            case ROLLOUT_PLANS: {
                parseRolloutPlans(reader, address, list);
                rolloutPlansAdded = true;
                break;
            }
            default: {
                throw unexpectedElement(reader);
            }
        }
    }

    if (!rolloutPlansAdded) {
        initializeRolloutPlans(address, list);
    }
}
 
Example #11
Source File: DomainXml_12.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
private void parseManagementClientContent(XMLExtendedStreamReader reader, ModelNode address, Namespace expectedNs, List<ModelNode> list) throws XMLStreamException {
    requireNoAttributes(reader);

    boolean rolloutPlansAdded = false;
    while (reader.nextTag() != END_ELEMENT) {
        requireNamespace(reader, expectedNs);
        Element element = Element.forName(reader.getLocalName());
        switch (element) {
            case ROLLOUT_PLANS: {
                parseRolloutPlans(reader, address, list);
                rolloutPlansAdded = true;
                break;
            }
            default: {
                throw unexpectedElement(reader);
            }
        }
    }

    if (!rolloutPlansAdded) {
        initializeRolloutPlans(address, list);
    }
}
 
Example #12
Source File: DomainXml_7.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
private void parseManagementClientContent(XMLExtendedStreamReader reader, ModelNode address, Namespace expectedNs, List<ModelNode> list) throws XMLStreamException {
    requireNoAttributes(reader);

    boolean rolloutPlansAdded = false;
    while (reader.nextTag() != END_ELEMENT) {
        requireNamespace(reader, expectedNs);
        Element element = Element.forName(reader.getLocalName());
        switch (element) {
            case ROLLOUT_PLANS: {
                parseRolloutPlans(reader, address, list);
                rolloutPlansAdded = true;
                break;
            }
            default: {
                throw unexpectedElement(reader);
            }
        }
    }

    if (!rolloutPlansAdded) {
        initializeRolloutPlans(address, list);
    }
}
 
Example #13
Source File: JvmXml.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
public static ModelNode parseEnvironmentVariables(final XMLExtendedStreamReader reader, final Namespace expectedNs, ModelNode addOp) throws XMLStreamException {
    final ModelNode properties = new ModelNode();
    while (reader.nextTag() != END_ELEMENT) {
        requireNamespace(reader, expectedNs);
        if (Element.forName(reader.getLocalName()) != Element.VARIABLE) {
            throw unexpectedElement(reader);
        }
        final String[] array = requireAttributes(reader, Attribute.NAME.getLocalName(), Attribute.VALUE.getLocalName());
        requireNoContent(reader);
        properties.get(array[0]).set(ParseUtils.parsePossibleExpression(array[1]));
    }

    if (!properties.isDefined()) {
        throw missingRequiredElement(reader, Collections.singleton(Element.OPTION));
    }
    addOp.get(JvmAttributes.JVM_ENV_VARIABLES).set(properties);
    return properties;
}
 
Example #14
Source File: DomainXml_5.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
private void parseManagementClientContent(XMLExtendedStreamReader reader, ModelNode address, Namespace expectedNs, List<ModelNode> list) throws XMLStreamException {
    requireNoAttributes(reader);

    boolean rolloutPlansAdded = false;
    while (reader.nextTag() != END_ELEMENT) {
        requireNamespace(reader, expectedNs);
        Element element = Element.forName(reader.getLocalName());
        switch (element) {
            case ROLLOUT_PLANS: {
                parseRolloutPlans(reader, address, list);
                rolloutPlansAdded = true;
                break;
            }
            default: {
                throw unexpectedElement(reader);
            }
        }
    }

    if (!rolloutPlansAdded) {
        initializeRolloutPlans(address, list);
    }
}
 
Example #15
Source File: DeploymentOverlaysXml.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
void parseDeploymentOverlays(final XMLExtendedStreamReader reader, final Namespace namespace, final ModelNode baseAddress, final List<ModelNode> list, final boolean allowContent, final boolean allowDeployment) throws XMLStreamException {
    requireNoAttributes(reader);

    while (reader.nextTag() != END_ELEMENT) {
        requireNamespace(reader, namespace);
        final Element element = Element.forName(reader.getLocalName());

        switch (element) {
            case DEPLOYMENT_OVERLAY:
                parseDeploymentOverlay(reader, baseAddress, list, allowContent, allowDeployment);
                break;
            default:
                throw unexpectedElement(reader);
        }
    }
}
 
Example #16
Source File: PathsXml.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
void parsePaths(final XMLExtendedStreamReader reader, final ModelNode address, final Namespace expectedNs,
        final List<ModelNode> list, final boolean requirePath) throws XMLStreamException {
    final Set<String> pathNames = new HashSet<String>();
    while (reader.hasNext() && reader.nextTag() != END_ELEMENT) {
        final Element element = Element.forName(reader.getLocalName());
        requireNamespace(reader, expectedNs);

        switch (element) {
            case PATH: {
                parsePath(reader, address, list, requirePath, pathNames);
                break;
            }
            default: {
                throw unexpectedElement(reader);
            }
        }
    }
}
 
Example #17
Source File: DomainXml_6.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
private void parseManagementClientContent(XMLExtendedStreamReader reader, ModelNode address, Namespace expectedNs, List<ModelNode> list) throws XMLStreamException {
    requireNoAttributes(reader);

    boolean rolloutPlansAdded = false;
    while (reader.nextTag() != END_ELEMENT) {
        requireNamespace(reader, expectedNs);
        Element element = Element.forName(reader.getLocalName());
        switch (element) {
            case ROLLOUT_PLANS: {
                parseRolloutPlans(reader, address, list);
                rolloutPlansAdded = true;
                break;
            }
            default: {
                throw unexpectedElement(reader);
            }
        }
    }

    if (!rolloutPlansAdded) {
        initializeRolloutPlans(address, list);
    }
}
 
Example #18
Source File: BootstrapPersister.java    From thorntail with Apache License 2.0 6 votes vote down vote up
private XmlConfigurationPersister createDelegate(File configFile) {

        QName rootElement = new QName(Namespace.CURRENT.getUriString(), "server");
        ExtensionRegistry extensionRegistry = new ExtensionRegistry(
                ProcessType.SELF_CONTAINED,
                new RunningModeControl(RunningMode.NORMAL),
                null,
                null,
                null,
                RuntimeHostControllerInfoAccessor.SERVER
        );
        StandaloneXml parser = new StandaloneXml(Module.getBootModuleLoader(), Executors.newSingleThreadExecutor(), extensionRegistry);

        XmlConfigurationPersister persister = new XmlConfigurationPersister(
                configFile, rootElement, parser, parser, false
        );

        return persister;

    }
 
Example #19
Source File: StandaloneXmlParser.java    From ARCHIVE-wildfly-swarm with Apache License 2.0 6 votes vote down vote up
public StandaloneXmlParser() {

        parserDelegate = new StandaloneXml(new ExtensionHandler() {
            @Override
            public void parseExtensions(XMLExtendedStreamReader reader, ModelNode address, Namespace namespace, List<ModelNode> list) throws XMLStreamException {
                reader.discardRemainder(); // noop
            }

            @Override
            public Set<ProfileParsingCompletionHandler> getProfileParsingCompletionHandlers() {
                return Collections.EMPTY_SET;
            }

            @Override
            public void writeExtensions(XMLExtendedStreamWriter writer, ModelNode modelNode) throws XMLStreamException {
                // noop
            }
        }, ParsingOption.IGNORE_SUBSYSTEM_FAILURES);

        xmlMapper = XMLMapper.Factory.create();
        xmlMapper.registerRootElement(new QName("urn:jboss:domain:4.0", "server"), parserDelegate);

    }
 
Example #20
Source File: HostXml_11.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
HostXml_11(String defaultHostControllerName, RunningMode runningMode, boolean isCachedDC,
           final ExtensionRegistry extensionRegistry, final ExtensionXml extensionXml, final Namespace namespace) {
    super(new SocketBindingsXml.HostSocketBindingsXml());
    this.auditLogDelegate = AuditLogXml.newInstance(namespace, true);
    this.defaultHostControllerName = defaultHostControllerName;
    this.runningMode = runningMode;
    this.isCachedDc = isCachedDC;
    this.extensionRegistry = extensionRegistry;
    this.extensionXml = extensionXml;
    this.namespace = namespace;
}
 
Example #21
Source File: HostXml_13.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
HostXml_13(String defaultHostControllerName, RunningMode runningMode, boolean isCachedDC,
           final ExtensionRegistry extensionRegistry, final ExtensionXml extensionXml, final Namespace namespace) {
    super(new SocketBindingsXml.HostSocketBindingsXml());
    this.auditLogDelegate = AuditLogXml.newInstance(namespace, true);
    this.defaultHostControllerName = defaultHostControllerName;
    this.runningMode = runningMode;
    this.isCachedDc = isCachedDC;
    this.extensionRegistry = extensionRegistry;
    this.extensionXml = extensionXml;
    this.namespace = namespace;
}
 
Example #22
Source File: DomainXml_6.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void readElement(final XMLExtendedStreamReader reader, final List<ModelNode> nodes) throws XMLStreamException {
    if (Element.forName(reader.getLocalName()) != Element.DOMAIN) {
        throw unexpectedElement(reader);
    }
    // Instead of having to list the remaining versions we just check it is actually a valid version.
    for (Namespace current : Namespace.domainValues()) {
        if (namespace.equals(current)) {
            readDomainElement(reader, new ModelNode(), nodes);
            return;
        }
    }
    throw unexpectedElement(reader);
}
 
Example #23
Source File: DomainXml_6.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
DomainXml_6(final ExtensionXml extensionXml, final ExtensionRegistry extensionRegistry, final Namespace namespace) {
    super(new DomainSocketBindingsXml());
    accessControlXml = AccessControlXml.newInstance(namespace);
    this.extensionXml = extensionXml;
    this.extensionRegistry = extensionRegistry;
    this.namespace = namespace;
}
 
Example #24
Source File: HostXml_5.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
HostXml_5(String defaultHostControllerName, RunningMode runningMode, boolean isCachedDC,
        final ExtensionRegistry extensionRegistry, final ExtensionXml extensionXml, final Namespace namespace) {
    super(new SocketBindingsXml.HostSocketBindingsXml());
    this.auditLogDelegate = AuditLogXml.newInstance(namespace, true);
    this.defaultHostControllerName = defaultHostControllerName;
    this.runningMode = runningMode;
    this.isCachedDc = isCachedDC;
    this.extensionRegistry = extensionRegistry;
    this.extensionXml = extensionXml;
    this.namespace = namespace;
}
 
Example #25
Source File: HostXml_10.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
HostXml_10(String defaultHostControllerName, RunningMode runningMode, boolean isCachedDC,
           final ExtensionRegistry extensionRegistry, final ExtensionXml extensionXml, final Namespace namespace) {
    super(new SocketBindingsXml.HostSocketBindingsXml());
    this.auditLogDelegate = AuditLogXml.newInstance(namespace, true);
    this.defaultHostControllerName = defaultHostControllerName;
    this.runningMode = runningMode;
    this.isCachedDc = isCachedDC;
    this.extensionRegistry = extensionRegistry;
    this.extensionXml = extensionXml;
    this.namespace = namespace;
}
 
Example #26
Source File: DomainXml_13.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void readElement(final XMLExtendedStreamReader reader, final List<ModelNode> nodes) throws XMLStreamException {
    if (Element.forName(reader.getLocalName()) != Element.DOMAIN) {
        throw unexpectedElement(reader);
    }
    // Instead of having to list the remaining versions we just check it is actually a valid version.
    for (Namespace current : Namespace.domainValues()) {
        if (namespace.equals(current)) {
            readDomainElement(reader, new ModelNode(), nodes);
            return;
        }
    }
    throw unexpectedElement(reader);
}
 
Example #27
Source File: StandaloneXml_13.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void readElement(final XMLExtendedStreamReader reader, final List<ModelNode> operationList)
        throws XMLStreamException {

    long start = System.currentTimeMillis();
    final ModelNode address = new ModelNode().setEmptyList();

    if (Element.forName(reader.getLocalName()) != Element.SERVER) {
        throw unexpectedElement(reader);
    }

    boolean validNamespace = false;
    for (Namespace current : Namespace.domainValues()) {
        if (namespace.equals(current)) {
            validNamespace = true;
            readServerElement(reader, address, operationList);
            break;
        }
    }
    if (validNamespace == false) {
        throw unexpectedElement(reader);
    }

    if (ServerLogger.ROOT_LOGGER.isDebugEnabled()) {
        long elapsed = System.currentTimeMillis() - start;
        ServerLogger.ROOT_LOGGER.debugf("Parsed standalone configuration in [%d] ms", elapsed);
    }
}
 
Example #28
Source File: DomainXml_12.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
DomainXml_12(final ExtensionXml extensionXml, final ExtensionRegistry extensionRegistry, final Namespace namespace) {
    super(new DomainSocketBindingsXml());
    accessControlXml = AccessControlXml.newInstance(namespace);
    this.extensionXml = extensionXml;
    this.extensionRegistry = extensionRegistry;
    this.namespace = namespace;
}
 
Example #29
Source File: StandaloneXml_11.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void readElement(final XMLExtendedStreamReader reader, final List<ModelNode> operationList)
        throws XMLStreamException {

    long start = System.currentTimeMillis();
    final ModelNode address = new ModelNode().setEmptyList();

    if (Element.forName(reader.getLocalName()) != Element.SERVER) {
        throw unexpectedElement(reader);
    }

    boolean validNamespace = false;
    for (Namespace current : Namespace.domainValues()) {
        if (namespace.equals(current)) {
            validNamespace = true;
            readServerElement(reader, address, operationList);
            break;
        }
    }
    if (validNamespace == false) {
        throw unexpectedElement(reader);
    }

    if (ServerLogger.ROOT_LOGGER.isDebugEnabled()) {
        long elapsed = System.currentTimeMillis() - start;
        ServerLogger.ROOT_LOGGER.debugf("Parsed standalone configuration in [%d] ms", elapsed);
    }
}
 
Example #30
Source File: TestParser.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
public static TestParser create(ExtensionRegistry registry, XMLMapper xmlMapper, TestModelType type) {
    TestParser testParser;
    String root;
    if (type == TestModelType.STANDALONE) {
        StandaloneXml standaloneXml = new StandaloneXml(null, Executors.newCachedThreadPool(), registry);
        testParser = new TestParser(type, standaloneXml, standaloneXml);
        root = "server";
    } else if (type == TestModelType.DOMAIN) {
        DomainXml domainXml = new DomainXml(null, Executors.newCachedThreadPool(), registry);
        testParser = new TestParser(type, domainXml, domainXml);
        root = "domain";
    } else if (type == TestModelType.HOST) {
        HostXml hostXml = new HostXml("master", RunningMode.NORMAL, false, null, Executors.newCachedThreadPool(), registry);
        testParser = new TestParser(type, hostXml, hostXml);
        root = "host";
    } else {
        throw new IllegalArgumentException("Unknown type " + type);
    }


    try {
        for (Namespace ns : Namespace.ALL_NAMESPACES) {
            xmlMapper.registerRootElement(new QName(ns.getUriString(), root), testParser);
        }
    } catch (NoSuchFieldError e) {
        //7.1.2 does not have the ALL_NAMESPACES field
        xmlMapper.registerRootElement(new QName(Namespace.DOMAIN_1_0.getUriString(), root), testParser);
        xmlMapper.registerRootElement(new QName(Namespace.DOMAIN_1_1.getUriString(), root), testParser);
        xmlMapper.registerRootElement(new QName(Namespace.DOMAIN_1_2.getUriString(), root), testParser);
    }
    return testParser;
}