From 356471787639f4b7aca844c8a3800c13c4d52626 Mon Sep 17 00:00:00 2001 From: Yanming Zhou Date: Thu, 27 Jul 2023 12:09:23 +0800 Subject: [PATCH] HHH-16935 Fix inconsistent method name --- .../boot/internal/MetadataBuilderImpl.java | 2 +- .../hibernate/boot/model/TypeDefinition.java | 2 +- .../boot/model/internal/AnnotationBinder.java | 41 ++++++------------- .../boot/model/internal/BasicValueBinder.java | 14 +++---- .../boot/model/internal/CollectionBinder.java | 2 +- .../boot/model/internal/EmbeddableBinder.java | 2 +- .../source/internal/hbm/ModelBinder.java | 2 +- ...ractDelegatingMetadataBuildingOptions.java | 4 +- .../boot/spi/MetadataBuildingOptions.java | 12 +++++- .../org/hibernate/mapping/BasicValue.java | 2 +- .../org/hibernate/mapping/MappingHelper.java | 2 +- ...gedTypeRepresentationResolverStandard.java | 4 +- .../hibernate/type/spi/TypeConfiguration.java | 4 +- .../metadata/ComponentMetadataGenerator.java | 4 +- 14 files changed, 46 insertions(+), 51 deletions(-) diff --git a/hibernate-core/src/main/java/org/hibernate/boot/internal/MetadataBuilderImpl.java b/hibernate-core/src/main/java/org/hibernate/boot/internal/MetadataBuilderImpl.java index 4bb559fb35..5c468ee046 100644 --- a/hibernate-core/src/main/java/org/hibernate/boot/internal/MetadataBuilderImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/boot/internal/MetadataBuilderImpl.java @@ -975,7 +975,7 @@ public class MetadataBuilderImpl implements MetadataBuilderImplementor, TypeCont } @Override - public boolean disallowExtensionsInCdi() { + public boolean isAllowExtensionsInCdi() { return allowExtensionsInCdi; } diff --git a/hibernate-core/src/main/java/org/hibernate/boot/model/TypeDefinition.java b/hibernate-core/src/main/java/org/hibernate/boot/model/TypeDefinition.java index 9deef365c8..7e43d7b1c3 100644 --- a/hibernate-core/src/main/java/org/hibernate/boot/model/TypeDefinition.java +++ b/hibernate-core/src/main/java/org/hibernate/boot/model/TypeDefinition.java @@ -302,7 +302,7 @@ public class TypeDefinition implements Serializable { String name, Class typeImplementorClass, BeanInstanceProducer instanceProducer) { - if ( buildingOptions.disallowExtensionsInCdi() ) { + if ( !buildingOptions.isAllowExtensionsInCdi() ) { return name != null ? instanceProducer.produceBeanInstance( name, typeImplementorClass ) : instanceProducer.produceBeanInstance( typeImplementorClass ); diff --git a/hibernate-core/src/main/java/org/hibernate/boot/model/internal/AnnotationBinder.java b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/AnnotationBinder.java index 1ea1c6e3a0..3a7ad75cca 100644 --- a/hibernate-core/src/main/java/org/hibernate/boot/model/internal/AnnotationBinder.java +++ b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/AnnotationBinder.java @@ -494,15 +494,9 @@ public final class AnnotationBinder { ManagedBeanRegistry managedBeanRegistry, JdbcTypeRegistration annotation) { final Class jdbcTypeClass = annotation.value(); - - final JdbcType jdbcType; - if ( context.getBuildingOptions().disallowExtensionsInCdi() ) { - jdbcType = FallbackBeanInstanceProducer.INSTANCE.produceBeanInstance( jdbcTypeClass ); - } - else { - jdbcType = managedBeanRegistry.getBean( jdbcTypeClass ).getBeanInstance(); - } - + final JdbcType jdbcType = !context.getBuildingOptions().isAllowExtensionsInCdi() + ? FallbackBeanInstanceProducer.INSTANCE.produceBeanInstance( jdbcTypeClass ) + : managedBeanRegistry.getBean( jdbcTypeClass ).getBeanInstance(); final int typeCode = annotation.registrationCode() == Integer.MIN_VALUE ? jdbcType.getDefaultSqlTypeCode() : annotation.registrationCode(); @@ -514,14 +508,10 @@ public final class AnnotationBinder { ManagedBeanRegistry managedBeanRegistry, JavaTypeRegistration annotation) { final Class> javaTypeClass = annotation.descriptorClass(); - - final BasicJavaType javaType; - if ( context.getBuildingOptions().disallowExtensionsInCdi() ) { - javaType = FallbackBeanInstanceProducer.INSTANCE.produceBeanInstance( javaTypeClass ); - } - else { - javaType = managedBeanRegistry.getBean( javaTypeClass ).getBeanInstance(); - } + final BasicJavaType javaType = + !context.getBuildingOptions().isAllowExtensionsInCdi() + ? FallbackBeanInstanceProducer.INSTANCE.produceBeanInstance( javaTypeClass ) + : managedBeanRegistry.getBean( javaTypeClass ).getBeanInstance(); context.getMetadataCollector().addJavaTypeRegistration( annotation.javaType(), javaType ); } @@ -751,16 +741,11 @@ public final class AnnotationBinder { } private static JdbcMapping resolveUserType(Class> userTypeClass, MetadataBuildingContext context) { - final UserType userType; - if ( context.getBuildingOptions().disallowExtensionsInCdi() ) { - userType = FallbackBeanInstanceProducer.INSTANCE.produceBeanInstance( userTypeClass ); - } - else { - final StandardServiceRegistry serviceRegistry = context.getBootstrapContext().getServiceRegistry(); - final ManagedBeanRegistry beanRegistry = serviceRegistry.getService( ManagedBeanRegistry.class ); - userType = beanRegistry.getBean( userTypeClass ).getBeanInstance(); - } - + final UserType userType = !context.getBuildingOptions().isAllowExtensionsInCdi() + ? FallbackBeanInstanceProducer.INSTANCE.produceBeanInstance( userTypeClass ) + : context.getBootstrapContext().getServiceRegistry() + .requireService( ManagedBeanRegistry.class ) + .getBean( userTypeClass ).getBeanInstance(); return new CustomType<>( userType, context.getBootstrapContext().getTypeConfiguration() ); } @@ -812,7 +797,7 @@ public final class AnnotationBinder { return registeredJtd; } - if ( context.getBuildingOptions().disallowExtensionsInCdi() ) { + if ( !context.getBuildingOptions().isAllowExtensionsInCdi() ) { return FallbackBeanInstanceProducer.INSTANCE.produceBeanInstance( javaTypeClass ); } diff --git a/hibernate-core/src/main/java/org/hibernate/boot/model/internal/BasicValueBinder.java b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/BasicValueBinder.java index a820f7b467..0981d2c000 100644 --- a/hibernate-core/src/main/java/org/hibernate/boot/model/internal/BasicValueBinder.java +++ b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/BasicValueBinder.java @@ -432,7 +432,7 @@ public class BasicValueBinder implements JdbcTypeIndicators { throw new MappingException( "idbag mapping missing @CollectionId" ); } - final boolean useDeferredBeanContainerAccess = buildingContext.getBuildingOptions().disallowExtensionsInCdi(); + final boolean useDeferredBeanContainerAccess = !buildingContext.getBuildingOptions().isAllowExtensionsInCdi(); final ManagedBeanRegistry beanRegistry = getManagedBeanRegistry(); explicitBasicTypeName = null; @@ -555,7 +555,7 @@ public class BasicValueBinder implements JdbcTypeIndicators { temporalPrecision = mapKeyTemporalAnn.value(); } - final boolean useDeferredBeanContainerAccess = buildingContext.getBuildingOptions().disallowExtensionsInCdi(); + final boolean useDeferredBeanContainerAccess = !buildingContext.getBuildingOptions().isAllowExtensionsInCdi(); explicitJdbcTypeAccess = typeConfiguration -> { final MapKeyJdbcType jdbcTypeAnn = findAnnotation( mapAttribute, MapKeyJdbcType.class ); @@ -658,7 +658,7 @@ public class BasicValueBinder implements JdbcTypeIndicators { private void prepareListIndex(XProperty listAttribute) { implicitJavaTypeAccess = typeConfiguration -> Integer.class; - final boolean useDeferredBeanContainerAccess = buildingContext.getBuildingOptions().disallowExtensionsInCdi(); + final boolean useDeferredBeanContainerAccess = !buildingContext.getBuildingOptions().isAllowExtensionsInCdi(); final ManagedBeanRegistry beanRegistry = buildingContext .getBootstrapContext() .getServiceRegistry() @@ -873,7 +873,7 @@ public class BasicValueBinder implements JdbcTypeIndicators { private void prepareAnyKey(XProperty modelXProperty) { implicitJavaTypeAccess = (typeConfiguration) -> null; - final boolean useDeferredBeanContainerAccess = buildingContext.getBuildingOptions().disallowExtensionsInCdi(); + final boolean useDeferredBeanContainerAccess = !buildingContext.getBuildingOptions().isAllowExtensionsInCdi(); explicitJavaTypeAccess = (typeConfiguration) -> { final AnyKeyJavaType javaTypeAnn = findAnnotation( modelXProperty, AnyKeyJavaType.class ); @@ -930,7 +930,7 @@ public class BasicValueBinder implements JdbcTypeIndicators { if ( jdbcTypeAnn != null ) { final Class jdbcTypeClass = normalizeJdbcType( jdbcTypeAnn.value() ); if ( jdbcTypeClass != null ) { - if ( buildingContext.getBuildingOptions().disallowExtensionsInCdi() ) { + if ( !buildingContext.getBuildingOptions().isAllowExtensionsInCdi() ) { return FallbackBeanInstanceProducer.INSTANCE.produceBeanInstance( jdbcTypeClass ); } return getManagedBeanRegistry().getBean( jdbcTypeClass ).getBeanInstance(); @@ -1043,7 +1043,7 @@ public class BasicValueBinder implements JdbcTypeIndicators { return ImmutableMutabilityPlan.instance(); } - if ( buildingContext.getBuildingOptions().disallowExtensionsInCdi() ) { + if ( !buildingContext.getBuildingOptions().isAllowExtensionsInCdi() ) { return FallbackBeanInstanceProducer.INSTANCE.produceBeanInstance( mutability ); } @@ -1057,7 +1057,7 @@ public class BasicValueBinder implements JdbcTypeIndicators { if ( javaTypeAnn != null ) { final Class> javaTypeClass = normalizeJavaType( javaTypeAnn.value() ); if ( javaTypeClass != null ) { - if ( buildingContext.getBuildingOptions().disallowExtensionsInCdi() ) { + if ( !buildingContext.getBuildingOptions().isAllowExtensionsInCdi() ) { return FallbackBeanInstanceProducer.INSTANCE.produceBeanInstance( javaTypeClass ); } final ManagedBean> jtdBean = getManagedBeanRegistry().getBean( javaTypeClass ); diff --git a/hibernate-core/src/main/java/org/hibernate/boot/model/internal/CollectionBinder.java b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/CollectionBinder.java index d6c8a8cb63..810431ed2a 100644 --- a/hibernate-core/src/main/java/org/hibernate/boot/model/internal/CollectionBinder.java +++ b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/CollectionBinder.java @@ -846,7 +846,7 @@ public abstract class CollectionBinder { Map parameters, MetadataBuildingContext buildingContext) { final boolean hasParameters = CollectionHelper.isNotEmpty( parameters ); - if ( buildingContext.getBuildingOptions().disallowExtensionsInCdi() ) { + if ( !buildingContext.getBuildingOptions().isAllowExtensionsInCdi() ) { // if deferred container access is enabled, we locally create the user-type return MappingHelper.createLocalUserCollectionTypeBean( role, implementation, hasParameters, parameters ); } diff --git a/hibernate-core/src/main/java/org/hibernate/boot/model/internal/EmbeddableBinder.java b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/EmbeddableBinder.java index ca5903b303..c210e793e3 100644 --- a/hibernate-core/src/main/java/org/hibernate/boot/model/internal/EmbeddableBinder.java +++ b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/EmbeddableBinder.java @@ -405,7 +405,7 @@ public class EmbeddableBinder { private static CompositeUserType compositeUserType( Class> compositeUserTypeClass, MetadataBuildingContext context) { - if ( context.getBuildingOptions().disallowExtensionsInCdi() ) { + if ( !context.getBuildingOptions().isAllowExtensionsInCdi() ) { FallbackBeanInstanceProducer.INSTANCE.produceBeanInstance( compositeUserTypeClass ); } diff --git a/hibernate-core/src/main/java/org/hibernate/boot/model/source/internal/hbm/ModelBinder.java b/hibernate-core/src/main/java/org/hibernate/boot/model/source/internal/hbm/ModelBinder.java index 907a9c6b07..d65225f6b9 100644 --- a/hibernate-core/src/main/java/org/hibernate/boot/model/source/internal/hbm/ModelBinder.java +++ b/hibernate-core/src/main/java/org/hibernate/boot/model/source/internal/hbm/ModelBinder.java @@ -2632,7 +2632,7 @@ public class ModelBinder { if ( CompositeUserType.class.isAssignableFrom( componentClass ) ) { componentBinding.setTypeName( explicitComponentClassName ); CompositeUserType compositeUserType; - if ( sourceDocument.getBuildingOptions().disallowExtensionsInCdi() ) { + if ( !sourceDocument.getBuildingOptions().isAllowExtensionsInCdi() ) { compositeUserType = (CompositeUserType) FallbackBeanInstanceProducer.INSTANCE.produceBeanInstance( componentClass ); } else { diff --git a/hibernate-core/src/main/java/org/hibernate/boot/spi/AbstractDelegatingMetadataBuildingOptions.java b/hibernate-core/src/main/java/org/hibernate/boot/spi/AbstractDelegatingMetadataBuildingOptions.java index e8f1df0e24..f927b004fe 100644 --- a/hibernate-core/src/main/java/org/hibernate/boot/spi/AbstractDelegatingMetadataBuildingOptions.java +++ b/hibernate-core/src/main/java/org/hibernate/boot/spi/AbstractDelegatingMetadataBuildingOptions.java @@ -178,7 +178,7 @@ public abstract class AbstractDelegatingMetadataBuildingOptions implements Metad } @Override - public boolean disallowExtensionsInCdi() { - return delegate.disallowExtensionsInCdi(); + public boolean isAllowExtensionsInCdi() { + return delegate.isAllowExtensionsInCdi(); } } diff --git a/hibernate-core/src/main/java/org/hibernate/boot/spi/MetadataBuildingOptions.java b/hibernate-core/src/main/java/org/hibernate/boot/spi/MetadataBuildingOptions.java index b887810117..5d68fba35e 100644 --- a/hibernate-core/src/main/java/org/hibernate/boot/spi/MetadataBuildingOptions.java +++ b/hibernate-core/src/main/java/org/hibernate/boot/spi/MetadataBuildingOptions.java @@ -243,5 +243,15 @@ public interface MetadataBuildingOptions { /** * Check to see if extensions can be hosted in CDI */ - boolean disallowExtensionsInCdi(); + boolean isAllowExtensionsInCdi(); + + /** + * Check to see if extensions can be hosted in CDI + * + * @deprecated Use {@link #isAllowExtensionsInCdi()} + */ + @Deprecated(forRemoval = true) + default boolean disallowExtensionsInCdi() { + return !isAllowExtensionsInCdi(); + } } diff --git a/hibernate-core/src/main/java/org/hibernate/mapping/BasicValue.java b/hibernate-core/src/main/java/org/hibernate/mapping/BasicValue.java index 1ed0aaeaf3..f6f2fec27a 100644 --- a/hibernate-core/src/main/java/org/hibernate/mapping/BasicValue.java +++ b/hibernate-core/src/main/java/org/hibernate/mapping/BasicValue.java @@ -841,7 +841,7 @@ public class BasicValue extends SimpleValue implements JdbcTypeIndicators, Resol } final T typeInstance; - if ( getBuildingContext().getBuildingOptions().disallowExtensionsInCdi() ) { + if ( !getBuildingContext().getBuildingOptions().isAllowExtensionsInCdi() ) { typeInstance = FallbackBeanInstanceProducer.INSTANCE.produceBeanInstance( explicitCustomType ); } else { diff --git a/hibernate-core/src/main/java/org/hibernate/mapping/MappingHelper.java b/hibernate-core/src/main/java/org/hibernate/mapping/MappingHelper.java index 5a33906334..cf248ae578 100644 --- a/hibernate-core/src/main/java/org/hibernate/mapping/MappingHelper.java +++ b/hibernate-core/src/main/java/org/hibernate/mapping/MappingHelper.java @@ -60,7 +60,7 @@ public final class MappingHelper { final boolean hasParameters = CollectionHelper.isNotEmpty( typeParameters ); final ManagedBean userTypeBean; - if ( metadata.getMetadataBuildingOptions().disallowExtensionsInCdi() ) { + if ( !metadata.getMetadataBuildingOptions().isAllowExtensionsInCdi() ) { //noinspection unchecked,rawtypes userTypeBean = createLocalUserCollectionTypeBean( role, diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/ManagedTypeRepresentationResolverStandard.java b/hibernate-core/src/main/java/org/hibernate/metamodel/internal/ManagedTypeRepresentationResolverStandard.java index 975950e5bf..efe2a89ce8 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/ManagedTypeRepresentationResolverStandard.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/internal/ManagedTypeRepresentationResolverStandard.java @@ -82,7 +82,7 @@ public class ManagedTypeRepresentationResolverStandard implements ManagedTypeRep final Class> userTypeClass = creationContext.getBootstrapContext() .getClassLoaderAccess() .classForName( bootDescriptor.getTypeName() ); - if ( creationContext.getBootModel().getMetadataBuildingOptions().disallowExtensionsInCdi() ) { + if ( !creationContext.getBootModel().getMetadataBuildingOptions().isAllowExtensionsInCdi() ) { compositeUserType = FallbackBeanInstanceProducer.INSTANCE.produceBeanInstance( userTypeClass ); } else { @@ -99,7 +99,7 @@ public class ManagedTypeRepresentationResolverStandard implements ManagedTypeRep final EmbeddableInstantiator customInstantiator; if ( bootDescriptor.getCustomInstantiator() != null ) { final Class instantiatorClass = bootDescriptor.getCustomInstantiator(); - if ( creationContext.getBootModel().getMetadataBuildingOptions().disallowExtensionsInCdi() ) { + if ( !creationContext.getBootModel().getMetadataBuildingOptions().isAllowExtensionsInCdi() ) { customInstantiator = FallbackBeanInstanceProducer.INSTANCE.produceBeanInstance( instantiatorClass ); } else { diff --git a/hibernate-core/src/main/java/org/hibernate/type/spi/TypeConfiguration.java b/hibernate-core/src/main/java/org/hibernate/type/spi/TypeConfiguration.java index 400afdc749..01cf847e42 100644 --- a/hibernate-core/src/main/java/org/hibernate/type/spi/TypeConfiguration.java +++ b/hibernate-core/src/main/java/org/hibernate/type/spi/TypeConfiguration.java @@ -494,7 +494,7 @@ public class TypeConfiguration implements SessionFactoryObserver, Serializable { private void setMetadataBuildingContext(MetadataBuildingContext metadataBuildingContext) { this.metadataBuildingContext = metadataBuildingContext; if ( metadataBuildingContext != null ) { - this.allowExtensionsInCdi = metadataBuildingContext.getBuildingOptions().disallowExtensionsInCdi(); + this.allowExtensionsInCdi = metadataBuildingContext.getBuildingOptions().isAllowExtensionsInCdi(); } } @@ -811,7 +811,7 @@ public class TypeConfiguration implements SessionFactoryObserver, Serializable { @Internal @SuppressWarnings("unchecked") public MutabilityPlan createMutabilityPlan(Class> planClass) { - if ( scope.allowExtensionsInCdi ) { + if ( !scope.allowExtensionsInCdi ) { //noinspection rawtypes return (MutabilityPlan) FallbackBeanInstanceProducer.INSTANCE.produceBeanInstance( planClass ); } diff --git a/hibernate-envers/src/main/java/org/hibernate/envers/configuration/internal/metadata/ComponentMetadataGenerator.java b/hibernate-envers/src/main/java/org/hibernate/envers/configuration/internal/metadata/ComponentMetadataGenerator.java index a4757cbf49..4082648335 100644 --- a/hibernate-envers/src/main/java/org/hibernate/envers/configuration/internal/metadata/ComponentMetadataGenerator.java +++ b/hibernate-envers/src/main/java/org/hibernate/envers/configuration/internal/metadata/ComponentMetadataGenerator.java @@ -53,7 +53,7 @@ public final class ComponentMetadataGenerator extends AbstractMetadataGenerator final Component propComponent = (Component) value; final EmbeddableInstantiator instantiator; if ( propComponent.getCustomInstantiator() != null ) { - if ( getMetadataBuildingContext().getBuildingOptions().disallowExtensionsInCdi() ) { + if ( !getMetadataBuildingContext().getBuildingOptions().isAllowExtensionsInCdi() ) { instantiator = FallbackBeanInstanceProducer.INSTANCE.produceBeanInstance( propComponent.getCustomInstantiator() ); } else { @@ -68,7 +68,7 @@ public final class ComponentMetadataGenerator extends AbstractMetadataGenerator final Class> userTypeClass = getMetadataBuildingContext().getBootstrapContext() .getClassLoaderAccess() .classForName( propComponent.getTypeName() ); - if ( getMetadataBuildingContext().getBuildingOptions().disallowExtensionsInCdi() ) { + if ( !getMetadataBuildingContext().getBuildingOptions().isAllowExtensionsInCdi() ) { final CompositeUserType compositeUserType = FallbackBeanInstanceProducer.INSTANCE.produceBeanInstance( userTypeClass ); //noinspection rawtypes instantiator = new EmbeddableCompositeUserTypeInstantiator( (CompositeUserType) compositeUserType );