Skip to content

Commit

Permalink
HHH-14332 Make it easier for Quarkus SPI to avoid loading XML related…
Browse files Browse the repository at this point in the history
… resources
  • Loading branch information
Sanne committed Nov 17, 2020
1 parent da8706e commit 84e37c1
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
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;

Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -86,6 +88,18 @@ public MetadataSources(ServiceRegistry serviceRegistry) {
}
}
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) {
Expand All @@ -94,6 +108,9 @@ protected static boolean isExpectedServiceRegistryType(ServiceRegistry serviceRe
}

public XmlMappingBinderAccess getXmlMappingBinderAccess() {
if ( disableXmlMappingBinders ) {
return null;
}
if ( xmlMappingBinderAccess == null ) {
xmlMappingBinderAccess = new XmlMappingBinderAccess( serviceRegistry );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,9 @@ protected 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,
Expand All @@ -130,6 +132,24 @@ protected 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.
*
Expand Down

0 comments on commit 84e37c1

Please sign in to comment.