Skip to content

Commit

Permalink
WFLY-7751 mod_cluster XML parsers are loaded eagerly
Browse files Browse the repository at this point in the history
  • Loading branch information
rhusar committed Dec 8, 2016
1 parent 1a1e4f5 commit 56902f8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 18 deletions.
Expand Up @@ -24,7 +24,7 @@

import static org.wildfly.extension.mod_cluster.ModClusterLogger.ROOT_LOGGER;

import java.util.List;
import java.util.EnumSet;

import javax.xml.stream.XMLStreamConstants;

Expand All @@ -36,8 +36,6 @@
import org.jboss.as.controller.descriptions.StandardResourceDescriptionResolver;
import org.jboss.as.controller.parsing.ExtensionParsingContext;
import org.jboss.as.controller.registry.ManagementResourceRegistration;
import org.jboss.dmr.ModelNode;
import org.jboss.staxmapper.XMLElementReader;
import org.kohsuke.MetaInfServices;

/**
Expand Down Expand Up @@ -91,12 +89,7 @@ public void initialize(ExtensionContext context) {

@Override
public void initializeParsers(ExtensionParsingContext context) {
for (ModClusterSchema schema : ModClusterSchema.values()) {
XMLElementReader<List<ModelNode>> reader = schema.getXMLReader();
if (reader != null) {
context.setSubsystemXmlMapping(SUBSYSTEM_NAME, schema.getNamespaceUri(), schema.getXMLReader());
}
}
EnumSet.allOf(ModClusterSchema.class).forEach(schema -> context.setSubsystemXmlMapping(SUBSYSTEM_NAME, schema.getNamespaceUri(), schema.getXMLReaderSupplier()));
}

}
Expand Up @@ -27,6 +27,7 @@

import java.util.List;
import java.util.Locale;
import java.util.function.Supplier;

/**
* @author Jean-Frederic Clere
Expand All @@ -35,21 +36,21 @@
*/
public enum ModClusterSchema implements Schema<ModClusterSchema> {

MODCLUSTER_1_0(1, 0, new ModClusterSubsystemXMLReader_1_0()),
MODCLUSTER_1_1(1, 1, new ModClusterSubsystemXMLReader_1_1()),
MODCLUSTER_1_2(1, 2, new ModClusterSubsystemXMLReader_1_2()),
MODCLUSTER_2_0(2, 0, new ModClusterSubsystemXMLReader_2_0()),
MODCLUSTER_1_0(1, 0, ModClusterSubsystemXMLReader_1_0::new),
MODCLUSTER_1_1(1, 1, ModClusterSubsystemXMLReader_1_1::new),
MODCLUSTER_1_2(1, 2, ModClusterSubsystemXMLReader_1_2::new),
MODCLUSTER_2_0(2, 0, ModClusterSubsystemXMLReader_2_0::new),
;
public static final ModClusterSchema CURRENT = MODCLUSTER_2_0;

private final int major;
private final int minor;
private final XMLElementReader<List<ModelNode>> reader;
private final Supplier<XMLElementReader<List<ModelNode>>> readerSupplier;

ModClusterSchema(int major, int minor, XMLElementReader<List<ModelNode>> reader) {
ModClusterSchema(int major, int minor, Supplier<XMLElementReader<List<ModelNode>>> readerSupplier) {
this.major = major;
this.minor = minor;
this.reader = reader;
this.readerSupplier = readerSupplier;
}

@Override
Expand All @@ -67,7 +68,7 @@ public String getNamespaceUri() {
return String.format(Locale.ROOT, "urn:jboss:domain:%s:%d.%d", ModClusterExtension.SUBSYSTEM_NAME, this.major, this.minor);
}

public XMLElementReader<List<ModelNode>> getXMLReader() {
return this.reader;
public Supplier<XMLElementReader<List<ModelNode>>> getXMLReaderSupplier() {
return this.readerSupplier;
}
}

0 comments on commit 56902f8

Please sign in to comment.