HHH-14332 Make it easier for Quarkus SPI to avoid loading XML related resources

This commit is contained in:
Sanne Grinovero 2020-11-17 15:55:58 +00:00 committed by Sanne Grinovero
parent 6b55f8ea09
commit 4aa7b84a86
2 changed files with 37 additions and 0 deletions

View File

@ -18,6 +18,7 @@ import java.util.Collections;
import java.util.Enumeration;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Objects;
import java.util.jar.JarFile;
import java.util.zip.ZipEntry;
@ -57,6 +58,7 @@ public class MetadataSources implements Serializable {
private static final CoreMessageLogger LOG = CoreLogging.messageLogger( MetadataSources.class );
private final ServiceRegistry serviceRegistry;
private final boolean disableXmlMappingBinders;
private XmlMappingBinderAccess xmlMappingBinderAccess;
@ -86,6 +88,18 @@ public class MetadataSources implements Serializable {
}
}
this.serviceRegistry = serviceRegistry;
this.disableXmlMappingBinders = false;
}
/**
* Consider this an SPI, used by Quarkus
* @param serviceRegistry
* @param disableXmlMappingBinders
*/
public MetadataSources(ServiceRegistry serviceRegistry, boolean disableXmlMappingBinders) {
Objects.requireNonNull( serviceRegistry );
this.serviceRegistry = serviceRegistry;
this.disableXmlMappingBinders = disableXmlMappingBinders;
}
protected static boolean isExpectedServiceRegistryType(ServiceRegistry serviceRegistry) {
@ -94,6 +108,9 @@ public class MetadataSources implements Serializable {
}
public XmlMappingBinderAccess getXmlMappingBinderAccess() {
if ( disableXmlMappingBinders ) {
return null;
}
if ( xmlMappingBinderAccess == null ) {
xmlMappingBinderAccess = new XmlMappingBinderAccess( serviceRegistry );
}

View File

@ -117,7 +117,9 @@ public class StandardServiceRegistryBuilder {
* Intended for use exclusively from Quarkus boot-strapping, or extensions of
* this class which need to override the standard ServiceInitiator list.
* Consider this an SPI.
* @deprecated Quarkus will switch to use {@link #StandardServiceRegistryBuilder(BootstrapServiceRegistry, Map, ConfigLoader, LoadedConfig, List)}
*/
@Deprecated
protected StandardServiceRegistryBuilder(
BootstrapServiceRegistry bootstrapServiceRegistry,
Map settings,
@ -130,6 +132,24 @@ public class StandardServiceRegistryBuilder {
this.initiators = initiators;
}
/**
* Intended for use exclusively from Quarkus boot-strapping, or extensions of
* this class which need to override the standard ServiceInitiator list.
* Consider this an SPI.
*/
protected StandardServiceRegistryBuilder(
BootstrapServiceRegistry bootstrapServiceRegistry,
Map settings,
ConfigLoader loader,
LoadedConfig loadedConfig,
List<StandardServiceInitiator> initiators) {
this.bootstrapServiceRegistry = bootstrapServiceRegistry;
this.configLoader = loader;
this.settings = settings;
this.aggregatedCfgXml = loadedConfig;
this.initiators = initiators;
}
/**
* Create a builder with the specified bootstrap services.
*