HHH-16006 - Implement an "additional mapping" contributor SPI

This commit is contained in:
Steve Ebersole 2023-01-09 18:14:27 -06:00
parent a9ef9045f2
commit d1a890a9cc
3 changed files with 36 additions and 9 deletions

View File

@ -318,15 +318,19 @@ public class MetadataBuildingProcess {
processor.finishUp();
processAdditionalMappingContributions( options, metadataCollector, classLoaderService, rootMetadataBuildingContext );
processAdditionalJaxbMappingProducer( options, metadataCollector, classLoaderService, rootMetadataBuildingContext, jandexView );
processAdditionalMappingContributions( metadataCollector, options, classLoaderService, rootMetadataBuildingContext );
processAdditionalJaxbMappingProducer( metadataCollector, options, jandexView, classLoaderService, rootMetadataBuildingContext );
applyExtraQueryImports( managedResources, metadataCollector );
return metadataCollector.buildMetadataInstance( rootMetadataBuildingContext );
}
private static void processAdditionalMappingContributions(MetadataBuildingOptions options, InFlightMetadataCollectorImpl metadataCollector, ClassLoaderService classLoaderService, MetadataBuildingContextRootImpl rootMetadataBuildingContext) {
private static void processAdditionalMappingContributions(
InFlightMetadataCollectorImpl metadataCollector,
MetadataBuildingOptions options,
ClassLoaderService classLoaderService,
MetadataBuildingContextRootImpl rootMetadataBuildingContext) {
final EntityHierarchyBuilder hierarchyBuilder = new EntityHierarchyBuilder();
final AdditionalMappingContributionsImpl contributions = new AdditionalMappingContributionsImpl(
metadataCollector,
@ -396,13 +400,10 @@ public class MetadataBuildingProcess {
this.hierarchyBuilder = hierarchyBuilder;
}
public String getCurrentContributor() {
return currentContributor;
}
public void setCurrentContributor(String contributor) {
this.currentContributor = contributor == null ? "orm" : contributor;
}
@Override
public void contributeBinding(JaxbHbmHibernateMapping hbmJaxbBinding, Origin origin) {
if ( ! options.isXmlMappingEnabled() ) {
@ -447,8 +448,12 @@ public class MetadataBuildingProcess {
}
}
@Deprecated
private static void processAdditionalJaxbMappingProducer(MetadataBuildingOptions options, InFlightMetadataCollectorImpl metadataCollector, ClassLoaderService classLoaderService, MetadataBuildingContextRootImpl rootMetadataBuildingContext, IndexView jandexView) {
private static void processAdditionalJaxbMappingProducer(
InFlightMetadataCollectorImpl metadataCollector,
MetadataBuildingOptions options,
IndexView jandexView,
ClassLoaderService classLoaderService,
MetadataBuildingContextRootImpl rootMetadataBuildingContext) {
if ( options.isXmlMappingEnabled() ) {
final Iterable<AdditionalJaxbMappingProducer> producers = classLoaderService.loadJavaServices( AdditionalJaxbMappingProducer.class );
if ( producers != null ) {

View File

@ -21,9 +21,28 @@ import org.hibernate.mapping.Table;
*/
@Incubating
public interface AdditionalMappingContributions {
/**
* Contribute mappings in the form of {@code hbm.xml} JAXB bindings
*/
void contributeBinding(JaxbHbmHibernateMapping hbmJaxbBinding, Origin origin);
/**
* Contribute a materialized PersistentClass
*/
void contributeEntity(PersistentClass entity);
/**
* Contribute a materialized Table
*/
void contributeTable(Table table);
/**
* Contribute a materialized Sequence
*/
void contributeSequence(Sequence sequence);
/**
* Contribute a materialized AuxiliaryDatabaseObject
*/
void contributeAuxiliaryDatabaseObject(AuxiliaryDatabaseObject auxiliaryDatabaseObject);
}

View File

@ -19,6 +19,9 @@ import org.hibernate.boot.jaxb.internal.MappingBinder;
*/
@Incubating
public interface AdditionalMappingContributor {
/**
* The name of this contributor.
*/
default String getContributorName() {
return null;
}