org.jboss.staxmapper.XMLElementReader Java Examples

The following examples show how to use org.jboss.staxmapper.XMLElementReader. 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: RuntimeServer.java    From ARCHIVE-wildfly-swarm with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
private void configureFractionsFromXML(Container container, List<ModelNode> operationList) throws Exception {

    StandaloneXmlParser parser = new StandaloneXmlParser();

    FractionProcessor<StandaloneXmlParser> consumer = (p, cfg, fraction) -> {
        try {
            if (cfg.getSubsystemParsers().isPresent()) {
                Map<QName, XMLElementReader<List<ModelNode>>> fractionParsers =
                        (Map<QName, XMLElementReader<List<ModelNode>>>) cfg.getSubsystemParsers().get();

                fractionParsers.forEach(p::addDelegate);
            }
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    };

    // collect parsers
    visitFractions(container, parser, consumer);

    // parse the configurations
    List<ModelNode> parseResult = parser.parse(xmlConfig.get());
    operationList.addAll(parseResult);

}
 
Example #2
Source File: GitConfigurationPersister.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
public GitConfigurationPersister(GitRepository gitRepository, ConfigurationFile file, QName rootElement, XMLElementReader<List<ModelNode>> rootParser,
        XMLElementWriter<ModelMarshallingContext> rootDeparser, boolean suppressLoad) {
    super(file.getBootFile(), rootElement, rootParser, rootDeparser, suppressLoad);
    root = file.getConfigurationDir().getParentFile().toPath();
    mainFile = file.getMainFile();
    this.gitRepository = gitRepository;
    File baseDir = root.toFile();
    try {
        File gitDir = new File(baseDir, Constants.DOT_GIT);
        if(!gitDir.exists()) {
            gitDir.mkdir();
        }
        if (gitRepository.isBare()) {
            Git.init().setDirectory(baseDir).setGitDir(gitDir).call();
            ServerLogger.ROOT_LOGGER.gitRespositoryInitialized(baseDir.getAbsolutePath());
        }
    } catch (IllegalStateException | GitAPIException e) {
        ControllerLogger.ROOT_LOGGER.error(e);
    }
}
 
Example #3
Source File: ExtensionRegistry.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Override
public void setSubsystemXmlMapping(String subsystemName, String namespaceUri, Supplier<XMLElementReader<List<ModelNode>>> supplier){
    assert subsystemName != null : "subsystemName is null";
    assert namespaceUri != null : "namespaceUri is null";
    synchronized (extension) {
        extension.getSubsystemInfo(subsystemName).addParsingNamespace(namespaceUri);
        if (extension.xmlMapper != null) {
            extension.xmlMapper.registerRootElement(new QName(namespaceUri, SUBSYSTEM), supplier);
            if (!hasNonSupplierParser) {
                if (latestNamespace == null || latestNamespace.compareTo(namespaceUri) < 0) {
                    latestNamespace = namespaceUri;
                    latestSupplier = supplier;
                }
            }
        }
    }
}
 
Example #4
Source File: JAXRSParserFactory.java    From ARCHIVE-wildfly-swarm with Apache License 2.0 5 votes vote down vote up
@Override
public Map<QName, XMLElementReader<List<ModelNode>>> create() {
    ParsingContext ctx = new ParsingContext();
    JaxrsExtension ext = new JaxrsExtension();
    ext.initializeParsers(ctx);
    return ctx.getParser();

}
 
Example #5
Source File: IOParserFactory.java    From ARCHIVE-wildfly-swarm with Apache License 2.0 5 votes vote down vote up
@Override
public Map<QName, XMLElementReader<List<ModelNode>>> create() {
    ParsingContext ctx = new ParsingContext();
    IOExtension ext = new IOExtension();
    ext.initializeParsers(ctx);
    return ctx.getParser();
}
 
Example #6
Source File: AbstractMgmtTestBase.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
public static List<ModelNode> xmlToModelOperations(String xml, String nameSpaceUriString, XMLElementReader<List<ModelNode>> parser) throws Exception {
    XMLMapper mapper = XMLMapper.Factory.create();
    mapper.registerRootElement(new QName(nameSpaceUriString, "subsystem"), parser);

    StringReader strReader = new StringReader(xml);

    XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(new StreamSource(strReader));
    List<ModelNode> newList = new ArrayList<ModelNode>();
    mapper.parseDocument(newList, reader);

    return newList;
}
 
Example #7
Source File: TestExtension.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void initializeParsers(ExtensionParsingContext context) {
    context.setSubsystemXmlMapping(SUBSYSTEM_NAME, "urn:jboss:domain:test-extension:1.0", new XMLElementReader<List<ModelNode>>() {

        @Override
        public void readElement(XMLExtendedStreamReader reader, List<ModelNode> value) throws XMLStreamException {
        }
    });
}
 
Example #8
Source File: AbstractParserFactory.java    From ARCHIVE-wildfly-swarm with Apache License 2.0 5 votes vote down vote up
/**
 * Parsers retain the namespace, but the local part becomes 'subsystem'
 *
 * @param factory the factory producing the parsers
 * @return
 */
public static Optional<Map<QName, XMLElementReader<List<ModelNode>>>> mapParserNamespaces(AbstractParserFactory factory) {
    Map<QName, XMLElementReader<List<ModelNode>>> result =
            factory.create().entrySet()
                    .stream()
                    .collect(Collectors.toMap(
                            e -> new QName(e.getKey().getNamespaceURI(), SUBSYSTEM),
                            e -> e.getValue()
                    ));

    return Optional.of(result);
}
 
Example #9
Source File: UndertowParserFactory.java    From ARCHIVE-wildfly-swarm with Apache License 2.0 5 votes vote down vote up
@Override
public Map<QName, XMLElementReader<List<ModelNode>>> create() {
    ParsingContext ctx = new ParsingContext();
    UndertowExtension ext = new UndertowExtension();
    ext.initializeParsers(ctx);
    return ctx.getParser();
}
 
Example #10
Source File: JCAParserFactory.java    From ARCHIVE-wildfly-swarm with Apache License 2.0 5 votes vote down vote up
@Override
public Map<QName, XMLElementReader<List<ModelNode>>> create() {
    ParsingContext ctx = new ParsingContext();
    JcaExtension ext = new JcaExtension();
    ext.initializeParsers(ctx);
    return ctx.getParser();
}
 
Example #11
Source File: ExtensionRegistry.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void setSubsystemXmlMapping(String subsystemName, String namespaceUri, XMLElementReader<List<ModelNode>> reader) {
    assert subsystemName != null : "subsystemName is null";
    assert namespaceUri != null : "namespaceUri is null";
    synchronized (extension) {
        extension.getSubsystemInfo(subsystemName).addParsingNamespace(namespaceUri);
        if (extension.xmlMapper != null) {
            extension.xmlMapper.registerRootElement(new QName(namespaceUri, SUBSYSTEM), reader);
            preCacheParserDescription(reader);
            hasNonSupplierParser = true;
        }
    }
}
 
Example #12
Source File: RemotingParserFactory.java    From ARCHIVE-wildfly-swarm with Apache License 2.0 5 votes vote down vote up
@Override
public Map<QName, XMLElementReader<List<ModelNode>>> create() {
    ParsingContext ctx = new ParsingContext();
    RemotingExtension ext = new RemotingExtension();
    ext.initializeParsers(ctx);
    return ctx.getParser();
}
 
Example #13
Source File: ExtensionRegistry.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private void preCacheParserDescription(XMLElementReader<List<ModelNode>> reader) {
    if (ExtensionRegistry.this.processType != ProcessType.DOMAIN_SERVER
            && reader instanceof PersistentResourceXMLParser) {
        // In a standard WildFly boot this method is being called as part of concurrent
        // work on multiple extensions. Generating the PersistentResourceXMLDescription
        // used by PersistentResourceXMLParser involves a lot of classloading and static
        // field initialization that can benefit by being done as part of this concurrent
        // work instead of being deferred to the single-threaded parsing phase. So, we ask
        // the parser to generate and cache that description for later use during parsing.
        //noinspection deprecation
        ((PersistentResourceXMLParser) reader).cacheXMLDescription();
    }
}
 
Example #14
Source File: LoggingParserFactory.java    From ARCHIVE-wildfly-swarm with Apache License 2.0 5 votes vote down vote up
public Map<QName, XMLElementReader<List<ModelNode>>> create() {

        ParsingContext ctx = new ParsingContext();
        LoggingExtension ext = new LoggingExtension();
        ext.initializeParsers(ctx);
        return ctx.getParser();
    }
 
Example #15
Source File: NamingParserFactory.java    From ARCHIVE-wildfly-swarm with Apache License 2.0 5 votes vote down vote up
@Override
public Map<QName, XMLElementReader<List<ModelNode>>> create() {
    ParsingContext ctx = new ParsingContext();
    NamingExtension ext = new NamingExtension();
    ext.initializeParsers(ctx);
    return ctx.getParser();
}
 
Example #16
Source File: DatasourceParserFactory.java    From ARCHIVE-wildfly-swarm with Apache License 2.0 5 votes vote down vote up
@Override
public Map<QName, XMLElementReader<List<ModelNode>>> create() {
    ParsingContext ctx = new ParsingContext();
    DataSourcesExtension ext = new DataSourcesExtension();
    ext.initializeParsers(ctx);
    return ctx.getParser();
}
 
Example #17
Source File: XmlConfigurationPersister.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Construct a new instance.
 *
 * @param fileName the configuration base file name
 * @param rootElement the root element of the configuration file
 * @param rootParser the root model parser
 * @param rootDeparser the root model deparser
 */
public XmlConfigurationPersister(final File fileName, final QName rootElement, final XMLElementReader<List<ModelNode>> rootParser,
                                 final XMLElementWriter<ModelMarshallingContext> rootDeparser, final boolean suppressLoad) {
    super(rootDeparser);
    this.fileName = fileName;
    this.rootElement = rootElement;
    this.rootParser = rootParser;
    this.additionalParsers = new HashMap<QName, XMLElementReader<List<ModelNode>>>();
    this.suppressLoad = suppressLoad;
}
 
Example #18
Source File: EEParserFactory.java    From ARCHIVE-wildfly-swarm with Apache License 2.0 5 votes vote down vote up
@Override
public Map<QName, XMLElementReader<List<ModelNode>>> create() {
    ParsingContext ctx = new ParsingContext();
    EeExtension ext = new EeExtension();
    ext.initializeParsers(ctx);
    return ctx.getParser();
}
 
Example #19
Source File: SubsystemTestDelegate.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private ExtensionRegistry cloneExtensionRegistry(AdditionalInitialization additionalInit) {
    final ExtensionRegistry clone = new ExtensionRegistry(additionalInit.getProcessType(), new RunningModeControl(additionalInit.getExtensionRegistryRunningMode()), null, null, null, RuntimeHostControllerInfoAccessor.SERVER);
    for (String extension : extensionParsingRegistry.getExtensionModuleNames()) {
        ExtensionParsingContext epc = clone.getExtensionParsingContext(extension, null);
        for (Map.Entry<String, SubsystemInformation> entry : extensionParsingRegistry.getAvailableSubsystems(extension).entrySet()) {
            for (String namespace : entry.getValue().getXMLNamespaces()) {
                epc.setSubsystemXmlMapping(entry.getKey(), namespace, (XMLElementReader) null);
            }
        }
    }

    return clone;
}
 
Example #20
Source File: SecurityParserFactory.java    From ARCHIVE-wildfly-swarm with Apache License 2.0 5 votes vote down vote up
@Override
public Map<QName, XMLElementReader<List<ModelNode>>> create() {
    ParsingContext ctx = new ParsingContext();
    SecurityExtension ext = new SecurityExtension();
    ext.initializeParsers(ctx);
    return ctx.getParser();
}
 
Example #21
Source File: ServerConfiguration.java    From ARCHIVE-wildfly-swarm with Apache License 2.0 4 votes vote down vote up
default Optional<Map<QName, XMLElementReader<List<ModelNode>>>> getSubsystemParsers() throws Exception {
    return Optional.empty();
}
 
Example #22
Source File: TestParser.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
public TestParser(TestModelType type, XMLElementReader<List<ModelNode>> reader, XMLElementWriter<ModelMarshallingContext> writer) {
    this.type = type;
    this.reader = reader;
    this.writer = writer;
}
 
Example #23
Source File: IOConfiguration.java    From ARCHIVE-wildfly-swarm with Apache License 2.0 4 votes vote down vote up
@Override
public Optional<Map<QName, XMLElementReader<List<ModelNode>>>> getSubsystemParsers() throws Exception {

    return AbstractParserFactory.mapParserNamespaces(new IOParserFactory());
}
 
Example #24
Source File: GitConfigurationPersister.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
public GitConfigurationPersister(GitRepository gitRepository, ConfigurationFile file, QName rootElement, XMLElementReader<List<ModelNode>> rootParser,
        XMLElementWriter<ModelMarshallingContext> rootDeparser) {
    this(gitRepository, file, rootElement, rootParser, rootDeparser, false);
}
 
Example #25
Source File: JBossAllXmlParserAdaptor.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
public JBossAllXmlParserAdaptor(final XMLElementReader<ParseResult> elementReader) {
    this.elementReader = elementReader;
}
 
Example #26
Source File: XmlConfigurationPersister.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
public void registerAdditionalRootElement(final QName anotherRoot, final XMLElementReader<List<ModelNode>> parser){
    synchronized (additionalParsers) {
        additionalParsers.put(anotherRoot, parser);
    }
}
 
Example #27
Source File: LoggingExtension.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
private static void setParser(final ExtensionParsingContext context, final Namespace namespace, final XMLElementReader<List<ModelNode>> parser) {
    context.setSubsystemXmlMapping(SUBSYSTEM_NAME, namespace.getUriString(), parser);
}
 
Example #28
Source File: ConfigurationPersisterFactory.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
BackupRemoteDomainXmlPersister(File file, File bootFile, QName rootElement, XMLElementReader<List<ModelNode>> rootParser, XMLElementWriter<ModelMarshallingContext> rootDeparser) {
    super(file, rootElement, rootParser, rootDeparser);
    this.bootWriter = new XmlConfigurationPersister(bootFile, rootElement, rootParser, rootDeparser);
    this.file = file;
    this.bootFile = bootFile;
}
 
Example #29
Source File: ConfigurationPersisterFactory.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Override
public void registerAdditionalRootElement(final QName anotherRoot, final XMLElementReader<List<ModelNode>> parser){
    bootWriter.registerAdditionalRootElement(anotherRoot, parser);
    super.registerAdditionalRootElement(anotherRoot, parser);
}
 
Example #30
Source File: BackupXmlConfigurationPersister.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
public void registerAdditionalRootElement(final QName anotherRoot, final XMLElementReader<List<ModelNode>> parser){
    super.registerAdditionalRootElement(anotherRoot, parser);
}