Permalink
Browse files

WFLY-7751 mod_cluster XML parsers are loaded eagerly

  • Loading branch information...
1 parent 1a1e4f5 commit 56902f8e538c5c4c2d8c6e3379e44820ff2aab48 @rhusar rhusar committed Dec 7, 2016
@@ -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;
@@ -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;
/**
@@ -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()));
}
}
@@ -27,6 +27,7 @@
import java.util.List;
import java.util.Locale;
+import java.util.function.Supplier;
/**
* @author Jean-Frederic Clere
@@ -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
@@ -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.