Skip to content

Commit 84e37c1

Browse files
committed
HHH-14332 Make it easier for Quarkus SPI to avoid loading XML related resources
1 parent da8706e commit 84e37c1

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

hibernate-core/src/main/java/org/hibernate/boot/MetadataSources.java

+17
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import java.util.Enumeration;
1919
import java.util.LinkedHashSet;
2020
import java.util.List;
21+
import java.util.Objects;
2122
import java.util.jar.JarFile;
2223
import java.util.zip.ZipEntry;
2324

@@ -57,6 +58,7 @@ public class MetadataSources implements Serializable {
5758
private static final CoreMessageLogger LOG = CoreLogging.messageLogger( MetadataSources.class );
5859

5960
private final ServiceRegistry serviceRegistry;
61+
private final boolean disableXmlMappingBinders;
6062

6163
private XmlMappingBinderAccess xmlMappingBinderAccess;
6264

@@ -86,6 +88,18 @@ public MetadataSources(ServiceRegistry serviceRegistry) {
8688
}
8789
}
8890
this.serviceRegistry = serviceRegistry;
91+
this.disableXmlMappingBinders = false;
92+
}
93+
94+
/**
95+
* Consider this an SPI, used by Quarkus
96+
* @param serviceRegistry
97+
* @param disableXmlMappingBinders
98+
*/
99+
public MetadataSources(ServiceRegistry serviceRegistry, boolean disableXmlMappingBinders) {
100+
Objects.requireNonNull( serviceRegistry );
101+
this.serviceRegistry = serviceRegistry;
102+
this.disableXmlMappingBinders = disableXmlMappingBinders;
89103
}
90104

91105
protected static boolean isExpectedServiceRegistryType(ServiceRegistry serviceRegistry) {
@@ -94,6 +108,9 @@ protected static boolean isExpectedServiceRegistryType(ServiceRegistry serviceRe
94108
}
95109

96110
public XmlMappingBinderAccess getXmlMappingBinderAccess() {
111+
if ( disableXmlMappingBinders ) {
112+
return null;
113+
}
97114
if ( xmlMappingBinderAccess == null ) {
98115
xmlMappingBinderAccess = new XmlMappingBinderAccess( serviceRegistry );
99116
}

hibernate-core/src/main/java/org/hibernate/boot/registry/StandardServiceRegistryBuilder.java

+20
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,9 @@ protected StandardServiceRegistryBuilder(
117117
* Intended for use exclusively from Quarkus boot-strapping, or extensions of
118118
* this class which need to override the standard ServiceInitiator list.
119119
* Consider this an SPI.
120+
* @deprecated Quarkus will switch to use {@link #StandardServiceRegistryBuilder(BootstrapServiceRegistry, Map, ConfigLoader, LoadedConfig, List)}
120121
*/
122+
@Deprecated
121123
protected StandardServiceRegistryBuilder(
122124
BootstrapServiceRegistry bootstrapServiceRegistry,
123125
Map settings,
@@ -130,6 +132,24 @@ protected StandardServiceRegistryBuilder(
130132
this.initiators = initiators;
131133
}
132134

135+
/**
136+
* Intended for use exclusively from Quarkus boot-strapping, or extensions of
137+
* this class which need to override the standard ServiceInitiator list.
138+
* Consider this an SPI.
139+
*/
140+
protected StandardServiceRegistryBuilder(
141+
BootstrapServiceRegistry bootstrapServiceRegistry,
142+
Map settings,
143+
ConfigLoader loader,
144+
LoadedConfig loadedConfig,
145+
List<StandardServiceInitiator> initiators) {
146+
this.bootstrapServiceRegistry = bootstrapServiceRegistry;
147+
this.configLoader = loader;
148+
this.settings = settings;
149+
this.aggregatedCfgXml = loadedConfig;
150+
this.initiators = initiators;
151+
}
152+
133153
/**
134154
* Create a builder with the specified bootstrap services.
135155
*

0 commit comments

Comments
 (0)