HHH-15409 Restore lazy initialization semantics for MetadataSources#xmlMappingBinderAccess

This commit is contained in:
Sanne Grinovero 2022-07-18 16:29:20 +01:00 committed by Sanne Grinovero
parent e6fdafc393
commit fbd7fe000e
1 changed files with 5 additions and 14 deletions

View File

@ -63,7 +63,7 @@ public class MetadataSources implements Serializable {
private final ServiceRegistry serviceRegistry;
private final ClassLoaderService classLoaderService;
private final XmlMappingBinderAccess xmlMappingBinderAccess;
private XmlMappingBinderAccess xmlMappingBinderAccess;
private List<Binding<?>> xmlBindings;
private LinkedHashSet<Class<?>> annotatedClasses;
@ -85,7 +85,7 @@ public class MetadataSources implements Serializable {
* @param serviceRegistry The service registry to use.
*/
public MetadataSources(ServiceRegistry serviceRegistry) {
this( serviceRegistry, new XmlMappingBinderAccess( serviceRegistry ) );
this( serviceRegistry, null );
}
/**
@ -109,24 +109,15 @@ public class MetadataSources implements Serializable {
this.xmlMappingBinderAccess = xmlMappingBinderAccess;
}
/**
* Consider this an SPI, used by Quarkus
*/
public MetadataSources(ServiceRegistry serviceRegistry, boolean disableXmlMappingBinders) {
Objects.requireNonNull( serviceRegistry );
this.serviceRegistry = serviceRegistry;
this.classLoaderService = serviceRegistry.getService( ClassLoaderService.class );
this.xmlMappingBinderAccess = disableXmlMappingBinders
? null
: new XmlMappingBinderAccess( serviceRegistry );
}
protected static boolean isExpectedServiceRegistryType(ServiceRegistry serviceRegistry) {
return serviceRegistry instanceof BootstrapServiceRegistry
|| serviceRegistry instanceof StandardServiceRegistry;
}
public XmlMappingBinderAccess getXmlMappingBinderAccess() {
if ( xmlMappingBinderAccess == null ) {
xmlMappingBinderAccess = new XmlMappingBinderAccess( serviceRegistry );
}
return xmlMappingBinderAccess;
}