HHH-14529 Clean up constructors in JPAXMLOverriddenMetadataProvider and related

This commit is contained in:
Yoann Rodière 2021-03-26 11:40:03 +01:00
parent ef6bb2679b
commit e8cd9f8917
3 changed files with 6 additions and 42 deletions

View File

@ -250,10 +250,7 @@ public class JPAXMLOverriddenAnnotationReader implements AnnotationReader {
private transient List<Element> elementsForProperty; private transient List<Element> elementsForProperty;
private AccessibleObject mirroredAttribute; private AccessibleObject mirroredAttribute;
/** JPAXMLOverriddenAnnotationReader(
* @deprecated Use {@link #JPAXMLOverriddenAnnotationReader(AnnotatedElement, XMLContext, BootstrapContext)} instead.
*/
public JPAXMLOverriddenAnnotationReader(
AnnotatedElement el, AnnotatedElement el,
XMLContext xmlContext, XMLContext xmlContext,
ClassLoaderAccess classLoaderAccess) { ClassLoaderAccess classLoaderAccess) {
@ -318,6 +315,7 @@ public class JPAXMLOverriddenAnnotationReader implements AnnotationReader {
} }
} }
// For tests only
public JPAXMLOverriddenAnnotationReader( public JPAXMLOverriddenAnnotationReader(
AnnotatedElement el, AnnotatedElement el,
XMLContext xmlContext, XMLContext xmlContext,

View File

@ -23,13 +23,9 @@ import javax.persistence.TableGenerator;
import org.hibernate.annotations.common.reflection.AnnotationReader; import org.hibernate.annotations.common.reflection.AnnotationReader;
import org.hibernate.annotations.common.reflection.MetadataProvider; import org.hibernate.annotations.common.reflection.MetadataProvider;
import org.hibernate.annotations.common.reflection.java.JavaMetadataProvider; import org.hibernate.annotations.common.reflection.java.JavaMetadataProvider;
import org.hibernate.boot.internal.ClassLoaderAccessImpl;
import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
import org.hibernate.boot.registry.classloading.spi.ClassLoadingException; import org.hibernate.boot.registry.classloading.spi.ClassLoadingException;
import org.hibernate.boot.spi.BootstrapContext; import org.hibernate.boot.spi.BootstrapContext;
import org.hibernate.boot.spi.ClassLoaderAccess; import org.hibernate.boot.spi.ClassLoaderAccess;
import org.hibernate.boot.spi.ClassLoaderAccessDelegateImpl;
import org.hibernate.boot.spi.MetadataBuildingOptions;
import org.dom4j.Element; import org.dom4j.Element;
@ -55,37 +51,10 @@ public final class JPAXMLOverriddenMetadataProvider implements MetadataProvider
private Map<Object, Object> defaults; private Map<Object, Object> defaults;
private Map<AnnotatedElement, AnnotationReader> cache; private Map<AnnotatedElement, AnnotationReader> cache;
/**
* @deprecated Use {@link JPAXMLOverriddenMetadataProvider#JPAXMLOverriddenMetadataProvider(BootstrapContext)} instead.
*/
@Deprecated
public JPAXMLOverriddenMetadataProvider(final MetadataBuildingOptions metadataBuildingOptions) {
this( new ClassLoaderAccessDelegateImpl() {
ClassLoaderAccess delegate;
@Override
protected ClassLoaderAccess getDelegate() {
if ( delegate == null ) {
delegate = new ClassLoaderAccessImpl(
metadataBuildingOptions.getTempClassLoader(),
metadataBuildingOptions.getServiceRegistry().getService( ClassLoaderService.class )
);
}
return delegate;
}
},
metadataBuildingOptions.isXmlMappingEnabled() );
}
public JPAXMLOverriddenMetadataProvider(BootstrapContext bootstrapContext) { public JPAXMLOverriddenMetadataProvider(BootstrapContext bootstrapContext) {
this( bootstrapContext.getClassLoaderAccess(), this.classLoaderAccess = bootstrapContext.getClassLoaderAccess();
bootstrapContext.getMetadataBuildingOptions().isXmlMappingEnabled() );
}
JPAXMLOverriddenMetadataProvider(ClassLoaderAccess classLoaderAccess, boolean xmlMetadataEnabled) {
this.classLoaderAccess = classLoaderAccess;
this.xmlContext = new XMLContext( classLoaderAccess ); this.xmlContext = new XMLContext( classLoaderAccess );
this.xmlMappingEnabled = xmlMetadataEnabled; this.xmlMappingEnabled = bootstrapContext.getMetadataBuildingOptions().isXmlMappingEnabled();
} }
//all of the above can be safely rebuilt from XMLContext: only XMLContext this object is serialized //all of the above can be safely rebuilt from XMLContext: only XMLContext this object is serialized

View File

@ -46,14 +46,11 @@ public class XMLContext implements Serializable {
private List<String> defaultEntityListeners = new ArrayList<>(); private List<String> defaultEntityListeners = new ArrayList<>();
private boolean hasContext = false; private boolean hasContext = false;
/** XMLContext(ClassLoaderAccess classLoaderAccess) {
* @deprecated Use {@link XMLContext#XMLContext(BootstrapContext)} instead.
*/
@Deprecated
public XMLContext(ClassLoaderAccess classLoaderAccess) {
this.classLoaderAccess = classLoaderAccess; this.classLoaderAccess = classLoaderAccess;
} }
// For tests only
public XMLContext(BootstrapContext bootstrapContext) { public XMLContext(BootstrapContext bootstrapContext) {
this.classLoaderAccess = bootstrapContext.getClassLoaderAccess(); this.classLoaderAccess = bootstrapContext.getClassLoaderAccess();
} }