From edcc34a291ebc1a259cb766529e78aa69f4e131a Mon Sep 17 00:00:00 2001 From: Karel Maesen Date: Sat, 24 Mar 2012 00:03:16 +0100 Subject: [PATCH] HHH-6507 Adds TypeContributingIntegrator. --- .../spi/TypeContributingIntegrator.java | 21 +++++++++++++++++++ .../metamodel/internal/MetadataImpl.java | 14 ++++++++++++- 2 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 hibernate-core/src/main/java/org/hibernate/integrator/spi/TypeContributingIntegrator.java diff --git a/hibernate-core/src/main/java/org/hibernate/integrator/spi/TypeContributingIntegrator.java b/hibernate-core/src/main/java/org/hibernate/integrator/spi/TypeContributingIntegrator.java new file mode 100644 index 0000000000..ef99af51f6 --- /dev/null +++ b/hibernate-core/src/main/java/org/hibernate/integrator/spi/TypeContributingIntegrator.java @@ -0,0 +1,21 @@ +package org.hibernate.integrator.spi; + +import org.hibernate.metamodel.spi.source.MetadataImplementor; + +/** + * @author Karel Maesen, Geovise BVBA + * creation-date: 3/23/12 + */ +public interface TypeContributingIntegrator extends Integrator { + + /** + * Allows the Integrator to modify the MetadataImplementor + * prior to building the metadata, presumably to register additional types in the + * TypeRegistry. + * + * + * @param builder + */ + public void prepareTypes(MetadataImplementor builder); + +} diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/MetadataImpl.java b/hibernate-core/src/main/java/org/hibernate/metamodel/internal/MetadataImpl.java index 8876dd63b4..7c723167e6 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/MetadataImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/internal/MetadataImpl.java @@ -26,6 +26,9 @@ package org.hibernate.metamodel.internal; import java.io.Serializable; import java.util.HashMap; import java.util.Map; + +import org.jboss.logging.Logger; + import org.hibernate.AssertionFailure; import org.hibernate.DuplicateMappingException; import org.hibernate.MappingException; @@ -39,6 +42,9 @@ import org.hibernate.engine.spi.NamedQueryDefinition; import org.hibernate.engine.spi.NamedSQLQueryDefinition; import org.hibernate.id.factory.IdentifierGeneratorFactory; import org.hibernate.id.factory.spi.MutableIdentifierGeneratorFactory; +import org.hibernate.integrator.spi.Integrator; +import org.hibernate.integrator.spi.IntegratorService; +import org.hibernate.integrator.spi.TypeContributingIntegrator; import org.hibernate.internal.CoreMessageLogger; import org.hibernate.internal.util.Value; import org.hibernate.metamodel.MetadataSourceProcessingOrder; @@ -65,7 +71,6 @@ import org.hibernate.persister.spi.PersisterClassResolver; import org.hibernate.service.ServiceRegistry; import org.hibernate.service.classloading.spi.ClassLoaderService; import org.hibernate.type.TypeResolver; -import org.jboss.logging.Logger; /** * Container for configuration data collected during binding the metamodel. @@ -149,6 +154,13 @@ public class MetadataImpl implements MetadataImplementor, Serializable { } ); + //check for typeContributingIntegrators integrators + for ( Integrator integrator : serviceRegistry.getService( IntegratorService.class ).getIntegrators() ) { + if ( TypeContributingIntegrator.class.isInstance( integrator ) ) { + TypeContributingIntegrator.class.cast( integrator ).prepareTypes( this ); + } + } + processTypeDefinitions( metadataSourceProcessors ); processFilterDefinitions( metadataSourceProcessors ); processIdentifierGenerators( metadataSourceProcessors );