use requiresService() much more consistently
we should usually avoid the use of getService() unless there is an explicit null test on the client side
This commit is contained in:
parent
f1e099b8e8
commit
3769d4c233
|
@ -31,7 +31,7 @@ public class AgroalConnectionProviderTest extends BaseCoreFunctionalTestCase {
|
|||
|
||||
@Test
|
||||
public void testAgroalConnectionProvider() throws Exception {
|
||||
JdbcServices jdbcServices = serviceRegistry().getService( JdbcServices.class );
|
||||
JdbcServices jdbcServices = serviceRegistry().requireService( JdbcServices.class );
|
||||
ConnectionProviderJdbcConnectionAccess connectionAccess = assertTyping(
|
||||
ConnectionProviderJdbcConnectionAccess.class,
|
||||
jdbcServices.getBootstrapJdbcConnectionAccess()
|
||||
|
|
|
@ -132,7 +132,7 @@ public class C3P0ConnectionProvider
|
|||
}
|
||||
else {
|
||||
try {
|
||||
serviceRegistry.getService( ClassLoaderService.class ).classForName( jdbcDriverClass );
|
||||
serviceRegistry.requireService( ClassLoaderService.class ).classForName( jdbcDriverClass );
|
||||
}
|
||||
catch (ClassLoadingException e) {
|
||||
throw new ClassLoadingException( C3P0_MSG_LOGGER.jdbcDriverNotFound( jdbcDriverClass ), e );
|
||||
|
|
|
@ -44,7 +44,7 @@ public class C3P0ConnectionProviderTest extends BaseCoreFunctionalTestCase {
|
|||
|
||||
@Test
|
||||
public void testC3P0isDefaultWhenThereIsC3P0Properties() {
|
||||
JdbcServices jdbcServices = serviceRegistry().getService( JdbcServices.class );
|
||||
JdbcServices jdbcServices = serviceRegistry().requireService( JdbcServices.class );
|
||||
ConnectionProviderJdbcConnectionAccess connectionAccess =
|
||||
assertTyping(
|
||||
ConnectionProviderJdbcConnectionAccess.class,
|
||||
|
|
|
@ -841,7 +841,7 @@ public class OracleLegacyDialect extends Dialect {
|
|||
if ( getVersion().isSameOrAfter( 12 ) ) {
|
||||
// account for Oracle's deprecated support for LONGVARBINARY
|
||||
// prefer BLOB, unless the user explicitly opts out
|
||||
boolean preferLong = serviceRegistry.getService( ConfigurationService.class ).getSetting(
|
||||
boolean preferLong = serviceRegistry.requireService( ConfigurationService.class ).getSetting(
|
||||
PREFER_LONG_RAW,
|
||||
StandardConverters.BOOLEAN,
|
||||
false
|
||||
|
|
|
@ -171,7 +171,7 @@ public class MetadataSources implements Serializable {
|
|||
private MetadataBuilder getCustomBuilderOrDefault(MetadataBuilderImpl defaultBuilder) {
|
||||
|
||||
Collection<MetadataBuilderFactory> discoveredBuilderFactories =
|
||||
serviceRegistry.getService( ClassLoaderService.class )
|
||||
serviceRegistry.requireService( ClassLoaderService.class )
|
||||
.loadJavaServices( MetadataBuilderFactory.class );
|
||||
|
||||
MetadataBuilder builder = null;
|
||||
|
|
|
@ -90,7 +90,7 @@ public class BeanValidationIntegrator implements Integrator {
|
|||
BootstrapContext bootstrapContext,
|
||||
SessionFactoryImplementor sessionFactory) {
|
||||
ServiceRegistryImplementor serviceRegistry = sessionFactory.getServiceRegistry();
|
||||
final ConfigurationService cfgService = serviceRegistry.getService( ConfigurationService.class );
|
||||
final ConfigurationService cfgService = serviceRegistry.requireService( ConfigurationService.class );
|
||||
// IMPL NOTE : see the comments on ActivationContext.getValidationModes() as to why this is multi-valued...
|
||||
Object modeSetting = cfgService.getSettings().get( JAKARTA_MODE_PROPERTY );
|
||||
if ( modeSetting == null ) {
|
||||
|
@ -105,7 +105,7 @@ public class BeanValidationIntegrator implements Integrator {
|
|||
return;
|
||||
}
|
||||
|
||||
final ClassLoaderService classLoaderService = serviceRegistry.getService( ClassLoaderService.class );
|
||||
final ClassLoaderService classLoaderService = serviceRegistry.requireService( ClassLoaderService.class );
|
||||
|
||||
// see if the Bean Validation API is available on the classpath
|
||||
if ( isBeanValidationApiAvailable( classLoaderService ) ) {
|
||||
|
|
|
@ -106,8 +106,8 @@ class TypeSafeActivator {
|
|||
return;
|
||||
}
|
||||
|
||||
final ConfigurationService cfgService = activationContext.getServiceRegistry().getService( ConfigurationService.class );
|
||||
final ClassLoaderService classLoaderService = activationContext.getServiceRegistry().getService( ClassLoaderService.class );
|
||||
final ConfigurationService cfgService = activationContext.getServiceRegistry().requireService( ConfigurationService.class );
|
||||
final ClassLoaderService classLoaderService = activationContext.getServiceRegistry().requireService( ClassLoaderService.class );
|
||||
|
||||
// de-activate not-null tracking at the core level when Bean Validation is present unless the user explicitly
|
||||
// asks for it
|
||||
|
@ -122,7 +122,7 @@ class TypeSafeActivator {
|
|||
);
|
||||
|
||||
final EventListenerRegistry listenerRegistry = activationContext.getServiceRegistry()
|
||||
.getService( EventListenerRegistry.class );
|
||||
.requireService( EventListenerRegistry.class );
|
||||
|
||||
listenerRegistry.addDuplicationStrategy( DuplicationStrategyImpl.INSTANCE );
|
||||
|
||||
|
@ -134,7 +134,7 @@ class TypeSafeActivator {
|
|||
}
|
||||
|
||||
private static void applyRelationalConstraints(ValidatorFactory factory, ActivationContext activationContext) {
|
||||
final ConfigurationService cfgService = activationContext.getServiceRegistry().getService( ConfigurationService.class );
|
||||
final ConfigurationService cfgService = activationContext.getServiceRegistry().requireService( ConfigurationService.class );
|
||||
if ( !cfgService.getSetting( BeanValidationIntegrator.APPLY_CONSTRAINTS, StandardConverters.BOOLEAN, true ) ) {
|
||||
LOG.debug( "Skipping application of relational constraints from legacy Hibernate Validator" );
|
||||
return;
|
||||
|
@ -149,7 +149,7 @@ class TypeSafeActivator {
|
|||
factory,
|
||||
activationContext.getMetadata().getEntityBindings(),
|
||||
cfgService.getSettings(),
|
||||
activationContext.getServiceRegistry().getService( JdbcServices.class ).getDialect(),
|
||||
activationContext.getServiceRegistry().requireService( JdbcServices.class ).getDialect(),
|
||||
new ClassLoaderAccessImpl(
|
||||
null,
|
||||
activationContext.getServiceRegistry().getService( ClassLoaderService.class )
|
||||
|
@ -473,7 +473,7 @@ class TypeSafeActivator {
|
|||
}
|
||||
|
||||
// 2 - look in ConfigurationService
|
||||
factory = resolveProvidedFactory( activationContext.getServiceRegistry().getService( ConfigurationService.class ) );
|
||||
factory = resolveProvidedFactory( activationContext.getServiceRegistry().requireService( ConfigurationService.class ) );
|
||||
if ( factory != null ) {
|
||||
return factory;
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@ public class ConfigLoader {
|
|||
}
|
||||
|
||||
public LoadedConfig loadConfigXmlResource(String cfgXmlResourceName) {
|
||||
final InputStream stream = bootstrapServiceRegistry.getService( ClassLoaderService.class ).locateResourceStream( cfgXmlResourceName );
|
||||
final InputStream stream = bootstrapServiceRegistry.requireService( ClassLoaderService.class ).locateResourceStream( cfgXmlResourceName );
|
||||
if ( stream == null ) {
|
||||
throw new ConfigurationException( "Could not locate cfg.xml resource [" + cfgXmlResourceName + "]" );
|
||||
}
|
||||
|
@ -113,7 +113,7 @@ public class ConfigLoader {
|
|||
}
|
||||
|
||||
public Properties loadProperties(String resourceName) {
|
||||
final InputStream stream = bootstrapServiceRegistry.getService( ClassLoaderService.class ).locateResourceStream( resourceName );
|
||||
final InputStream stream = bootstrapServiceRegistry.requireService( ClassLoaderService.class ).locateResourceStream( resourceName );
|
||||
|
||||
if ( stream == null ) {
|
||||
throw new ConfigurationException( "Unable to apply settings from properties file [" + resourceName + "]" );
|
||||
|
|
|
@ -90,8 +90,8 @@ public class BootstrapContextImpl implements BootstrapContext {
|
|||
this.classLoaderAccess = new ClassLoaderAccessImpl( serviceRegistry.getService( ClassLoaderService.class ) );
|
||||
this.hcannReflectionManager = generateHcannReflectionManager();
|
||||
|
||||
final StrategySelector strategySelector = serviceRegistry.getService( StrategySelector.class );
|
||||
final ConfigurationService configService = serviceRegistry.getService( ConfigurationService.class );
|
||||
final StrategySelector strategySelector = serviceRegistry.requireService( StrategySelector.class );
|
||||
final ConfigurationService configService = serviceRegistry.requireService( ConfigurationService.class );
|
||||
|
||||
this.jpaCompliance = new MutableJpaComplianceImpl( configService.getSettings() );
|
||||
this.scanOptions = new StandardScanOptions(
|
||||
|
|
|
@ -143,17 +143,17 @@ public class MetadataBuilderImpl implements MetadataBuilderImplementor, TypeCont
|
|||
|
||||
for ( MetadataSourcesContributor contributor :
|
||||
sources.getServiceRegistry()
|
||||
.getService( ClassLoaderService.class )
|
||||
.requireService( ClassLoaderService.class )
|
||||
.loadJavaServices( MetadataSourcesContributor.class ) ) {
|
||||
contributor.contribute( sources );
|
||||
}
|
||||
|
||||
// todo : not so sure this is needed anymore.
|
||||
// these should be set during the StandardServiceRegistryBuilder.configure call
|
||||
applyCfgXmlValues( serviceRegistry.getService( CfgXmlAccessService.class ) );
|
||||
applyCfgXmlValues( serviceRegistry.requireService( CfgXmlAccessService.class ) );
|
||||
|
||||
for ( MetadataBuilderInitializer contributor :
|
||||
serviceRegistry.getService( ClassLoaderService.class )
|
||||
serviceRegistry.requireService( ClassLoaderService.class )
|
||||
.loadJavaServices( MetadataBuilderInitializer.class ) ) {
|
||||
contributor.contribute( this, serviceRegistry );
|
||||
}
|
||||
|
@ -437,7 +437,7 @@ public class MetadataBuilderImpl implements MetadataBuilderImplementor, TypeCont
|
|||
|
||||
@Override
|
||||
public MetadataImplementor build() {
|
||||
final CfgXmlAccessService cfgXmlAccessService = options.serviceRegistry.getService( CfgXmlAccessService.class );
|
||||
final CfgXmlAccessService cfgXmlAccessService = options.serviceRegistry.requireService( CfgXmlAccessService.class );
|
||||
if ( cfgXmlAccessService.getAggregatedConfig() != null ) {
|
||||
if ( cfgXmlAccessService.getAggregatedConfig().getMappingReferences() != null ) {
|
||||
for ( MappingReference mappingReference : cfgXmlAccessService.getAggregatedConfig().getMappingReferences() ) {
|
||||
|
@ -468,7 +468,7 @@ public class MetadataBuilderImpl implements MetadataBuilderImplementor, TypeCont
|
|||
private CollectionClassification implicitListClassification;
|
||||
|
||||
public MappingDefaultsImpl(StandardServiceRegistry serviceRegistry) {
|
||||
final ConfigurationService configService = serviceRegistry.getService( ConfigurationService.class );
|
||||
final ConfigurationService configService = serviceRegistry.requireService( ConfigurationService.class );
|
||||
|
||||
// AvailableSettings.DEFAULT_SCHEMA and AvailableSettings.DEFAULT_CATALOG
|
||||
// are taken into account later, at runtime, when rendering table/sequence names.
|
||||
|
@ -620,8 +620,8 @@ public class MetadataBuilderImpl implements MetadataBuilderImplementor, TypeCont
|
|||
this.serviceRegistry = serviceRegistry;
|
||||
this.identifierGeneratorFactory = serviceRegistry.getService( IdentifierGeneratorFactory.class );
|
||||
|
||||
final StrategySelector strategySelector = serviceRegistry.getService( StrategySelector.class );
|
||||
final ConfigurationService configService = serviceRegistry.getService( ConfigurationService.class );
|
||||
final StrategySelector strategySelector = serviceRegistry.requireService( StrategySelector.class );
|
||||
final ConfigurationService configService = serviceRegistry.requireService( ConfigurationService.class );
|
||||
|
||||
this.mappingDefaults = new MappingDefaultsImpl( serviceRegistry );
|
||||
|
||||
|
@ -704,7 +704,7 @@ public class MetadataBuilderImpl implements MetadataBuilderImplementor, TypeCont
|
|||
// by default, see if the defined RegionFactory (if one) defines a default
|
||||
serviceRegistry.getService( RegionFactory.class ) == null
|
||||
? null
|
||||
: serviceRegistry.getService( RegionFactory.class ).getDefaultAccessType()
|
||||
: serviceRegistry.requireService( RegionFactory.class ).getDefaultAccessType()
|
||||
);
|
||||
|
||||
this.specjProprietarySyntaxEnabled = configService.getSetting(
|
||||
|
@ -821,7 +821,7 @@ public class MetadataBuilderImpl implements MetadataBuilderImplementor, TypeCont
|
|||
@Override
|
||||
public TimeZoneSupport getTimeZoneSupport() {
|
||||
try {
|
||||
return serviceRegistry.getService( JdbcServices.class )
|
||||
return serviceRegistry.requireService( JdbcServices.class )
|
||||
.getDialect()
|
||||
.getTimeZoneSupport();
|
||||
}
|
||||
|
@ -1021,7 +1021,7 @@ public class MetadataBuilderImpl implements MetadataBuilderImplementor, TypeCont
|
|||
);
|
||||
|
||||
if ( setting == WrapperArrayHandling.PICK ) {
|
||||
final Dialect dialect = serviceRegistry.getService( JdbcServices.class ).getDialect();
|
||||
final Dialect dialect = serviceRegistry.requireService( JdbcServices.class ).getDialect();
|
||||
if ( dialect.supportsStandardArrays()
|
||||
&& ( dialect.getPreferredSqlTypeCodeForArray() == SqlTypes.ARRAY
|
||||
|| dialect.getPreferredSqlTypeCodeForArray() == SqlTypes.SQLXML ) ) {
|
||||
|
|
|
@ -58,7 +58,6 @@ import org.hibernate.mapping.PersistentClass;
|
|||
import org.hibernate.mapping.PrimaryKey;
|
||||
import org.hibernate.mapping.Property;
|
||||
import org.hibernate.mapping.Table;
|
||||
import org.hibernate.mapping.UniqueKey;
|
||||
import org.hibernate.mapping.UserDefinedType;
|
||||
import org.hibernate.procedure.spi.NamedCallableQueryMemento;
|
||||
import org.hibernate.query.internal.NamedObjectRepositoryImpl;
|
||||
|
@ -166,10 +165,10 @@ public class MetadataImpl implements MetadataImplementor, Serializable {
|
|||
|
||||
@Override
|
||||
public SessionFactoryBuilder getSessionFactoryBuilder() {
|
||||
final SessionFactoryBuilderService factoryBuilderService = metadataBuildingOptions.getServiceRegistry().getService( SessionFactoryBuilderService.class );
|
||||
final SessionFactoryBuilderService factoryBuilderService = metadataBuildingOptions.getServiceRegistry().requireService( SessionFactoryBuilderService.class );
|
||||
final SessionFactoryBuilderImplementor defaultBuilder = factoryBuilderService.createSessionFactoryBuilder( this, bootstrapContext );
|
||||
|
||||
final ClassLoaderService cls = metadataBuildingOptions.getServiceRegistry().getService( ClassLoaderService.class );
|
||||
final ClassLoaderService cls = metadataBuildingOptions.getServiceRegistry().requireService( ClassLoaderService.class );
|
||||
final java.util.Collection<SessionFactoryBuilderFactory> discoveredBuilderFactories = cls.loadJavaServices( SessionFactoryBuilderFactory.class );
|
||||
|
||||
SessionFactoryBuilder builder = null;
|
||||
|
@ -464,7 +463,7 @@ public class MetadataImpl implements MetadataImplementor, Serializable {
|
|||
|
||||
private boolean shouldOrderTableColumns() {
|
||||
final ConfigurationService configurationService = metadataBuildingOptions.getServiceRegistry()
|
||||
.getService( ConfigurationService.class );
|
||||
.requireService( ConfigurationService.class );
|
||||
final Set<SchemaManagementToolCoordinator.ActionGrouping> groupings = SchemaManagementToolCoordinator.ActionGrouping.interpret(
|
||||
this,
|
||||
configurationService.getSettings()
|
||||
|
@ -515,9 +514,9 @@ public class MetadataImpl implements MetadataImplementor, Serializable {
|
|||
|
||||
assert sessionFactoryServiceRegistry != null;
|
||||
|
||||
final EventListenerRegistry eventListenerRegistry = sessionFactoryServiceRegistry.getService( EventListenerRegistry.class );
|
||||
final ConfigurationService cfgService = sessionFactoryServiceRegistry.getService( ConfigurationService.class );
|
||||
final ClassLoaderService classLoaderService = sessionFactoryServiceRegistry.getService( ClassLoaderService.class );
|
||||
final EventListenerRegistry eventListenerRegistry = sessionFactoryServiceRegistry.requireService( EventListenerRegistry.class );
|
||||
final ConfigurationService cfgService = sessionFactoryServiceRegistry.requireService( ConfigurationService.class );
|
||||
final ClassLoaderService classLoaderService = sessionFactoryServiceRegistry.requireService( ClassLoaderService.class );
|
||||
|
||||
for ( Map.Entry<String,Object> entry : cfgService.getSettings().entrySet() ) {
|
||||
final String propertyName = entry.getKey();
|
||||
|
|
|
@ -92,7 +92,7 @@ public class NamedNativeQueryDefinitionImpl extends AbstractNamedQueryDefinition
|
|||
sqlString,
|
||||
resultSetMappingName,
|
||||
isNotEmpty( resultSetMappingClassName )
|
||||
? factory.getServiceRegistry().getService( ClassLoaderService.class )
|
||||
? factory.getServiceRegistry().requireService( ClassLoaderService.class )
|
||||
.classForName( resultSetMappingClassName )
|
||||
: null,
|
||||
querySpaces,
|
||||
|
|
|
@ -280,12 +280,9 @@ public class SessionFactoryOptionsBuilder implements SessionFactoryOptions {
|
|||
this.serviceRegistry = serviceRegistry;
|
||||
this.jpaBootstrap = context.isJpaBootstrap();
|
||||
|
||||
final StrategySelector strategySelector = serviceRegistry.getService( StrategySelector.class );
|
||||
final ConfigurationService configurationService = serviceRegistry.getService( ConfigurationService.class );
|
||||
final JdbcServices jdbcServices = serviceRegistry.getService( JdbcServices.class );
|
||||
|
||||
assert jdbcServices != null;
|
||||
assert configurationService != null;
|
||||
final StrategySelector strategySelector = serviceRegistry.requireService( StrategySelector.class );
|
||||
final ConfigurationService configurationService = serviceRegistry.requireService( ConfigurationService.class );
|
||||
final JdbcServices jdbcServices = serviceRegistry.requireService( JdbcServices.class );
|
||||
|
||||
final Dialect dialect = jdbcServices.getJdbcEnvironment().getDialect();
|
||||
|
||||
|
@ -650,7 +647,7 @@ public class SessionFactoryOptionsBuilder implements SessionFactoryOptions {
|
|||
try {
|
||||
if ( dialectConstructor != null ) {
|
||||
return dialectConstructor.newInstance(
|
||||
serviceRegistry.getService( JdbcServices.class ).getDialect()
|
||||
serviceRegistry.requireService( JdbcServices.class ).getDialect()
|
||||
);
|
||||
}
|
||||
else if ( emptyConstructor != null ) {
|
||||
|
@ -699,7 +696,7 @@ public class SessionFactoryOptionsBuilder implements SessionFactoryOptions {
|
|||
try {
|
||||
if ( dialectConstructor != null ) {
|
||||
return dialectConstructor.newInstance(
|
||||
serviceRegistry.getService( JdbcServices.class ).getDialect()
|
||||
serviceRegistry.requireService( JdbcServices.class ).getDialect()
|
||||
);
|
||||
}
|
||||
else if ( emptyConstructor != null ) {
|
||||
|
@ -732,8 +729,8 @@ public class SessionFactoryOptionsBuilder implements SessionFactoryOptions {
|
|||
new Callable<>() {
|
||||
@Override
|
||||
public HqlTranslator call() throws Exception {
|
||||
final ClassLoaderService classLoaderService = serviceRegistry.getService( ClassLoaderService.class );
|
||||
return (HqlTranslator) classLoaderService.classForName( producerName ).newInstance();
|
||||
return (HqlTranslator) serviceRegistry.requireService( ClassLoaderService.class )
|
||||
.classForName( producerName ).newInstance();
|
||||
}
|
||||
}
|
||||
);
|
||||
|
@ -812,8 +809,7 @@ public class SessionFactoryOptionsBuilder implements SessionFactoryOptions {
|
|||
return specifiedHandlingMode;
|
||||
}
|
||||
|
||||
final TransactionCoordinatorBuilder transactionCoordinatorBuilder = serviceRegistry.getService( TransactionCoordinatorBuilder.class );
|
||||
return transactionCoordinatorBuilder.getDefaultConnectionHandlingMode();
|
||||
return serviceRegistry.requireService( TransactionCoordinatorBuilder.class ).getDefaultConnectionHandlingMode();
|
||||
}
|
||||
|
||||
private static FormatMapper determineJsonFormatMapper(Object setting, StrategySelector strategySelector) {
|
||||
|
|
|
@ -152,9 +152,8 @@ public class RegisteredConversion {
|
|||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public JpaAttributeConverter<?, ?> createJpaAttributeConverter(JpaAttributeConverterCreationContext context) {
|
||||
final ManagedBean<? extends AttributeConverter<?, ?>> converterBean = context
|
||||
.getManagedBeanRegistry()
|
||||
.getBean( converterType );
|
||||
final ManagedBean<? extends AttributeConverter<?, ?>> converterBean =
|
||||
context.getManagedBeanRegistry().getBean( converterType );
|
||||
|
||||
final TypeConfiguration typeConfiguration = context.getTypeConfiguration();
|
||||
final JavaTypeRegistry javaTypeRegistry = typeConfiguration.getJavaTypeRegistry();
|
||||
|
|
|
@ -813,9 +813,10 @@ public final class AnnotationBinder {
|
|||
return FallbackBeanInstanceProducer.INSTANCE.produceBeanInstance( javaTypeClass );
|
||||
}
|
||||
|
||||
final StandardServiceRegistry serviceRegistry = context.getBootstrapContext().getServiceRegistry();
|
||||
final ManagedBeanRegistry beanRegistry = serviceRegistry.getService( ManagedBeanRegistry.class );
|
||||
return beanRegistry.getBean(javaTypeClass).getBeanInstance();
|
||||
return context.getBootstrapContext().getServiceRegistry()
|
||||
.requireService( ManagedBeanRegistry.class )
|
||||
.getBean( javaTypeClass )
|
||||
.getBeanInstance();
|
||||
}
|
||||
|
||||
public static void bindFetchProfilesForClass(XClass annotatedClass, MetadataBuildingContext context) {
|
||||
|
|
|
@ -543,7 +543,7 @@ public class BasicValueBinder implements JdbcTypeIndicators {
|
|||
private ManagedBeanRegistry getManagedBeanRegistry() {
|
||||
return buildingContext.getBootstrapContext()
|
||||
.getServiceRegistry()
|
||||
.getService(ManagedBeanRegistry.class);
|
||||
.requireService(ManagedBeanRegistry.class);
|
||||
}
|
||||
|
||||
private void prepareMapKey(
|
||||
|
@ -667,10 +667,9 @@ public class BasicValueBinder implements JdbcTypeIndicators {
|
|||
implicitJavaTypeAccess = typeConfiguration -> Integer.class;
|
||||
|
||||
final boolean useDeferredBeanContainerAccess = !buildingContext.getBuildingOptions().isAllowExtensionsInCdi();
|
||||
final ManagedBeanRegistry beanRegistry = buildingContext
|
||||
.getBootstrapContext()
|
||||
.getServiceRegistry()
|
||||
.getService( ManagedBeanRegistry.class );
|
||||
final ManagedBeanRegistry beanRegistry =
|
||||
buildingContext.getBootstrapContext().getServiceRegistry()
|
||||
.requireService( ManagedBeanRegistry.class );
|
||||
|
||||
explicitJavaTypeAccess = (typeConfiguration) -> {
|
||||
final ListIndexJavaType javaTypeAnn = findAnnotation( listAttribute, ListIndexJavaType.class );
|
||||
|
|
|
@ -1174,10 +1174,9 @@ public class BinderHelper {
|
|||
final String declaringClassName = xClass.getName();
|
||||
final String packageName = qualifier( declaringClassName );
|
||||
if ( isNotEmpty( packageName ) ) {
|
||||
final ClassLoaderService classLoaderService = context.getBootstrapContext()
|
||||
.getServiceRegistry()
|
||||
.getService( ClassLoaderService.class );
|
||||
assert classLoaderService != null;
|
||||
final ClassLoaderService classLoaderService =
|
||||
context.getBootstrapContext().getServiceRegistry()
|
||||
.requireService( ClassLoaderService.class );
|
||||
final Package declaringClassPackage = classLoaderService.packageForNameOrNull( packageName );
|
||||
if ( declaringClassPackage != null ) {
|
||||
// will be null when there is no `package-info.class`
|
||||
|
|
|
@ -893,10 +893,10 @@ public abstract class CollectionBinder {
|
|||
return MappingHelper.createLocalUserCollectionTypeBean( role, implementation, hasParameters, parameters );
|
||||
}
|
||||
|
||||
final ManagedBeanRegistry beanRegistry = buildingContext.getBuildingOptions()
|
||||
.getServiceRegistry()
|
||||
.getService( ManagedBeanRegistry.class );
|
||||
final ManagedBean<? extends UserCollectionType> managedBean = beanRegistry.getBean( implementation );
|
||||
final ManagedBean<? extends UserCollectionType> managedBean =
|
||||
buildingContext.getBuildingOptions().getServiceRegistry()
|
||||
.requireService( ManagedBeanRegistry.class )
|
||||
.getBean( implementation );
|
||||
|
||||
if ( hasParameters ) {
|
||||
if ( ParameterizedType.class.isAssignableFrom( managedBean.getBeanClass() ) ) {
|
||||
|
|
|
@ -423,7 +423,7 @@ public class EmbeddableBinder {
|
|||
|
||||
return context.getBootstrapContext()
|
||||
.getServiceRegistry()
|
||||
.getService( ManagedBeanRegistry.class )
|
||||
.requireService( ManagedBeanRegistry.class )
|
||||
.getBean( compositeUserTypeClass )
|
||||
.getBeanInstance();
|
||||
}
|
||||
|
|
|
@ -66,7 +66,7 @@ public class NamedConverterResolution<J> implements BasicValue.Resolution<J> {
|
|||
|
||||
final ClassBasedConverterDescriptor converterDescriptor = new ClassBasedConverterDescriptor(
|
||||
context.getBootstrapContext().getServiceRegistry()
|
||||
.getService( ClassLoaderService.class )
|
||||
.requireService( ClassLoaderService.class )
|
||||
.classForName( converterClassName ),
|
||||
context.getBootstrapContext().getClassmateContext()
|
||||
);
|
||||
|
|
|
@ -34,7 +34,6 @@ import org.hibernate.boot.registry.classloading.spi.ClassLoadingException;
|
|||
import org.hibernate.boot.spi.BootstrapContext;
|
||||
import org.hibernate.boot.spi.ClassLoaderAccess;
|
||||
import org.hibernate.boot.spi.XmlMappingBinderAccess;
|
||||
import org.hibernate.service.ServiceRegistry;
|
||||
|
||||
import org.jboss.logging.Logger;
|
||||
|
||||
|
@ -63,10 +62,9 @@ public class ScanningCoordinator {
|
|||
return;
|
||||
}
|
||||
|
||||
final ClassLoaderService classLoaderService = bootstrapContext.getServiceRegistry().getService( ClassLoaderService.class );
|
||||
final ClassLoaderAccess classLoaderAccess = new ClassLoaderAccessImpl(
|
||||
bootstrapContext.getJpaTempClassLoader(),
|
||||
classLoaderService
|
||||
bootstrapContext.getServiceRegistry().requireService( ClassLoaderService.class )
|
||||
);
|
||||
|
||||
// NOTE : the idea with JandexInitializer/JandexInitManager was to allow adding classes
|
||||
|
@ -81,7 +79,7 @@ public class ScanningCoordinator {
|
|||
applyScanResultsToManagedResources( managedResources, scanResult, bootstrapContext, xmlMappingBinderAccess );
|
||||
}
|
||||
|
||||
private static final Class[] SINGLE_ARG = new Class[] { ArchiveDescriptorFactory.class };
|
||||
private static final Class<?>[] SINGLE_ARG = new Class[] { ArchiveDescriptorFactory.class };
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private static Scanner buildScanner(BootstrapContext bootstrapContext, ClassLoaderAccess classLoaderAccess) {
|
||||
|
@ -121,7 +119,7 @@ public class ScanningCoordinator {
|
|||
|
||||
|
||||
if ( archiveDescriptorFactory != null ) {
|
||||
// find the single-arg constructor - its an error if none exists
|
||||
// find the single-arg constructor - it's an error if none exists
|
||||
try {
|
||||
final Constructor<? extends Scanner> constructor = scannerImplClass.getConstructor( SINGLE_ARG );
|
||||
try {
|
||||
|
@ -190,8 +188,8 @@ public class ScanningCoordinator {
|
|||
XmlMappingBinderAccess xmlMappingBinderAccess) {
|
||||
|
||||
final ScanEnvironment scanEnvironment = bootstrapContext.getScanEnvironment();
|
||||
final ServiceRegistry serviceRegistry = bootstrapContext.getServiceRegistry();
|
||||
final ClassLoaderService classLoaderService = serviceRegistry.getService( ClassLoaderService.class );
|
||||
final ClassLoaderService classLoaderService =
|
||||
bootstrapContext.getServiceRegistry().requireService( ClassLoaderService.class );
|
||||
|
||||
|
||||
// mapping files ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
|
|
@ -141,7 +141,8 @@ public class MetadataBuildingProcess {
|
|||
final MetadataSources sources,
|
||||
final BootstrapContext bootstrapContext) {
|
||||
final ManagedResourcesImpl managedResources = ManagedResourcesImpl.baseline( sources, bootstrapContext );
|
||||
final ConfigurationService configService = bootstrapContext.getServiceRegistry().getService( ConfigurationService.class );
|
||||
final ConfigurationService configService =
|
||||
bootstrapContext.getServiceRegistry().requireService( ConfigurationService.class );
|
||||
final boolean xmlMappingEnabled = configService.getSetting(
|
||||
AvailableSettings.XML_MAPPING_ENABLED,
|
||||
StandardConverters.BOOLEAN,
|
||||
|
@ -174,7 +175,8 @@ public class MetadataBuildingProcess {
|
|||
|
||||
handleTypes( bootstrapContext, options, metadataCollector );
|
||||
|
||||
final ClassLoaderService classLoaderService = options.getServiceRegistry().getService( ClassLoaderService.class );
|
||||
final ClassLoaderService classLoaderService =
|
||||
options.getServiceRegistry().requireService( ClassLoaderService.class );
|
||||
|
||||
final MetadataBuildingContextRootImpl rootMetadataBuildingContext = new MetadataBuildingContextRootImpl(
|
||||
"orm",
|
||||
|
@ -594,7 +596,8 @@ public class MetadataBuildingProcess {
|
|||
BootstrapContext bootstrapContext,
|
||||
MetadataBuildingOptions options,
|
||||
InFlightMetadataCollector metadataCollector) {
|
||||
final ClassLoaderService classLoaderService = options.getServiceRegistry().getService(ClassLoaderService.class);
|
||||
final ClassLoaderService classLoaderService =
|
||||
options.getServiceRegistry().requireService(ClassLoaderService.class);
|
||||
|
||||
final TypeConfiguration typeConfiguration = bootstrapContext.getTypeConfiguration();
|
||||
final StandardServiceRegistry serviceRegistry = bootstrapContext.getServiceRegistry();
|
||||
|
@ -632,7 +635,7 @@ public class MetadataBuildingProcess {
|
|||
}
|
||||
|
||||
// add Dialect contributed types
|
||||
final Dialect dialect = options.getServiceRegistry().getService( JdbcServices.class ).getDialect();
|
||||
final Dialect dialect = options.getServiceRegistry().requireService( JdbcServices.class ).getDialect();
|
||||
dialect.contribute( typeContributions, options.getServiceRegistry() );
|
||||
// Capture the dialect configured JdbcTypes so that we can detect if a TypeContributor overwrote them,
|
||||
// which has precedence over the fallback and preferred type registrations
|
||||
|
|
|
@ -66,7 +66,7 @@ public class Database {
|
|||
}
|
||||
|
||||
private static Dialect determineDialect(MetadataBuildingOptions buildingOptions) {
|
||||
final Dialect dialect = buildingOptions.getServiceRegistry().getService( JdbcServices.class ).getDialect();
|
||||
final Dialect dialect = buildingOptions.getServiceRegistry().requireService( JdbcServices.class ).getDialect();
|
||||
if ( dialect != null ) {
|
||||
return dialect;
|
||||
}
|
||||
|
|
|
@ -73,8 +73,11 @@ public class AnnotationMetadataSourceProcessorImpl implements MetadataSourceProc
|
|||
annotatedPackages.addAll( managedResources.getAnnotatedPackageNames() );
|
||||
}
|
||||
|
||||
final ConverterRegistry converterRegistry = rootMetadataBuildingContext.getMetadataCollector().getConverterRegistry();
|
||||
this.classLoaderService = rootMetadataBuildingContext.getBuildingOptions().getServiceRegistry().getService( ClassLoaderService.class );
|
||||
final ConverterRegistry converterRegistry =
|
||||
rootMetadataBuildingContext.getMetadataCollector().getConverterRegistry();
|
||||
this.classLoaderService =
|
||||
rootMetadataBuildingContext.getBuildingOptions().getServiceRegistry()
|
||||
.requireService( ClassLoaderService.class );
|
||||
|
||||
MetadataBuildingOptions metadataBuildingOptions = rootMetadataBuildingContext.getBuildingOptions();
|
||||
if ( metadataBuildingOptions.isXmlMappingEnabled() ) {
|
||||
|
|
|
@ -33,7 +33,7 @@ public class AuxiliaryDatabaseObjectBinder {
|
|||
try {
|
||||
auxDbObject = (AuxiliaryDatabaseObject) context.getBuildingOptions()
|
||||
.getServiceRegistry()
|
||||
.getService( ClassLoaderService.class )
|
||||
.requireService( ClassLoaderService.class )
|
||||
.classForName( auxDbObjectImplClass )
|
||||
.newInstance();
|
||||
}
|
||||
|
|
|
@ -210,7 +210,7 @@ public class ModelBinder {
|
|||
final Object explicitSetting = buildingContext
|
||||
.getBuildingOptions()
|
||||
.getServiceRegistry()
|
||||
.getService( ConfigurationService.class )
|
||||
.requireService( ConfigurationService.class )
|
||||
.getSettings()
|
||||
.get( USE_ENTITY_WHERE_CLAUSE_FOR_COLLECTIONS );
|
||||
if ( explicitSetting != null ) {
|
||||
|
@ -2627,7 +2627,7 @@ public class ModelBinder {
|
|||
else {
|
||||
compositeUserType = (CompositeUserType<?>) sourceDocument.getBootstrapContext()
|
||||
.getServiceRegistry()
|
||||
.getService( ManagedBeanRegistry.class )
|
||||
.requireService( ManagedBeanRegistry.class )
|
||||
.getBean( componentClass )
|
||||
.getBeanInstance();
|
||||
}
|
||||
|
|
|
@ -27,11 +27,12 @@ public class TypeDefinitionBinder {
|
|||
public static void processTypeDefinition(
|
||||
HbmLocalMetadataBuildingContext context,
|
||||
JaxbHbmTypeDefinitionType typeDefinitionBinding) {
|
||||
final ClassLoaderService cls = context.getBuildingOptions().getServiceRegistry().getService( ClassLoaderService.class );
|
||||
|
||||
final TypeDefinition definition = new TypeDefinition(
|
||||
typeDefinitionBinding.getName(),
|
||||
cls.classForName( typeDefinitionBinding.getClazz() ),
|
||||
context.getBuildingOptions().getServiceRegistry()
|
||||
.requireService( ClassLoaderService.class )
|
||||
.classForName( typeDefinitionBinding.getClazz() ),
|
||||
null,
|
||||
ConfigParameterHelper.extractConfigParameters( typeDefinitionBinding )
|
||||
);
|
||||
|
|
|
@ -376,7 +376,7 @@ public class StandardServiceRegistryBuilder {
|
|||
|
||||
private void applyServiceContributors() {
|
||||
final Iterable<ServiceContributor> serviceContributors =
|
||||
bootstrapServiceRegistry.getService( ClassLoaderService.class )
|
||||
bootstrapServiceRegistry.requireService( ClassLoaderService.class )
|
||||
.loadJavaServices( ServiceContributor.class );
|
||||
|
||||
for ( ServiceContributor serviceContributor : serviceContributors ) {
|
||||
|
|
|
@ -86,7 +86,7 @@ public interface MetadataBuildingContext {
|
|||
}
|
||||
|
||||
static boolean isPreferJavaTimeJdbcTypesEnabled(ServiceRegistry serviceRegistry) {
|
||||
return isPreferJavaTimeJdbcTypesEnabled( serviceRegistry.getService( ConfigurationService.class ) );
|
||||
return isPreferJavaTimeJdbcTypesEnabled( serviceRegistry.requireService( ConfigurationService.class ) );
|
||||
}
|
||||
|
||||
static boolean isPreferJavaTimeJdbcTypesEnabled(ConfigurationService configurationService) {
|
||||
|
|
|
@ -46,8 +46,9 @@ public final class BytecodeProviderInitiator implements StandardServiceInitiator
|
|||
|
||||
@Override
|
||||
public BytecodeProvider initiateService(Map<String, Object> configurationValues, ServiceRegistryImplementor registry) {
|
||||
final ClassLoaderService classLoaderService = castNonNull( registry.getService( ClassLoaderService.class ) );
|
||||
final Collection<BytecodeProvider> bytecodeProviders = classLoaderService.loadJavaServices( BytecodeProvider.class );
|
||||
final Collection<BytecodeProvider> bytecodeProviders =
|
||||
registry.requireService( ClassLoaderService.class )
|
||||
.loadJavaServices( BytecodeProvider.class );
|
||||
return getBytecodeProvider( bytecodeProviders );
|
||||
}
|
||||
|
||||
|
|
|
@ -28,8 +28,7 @@ public final class ProxyFactoryFactoryInitiator implements StandardServiceInitia
|
|||
|
||||
@Override
|
||||
public ProxyFactoryFactory initiateService(Map<String, Object> configurationValues, ServiceRegistryImplementor registry) {
|
||||
final BytecodeProvider bytecodeProvider = registry.getService( BytecodeProvider.class );
|
||||
return bytecodeProvider.getProxyFactoryFactory();
|
||||
return registry.requireService( BytecodeProvider.class ).getProxyFactoryFactory();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -94,7 +94,7 @@ public class CollectionCacheInvalidator
|
|||
// Nothing to do, if caching is disabled
|
||||
return;
|
||||
}
|
||||
EventListenerRegistry eventListenerRegistry = serviceRegistry.getService( EventListenerRegistry.class );
|
||||
EventListenerRegistry eventListenerRegistry = serviceRegistry.requireService( EventListenerRegistry.class );
|
||||
eventListenerRegistry.appendListeners( EventType.POST_INSERT, this );
|
||||
eventListenerRegistry.appendListeners( EventType.POST_DELETE, this );
|
||||
eventListenerRegistry.appendListeners( EventType.POST_UPDATE, this );
|
||||
|
|
|
@ -19,7 +19,6 @@ import org.hibernate.cache.spi.access.CollectionDataAccess;
|
|||
import org.hibernate.cache.spi.access.EntityDataAccess;
|
||||
import org.hibernate.cache.spi.access.NaturalIdDataAccess;
|
||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||
import org.hibernate.internal.util.collections.ArrayHelper;
|
||||
import org.hibernate.metamodel.model.domain.NavigableRole;
|
||||
|
||||
/**
|
||||
|
|
|
@ -79,7 +79,9 @@ public class EnabledCaching implements CacheImplementor, DomainDataRegionBuildin
|
|||
public EnabledCaching(SessionFactoryImplementor sessionFactory) {
|
||||
this.sessionFactory = sessionFactory;
|
||||
|
||||
this.regionFactory = getSessionFactory().getSessionFactoryOptions().getServiceRegistry().getService( RegionFactory.class );
|
||||
this.regionFactory =
|
||||
getSessionFactory().getSessionFactoryOptions().getServiceRegistry()
|
||||
.requireService( RegionFactory.class );
|
||||
this.regionFactory.start( sessionFactory.getSessionFactoryOptions(), sessionFactory.getProperties() );
|
||||
|
||||
if ( getSessionFactory().getSessionFactoryOptions().isQueryCacheEnabled() ) {
|
||||
|
|
|
@ -83,7 +83,7 @@ public class RegionFactoryInitiator implements StandardServiceInitiator<RegionFa
|
|||
|
||||
final Object setting = configurationValues.get( AvailableSettings.CACHE_REGION_FACTORY );
|
||||
|
||||
final StrategySelector selector = registry.getService( StrategySelector.class );
|
||||
final StrategySelector selector = registry.requireService( StrategySelector.class );
|
||||
final Collection<Class<? extends RegionFactory>> implementors = selector.getRegisteredStrategyImplementors( RegionFactory.class );
|
||||
|
||||
if ( setting == null && implementors.size() != 1 ) {
|
||||
|
@ -93,7 +93,7 @@ public class RegionFactoryInitiator implements StandardServiceInitiator<RegionFa
|
|||
}
|
||||
}
|
||||
|
||||
final RegionFactory regionFactory = registry.getService( StrategySelector.class ).resolveStrategy(
|
||||
final RegionFactory regionFactory = registry.requireService( StrategySelector.class ).resolveStrategy(
|
||||
RegionFactory.class,
|
||||
setting,
|
||||
(RegionFactory) null,
|
||||
|
|
|
@ -63,7 +63,7 @@ public class JTASessionContext extends AbstractCurrentSessionContext {
|
|||
|
||||
@Override
|
||||
public Session currentSession() throws HibernateException {
|
||||
final JtaPlatform jtaPlatform = factory().getServiceRegistry().getService( JtaPlatform.class );
|
||||
final JtaPlatform jtaPlatform = factory().getServiceRegistry().requireService( JtaPlatform.class );
|
||||
final TransactionManager transactionManager = jtaPlatform.retrieveTransactionManager();
|
||||
if ( transactionManager == null ) {
|
||||
throw new HibernateException( "No TransactionManagerLookup specified" );
|
||||
|
|
|
@ -251,8 +251,7 @@ public abstract class AbstractHANADialect extends Dialect {
|
|||
public void contribute(TypeContributions typeContributions, ServiceRegistry serviceRegistry) {
|
||||
// This is the best hook for consuming dialect configuration that we have for now,
|
||||
// since this method is called very early in the bootstrap process
|
||||
final ConfigurationService configurationService = serviceRegistry.getService( ConfigurationService.class );
|
||||
assert configurationService != null;
|
||||
final ConfigurationService configurationService = serviceRegistry.requireService( ConfigurationService.class );
|
||||
|
||||
this.defaultTableTypeColumn = configurationService.getSetting(
|
||||
USE_DEFAULT_TABLE_TYPE_COLUMN,
|
||||
|
|
|
@ -882,7 +882,7 @@ public class OracleDialect extends Dialect {
|
|||
|
||||
// account for Oracle's deprecated support for LONGVARBINARY
|
||||
// prefer BLOB, unless the user explicitly opts out
|
||||
boolean preferLong = serviceRegistry.getService( ConfigurationService.class ).getSetting(
|
||||
boolean preferLong = serviceRegistry.requireService( ConfigurationService.class ).getSetting(
|
||||
PREFER_LONG_RAW,
|
||||
StandardConverters.BOOLEAN,
|
||||
false
|
||||
|
|
|
@ -24,7 +24,7 @@ import org.hibernate.type.descriptor.jdbc.JdbcTypeConstructor;
|
|||
public class OracleJdbcHelper {
|
||||
|
||||
public static boolean isUsable(ServiceRegistry serviceRegistry) {
|
||||
final ClassLoaderService classLoaderService = serviceRegistry.getService( ClassLoaderService.class );
|
||||
final ClassLoaderService classLoaderService = serviceRegistry.requireService( ClassLoaderService.class );
|
||||
try {
|
||||
classLoaderService.classForName( "oracle.jdbc.OracleConnection" );
|
||||
return true;
|
||||
|
@ -47,7 +47,7 @@ public class OracleJdbcHelper {
|
|||
}
|
||||
|
||||
private static <X> X create(ServiceRegistry serviceRegistry, String className) {
|
||||
final ClassLoaderService classLoaderService = serviceRegistry.getService( ClassLoaderService.class );
|
||||
final ClassLoaderService classLoaderService = serviceRegistry.requireService( ClassLoaderService.class );
|
||||
try {
|
||||
return classLoaderService.<X>classForName( className ).getConstructor().newInstance();
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ import org.hibernate.type.descriptor.jdbc.JdbcType;
|
|||
public final class PgJdbcHelper {
|
||||
|
||||
public static boolean isUsable(ServiceRegistry serviceRegistry) {
|
||||
final ClassLoaderService classLoaderService = serviceRegistry.getService( ClassLoaderService.class );
|
||||
final ClassLoaderService classLoaderService = serviceRegistry.requireService( ClassLoaderService.class );
|
||||
try {
|
||||
classLoaderService.classForName( "org.postgresql.util.PGobject" );
|
||||
return true;
|
||||
|
@ -55,7 +55,7 @@ public final class PgJdbcHelper {
|
|||
}
|
||||
|
||||
public static JdbcType createJdbcType(ServiceRegistry serviceRegistry, String className) {
|
||||
final ClassLoaderService classLoaderService = serviceRegistry.getService( ClassLoaderService.class );
|
||||
final ClassLoaderService classLoaderService = serviceRegistry.requireService( ClassLoaderService.class );
|
||||
try {
|
||||
final Class<?> clazz = classLoaderService.classForName( className );
|
||||
final Constructor<?> constructor = clazz.getConstructor();
|
||||
|
|
|
@ -93,7 +93,8 @@ public class ConfigurationServiceImpl implements ConfigurationService, ServiceRe
|
|||
}
|
||||
else {
|
||||
try {
|
||||
target = NullnessUtil.castNonNull( serviceRegistry.getService( ClassLoaderService.class ) ).classForName( candidate.toString() );
|
||||
target = serviceRegistry.requireService( ClassLoaderService.class )
|
||||
.classForName( candidate.toString() );
|
||||
}
|
||||
catch ( ClassLoadingException e ) {
|
||||
LOG.debugf( "Unable to locate %s implementation class %s", expected.getName(), candidate.toString() );
|
||||
|
|
|
@ -525,7 +525,7 @@ public class EntityEntryContext {
|
|||
final String entityEntryClassName = new String( entityEntryClassNameArr );
|
||||
final Class<?> entityEntryClass =
|
||||
rtn.getSession().getFactory().getServiceRegistry()
|
||||
.getService( ClassLoaderService.class )
|
||||
.requireService( ClassLoaderService.class )
|
||||
.classForName( entityEntryClassName );
|
||||
|
||||
try {
|
||||
|
|
|
@ -54,7 +54,7 @@ public class BatchBuilderInitiator implements StandardServiceInitiator<BatchBuil
|
|||
|
||||
final String builderClassName = builder.toString();
|
||||
try {
|
||||
return (BatchBuilder) registry.getService( ClassLoaderService.class )
|
||||
return (BatchBuilder) registry.requireService( ClassLoaderService.class )
|
||||
.classForName( builderClassName )
|
||||
.getConstructor()
|
||||
.newInstance();
|
||||
|
|
|
@ -113,7 +113,7 @@ public class ConnectionProviderInitiator implements StandardServiceInitiator<Con
|
|||
return new DatasourceConnectionProviderImpl();
|
||||
}
|
||||
|
||||
final StrategySelector strategySelector = registry.getService( StrategySelector.class );
|
||||
final StrategySelector strategySelector = registry.requireService( StrategySelector.class );
|
||||
final Object explicitSetting = configurationValues.get( AvailableSettings.CONNECTION_PROVIDER );
|
||||
if ( explicitSetting != null ) {
|
||||
// if we are explicitly supplied a ConnectionProvider to use (in some form) -> use it..
|
||||
|
|
|
@ -207,7 +207,7 @@ public class DriverManagerConnectionProviderImpl
|
|||
}
|
||||
|
||||
if ( serviceRegistry != null ) {
|
||||
final ClassLoaderService classLoaderService = serviceRegistry.getService( ClassLoaderService.class );
|
||||
final ClassLoaderService classLoaderService = serviceRegistry.requireService( ClassLoaderService.class );
|
||||
final Class<Driver> driverClass = classLoaderService.classForName( driverClassName );
|
||||
try {
|
||||
return driverClass.newInstance();
|
||||
|
@ -232,8 +232,9 @@ public class DriverManagerConnectionProviderImpl
|
|||
}
|
||||
|
||||
if ( serviceRegistry != null ) {
|
||||
final ClassLoaderService classLoaderService = serviceRegistry.getService( ClassLoaderService.class );
|
||||
final Class<ConnectionCreatorFactory> factoryClass = classLoaderService.classForName( connectionCreatorFactoryClassName );
|
||||
final ClassLoaderService classLoaderService = serviceRegistry.requireService( ClassLoaderService.class );
|
||||
final Class<ConnectionCreatorFactory> factoryClass =
|
||||
classLoaderService.classForName( connectionCreatorFactoryClassName );
|
||||
try {
|
||||
return factoryClass.newInstance();
|
||||
}
|
||||
|
|
|
@ -69,7 +69,7 @@ public class MultiTenantConnectionProviderInitiator implements StandardServiceIn
|
|||
}
|
||||
else {
|
||||
final String className = configValue.toString();
|
||||
final ClassLoaderService classLoaderService = registry.getService( ClassLoaderService.class );
|
||||
final ClassLoaderService classLoaderService = registry.requireService( ClassLoaderService.class );
|
||||
try {
|
||||
implClass = classLoaderService.classForName( className );
|
||||
}
|
||||
|
|
|
@ -71,9 +71,9 @@ public class DataSourceBasedMultiTenantConnectionProviderImpl<T>
|
|||
|
||||
@Override
|
||||
public void injectServices(ServiceRegistryImplementor serviceRegistry) {
|
||||
final Object dataSourceConfigValue = serviceRegistry.getService( ConfigurationService.class )
|
||||
.getSettings()
|
||||
.get( AvailableSettings.DATASOURCE );
|
||||
final Object dataSourceConfigValue =
|
||||
serviceRegistry.requireService( ConfigurationService.class )
|
||||
.getSettings().get( AvailableSettings.DATASOURCE );
|
||||
if ( !(dataSourceConfigValue instanceof String) ) {
|
||||
throw new HibernateException( "Improper set up of DataSourceBasedMultiTenantConnectionProviderImpl" );
|
||||
}
|
||||
|
@ -97,7 +97,7 @@ public class DataSourceBasedMultiTenantConnectionProviderImpl<T>
|
|||
}
|
||||
else if ( namedObject instanceof Context ) {
|
||||
this.baseJndiNamespace = jndiName;
|
||||
this.tenantIdentifierForAny = (T) serviceRegistry.getService( ConfigurationService.class )
|
||||
this.tenantIdentifierForAny = (T) serviceRegistry.requireService( ConfigurationService.class )
|
||||
.getSettings()
|
||||
.get( TENANT_IDENTIFIER_TO_USE_FOR_ANY_KEY );
|
||||
if ( tenantIdentifierForAny == null ) {
|
||||
|
|
|
@ -26,15 +26,11 @@ public class RefCursorSupportInitiator implements StandardServiceInitiator<RefCu
|
|||
|
||||
@Override
|
||||
public RefCursorSupport initiateService(Map<String, Object> configurationValues, ServiceRegistryImplementor registry) {
|
||||
final JdbcServices jdbcServices = registry.getService( JdbcServices.class );
|
||||
assert jdbcServices != null;
|
||||
final JdbcServices jdbcServices = registry.requireService( JdbcServices.class );
|
||||
final boolean supportsRefCursors = useRefCursorSupport( jdbcServices );
|
||||
if ( supportsRefCursors ) {
|
||||
return new StandardRefCursorSupport( jdbcServices );
|
||||
}
|
||||
else {
|
||||
return new FallbackRefCursorSupport( jdbcServices );
|
||||
}
|
||||
return supportsRefCursors
|
||||
? new StandardRefCursorSupport( jdbcServices )
|
||||
: new FallbackRefCursorSupport (jdbcServices );
|
||||
}
|
||||
|
||||
private boolean useRefCursorSupport(JdbcServices jdbcServices) {
|
||||
|
|
|
@ -50,11 +50,12 @@ public class DialectResolverInitiator implements StandardServiceInitiator<Dialec
|
|||
Map<?,?> configurationValues) {
|
||||
final String resolverImplNames = (String) configurationValues.get( AvailableSettings.DIALECT_RESOLVERS );
|
||||
|
||||
final ClassLoaderService classLoaderService = registry.getService( ClassLoaderService.class );
|
||||
final ClassLoaderService classLoaderService = registry.requireService( ClassLoaderService.class );
|
||||
if ( StringHelper.isNotEmpty( resolverImplNames ) ) {
|
||||
for ( String resolverImplName : StringHelper.split( ", \n\r\f\t", resolverImplNames ) ) {
|
||||
try {
|
||||
DialectResolver dialectResolver = (DialectResolver) classLoaderService.classForName(resolverImplName).newInstance();
|
||||
final DialectResolver dialectResolver = (DialectResolver)
|
||||
classLoaderService.classForName( resolverImplName ).newInstance();
|
||||
resolverSet.addResolver( dialectResolver );
|
||||
}
|
||||
catch (HibernateException e) {
|
||||
|
|
|
@ -72,7 +72,7 @@ public class JdbcEnvironmentImpl implements JdbcEnvironment {
|
|||
|
||||
this.sqlAstTranslatorFactory = resolveSqlAstTranslatorFactory( dialect );
|
||||
|
||||
final ConfigurationService cfgService = serviceRegistry.getService( ConfigurationService.class );
|
||||
final ConfigurationService cfgService = serviceRegistry.requireService( ConfigurationService.class );
|
||||
|
||||
NameQualifierSupport nameQualifierSupport = dialect.getNameQualifierSupport();
|
||||
if ( nameQualifierSupport == null ) {
|
||||
|
@ -259,7 +259,7 @@ public class JdbcEnvironmentImpl implements JdbcEnvironment {
|
|||
|
||||
this.sqlAstTranslatorFactory = resolveSqlAstTranslatorFactory( dialect );
|
||||
|
||||
final ConfigurationService cfgService = serviceRegistry.getService( ConfigurationService.class );
|
||||
final ConfigurationService cfgService = serviceRegistry.requireService( ConfigurationService.class );
|
||||
|
||||
this.sqlExceptionHelper = buildSqlExceptionHelper( dialect, logWarnings( cfgService, dialect ) );
|
||||
|
||||
|
@ -318,13 +318,13 @@ public class JdbcEnvironmentImpl implements JdbcEnvironment {
|
|||
Dialect dialect) {
|
||||
final SchemaNameResolver schemaNameResolver;
|
||||
|
||||
final Object setting = serviceRegistry.getService( ConfigurationService.class ).getSettings().get(
|
||||
final Object setting = serviceRegistry.requireService( ConfigurationService.class ).getSettings().get(
|
||||
SCHEMA_NAME_RESOLVER );
|
||||
if ( setting == null ) {
|
||||
schemaNameResolver = dialect.getSchemaNameResolver();
|
||||
}
|
||||
else {
|
||||
schemaNameResolver = serviceRegistry.getService( StrategySelector.class ).resolveDefaultableStrategy(
|
||||
schemaNameResolver = serviceRegistry.requireService( StrategySelector.class ).resolveDefaultableStrategy(
|
||||
SchemaNameResolver.class,
|
||||
setting,
|
||||
dialect.getSchemaNameResolver()
|
||||
|
|
|
@ -394,8 +394,7 @@ public class JdbcEnvironmentInitiator implements StandardServiceInitiator<JdbcEn
|
|||
|
||||
private JdbcConnectionAccess buildJdbcConnectionAccess(ServiceRegistryImplementor registry) {
|
||||
if ( !isMultiTenancyEnabled( registry ) ) {
|
||||
ConnectionProvider connectionProvider = registry.getService( ConnectionProvider.class );
|
||||
return new ConnectionProviderJdbcConnectionAccess( connectionProvider );
|
||||
return new ConnectionProviderJdbcConnectionAccess( registry.requireService( ConnectionProvider.class ) );
|
||||
}
|
||||
else {
|
||||
final MultiTenantConnectionProvider<?> multiTenantConnectionProvider =
|
||||
|
@ -406,8 +405,7 @@ public class JdbcEnvironmentInitiator implements StandardServiceInitiator<JdbcEn
|
|||
|
||||
public static JdbcConnectionAccess buildBootstrapJdbcConnectionAccess(ServiceRegistryImplementor registry) {
|
||||
if ( !isMultiTenancyEnabled( registry ) ) {
|
||||
ConnectionProvider connectionProvider = registry.getService( ConnectionProvider.class );
|
||||
return new ConnectionProviderJdbcConnectionAccess( connectionProvider );
|
||||
return new ConnectionProviderJdbcConnectionAccess( registry.requireService( ConnectionProvider.class ) );
|
||||
}
|
||||
else {
|
||||
final MultiTenantConnectionProvider<?> multiTenantConnectionProvider =
|
||||
|
|
|
@ -49,9 +49,7 @@ public class JdbcServicesImpl implements JdbcServices, ServiceRegistryAwareServi
|
|||
|
||||
@Override
|
||||
public void configure(Map<String, Object> configValues) {
|
||||
this.jdbcEnvironment = serviceRegistry.getService( JdbcEnvironment.class );
|
||||
assert jdbcEnvironment != null : "JdbcEnvironment was not found";
|
||||
|
||||
this.jdbcEnvironment = serviceRegistry.requireService( JdbcEnvironment.class );
|
||||
this.sqlStatementLogger = serviceRegistry.getService( SqlStatementLogger.class );
|
||||
this.parameterMarkerStrategy = serviceRegistry.getService( ParameterMarkerStrategy.class );
|
||||
}
|
||||
|
|
|
@ -53,7 +53,7 @@ public class MutationExecutorServiceInitiator implements StandardServiceInitiato
|
|||
customImplClass = (Class<? extends MutationExecutorService>) custom;
|
||||
}
|
||||
else {
|
||||
final ClassLoaderService classLoaderService = registry.getService( ClassLoaderService.class );
|
||||
final ClassLoaderService classLoaderService = registry.requireService( ClassLoaderService.class );
|
||||
customImplClass = classLoaderService.classForName( custom.toString() );
|
||||
}
|
||||
|
||||
|
|
|
@ -26,9 +26,9 @@ public class CacheInitiator implements SessionFactoryServiceInitiator<CacheImple
|
|||
@Override
|
||||
public CacheImplementor initiateService(SessionFactoryServiceInitiatorContext context) {
|
||||
final RegionFactory regionFactory = context.getServiceRegistry().getService( RegionFactory.class );
|
||||
return ( !(regionFactory instanceof NoCachingRegionFactory) )
|
||||
? new EnabledCaching( context.getSessionFactory() )
|
||||
: new DisabledCaching( context.getSessionFactory() );
|
||||
return regionFactory instanceof NoCachingRegionFactory
|
||||
? new DisabledCaching( context.getSessionFactory() )
|
||||
: new EnabledCaching( context.getSessionFactory() );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -18,7 +18,6 @@ import org.hibernate.engine.jndi.spi.JndiService;
|
|||
import org.hibernate.engine.transaction.internal.jta.JtaStatusHelper;
|
||||
import org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform;
|
||||
import org.hibernate.engine.transaction.jta.platform.spi.JtaPlatformException;
|
||||
import org.hibernate.internal.util.NullnessUtil;
|
||||
import org.hibernate.internal.util.config.ConfigurationHelper;
|
||||
import org.hibernate.service.ServiceRegistry;
|
||||
import org.hibernate.service.spi.Configurable;
|
||||
|
@ -64,7 +63,7 @@ public abstract class AbstractJtaPlatform
|
|||
}
|
||||
|
||||
protected JndiService jndiService() {
|
||||
return NullnessUtil.castNonNull( serviceRegistry().getService( JndiService.class ) );
|
||||
return serviceRegistry().requireService( JndiService.class );
|
||||
}
|
||||
|
||||
protected abstract TransactionManager locateTransactionManager();
|
||||
|
|
|
@ -11,7 +11,6 @@ import jakarta.transaction.UserTransaction;
|
|||
|
||||
import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
|
||||
import org.hibernate.engine.transaction.jta.platform.spi.JtaPlatformException;
|
||||
import org.hibernate.internal.util.NullnessUtil;
|
||||
|
||||
/**
|
||||
* @author Vlad Mihalcea
|
||||
|
@ -22,8 +21,10 @@ public class AtomikosJtaPlatform extends AbstractJtaPlatform {
|
|||
@Override
|
||||
protected TransactionManager locateTransactionManager() {
|
||||
try {
|
||||
Class transactionManagerClass = NullnessUtil.castNonNull( serviceRegistry().getService( ClassLoaderService.class ) ).classForName( TM_CLASS_NAME );
|
||||
return (TransactionManager) transactionManagerClass.newInstance();
|
||||
return (TransactionManager) serviceRegistry()
|
||||
.requireService( ClassLoaderService.class )
|
||||
.classForName( TM_CLASS_NAME )
|
||||
.newInstance();
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new JtaPlatformException( "Could not instantiate Atomikos TransactionManager", e );
|
||||
|
|
|
@ -12,7 +12,6 @@ import jakarta.transaction.UserTransaction;
|
|||
|
||||
import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
|
||||
import org.hibernate.engine.transaction.jta.platform.spi.JtaPlatformException;
|
||||
import org.hibernate.internal.util.NullnessUtil;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
|
@ -23,8 +22,10 @@ public class BitronixJtaPlatform extends AbstractJtaPlatform {
|
|||
@Override
|
||||
protected TransactionManager locateTransactionManager() {
|
||||
try {
|
||||
Class transactionManagerServicesClass = NullnessUtil.castNonNull( serviceRegistry().getService( ClassLoaderService.class ) ).classForName( TM_CLASS_NAME );
|
||||
final Method getTransactionManagerMethod = transactionManagerServicesClass.getMethod( "getTransactionManager" );
|
||||
final Method getTransactionManagerMethod =
|
||||
serviceRegistry().requireService( ClassLoaderService.class )
|
||||
.classForName( TM_CLASS_NAME )
|
||||
.getMethod( "getTransactionManager" );
|
||||
return (TransactionManager) getTransactionManagerMethod.invoke( null );
|
||||
}
|
||||
catch (Exception e) {
|
||||
|
|
|
@ -11,7 +11,6 @@ import jakarta.transaction.UserTransaction;
|
|||
|
||||
import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
|
||||
import org.hibernate.engine.transaction.jta.platform.spi.JtaPlatformException;
|
||||
import org.hibernate.internal.util.NullnessUtil;
|
||||
|
||||
/**
|
||||
* Return a standalone JTA transaction manager for JBoss (Arjuna) Transactions or WildFly transaction client
|
||||
|
@ -38,10 +37,10 @@ public class JBossStandAloneJtaPlatform extends AbstractJtaPlatform {
|
|||
}
|
||||
|
||||
try {
|
||||
final Class jbossTmClass = NullnessUtil.castNonNull( serviceRegistry()
|
||||
.getService( ClassLoaderService.class ) )
|
||||
.classForName( JBOSS_TM_CLASS_NAME );
|
||||
return (TransactionManager) jbossTmClass.getMethod( "transactionManager" ).invoke( null );
|
||||
return (TransactionManager) serviceRegistry().requireService( ClassLoaderService.class )
|
||||
.classForName( JBOSS_TM_CLASS_NAME )
|
||||
.getMethod( "transactionManager" )
|
||||
.invoke( null );
|
||||
}
|
||||
catch ( Exception e ) {
|
||||
throw new JtaPlatformException( "Could not obtain JBoss Transactions transaction manager instance", e );
|
||||
|
@ -59,10 +58,11 @@ public class JBossStandAloneJtaPlatform extends AbstractJtaPlatform {
|
|||
}
|
||||
|
||||
try {
|
||||
final Class jbossUtClass = NullnessUtil.castNonNull( serviceRegistry()
|
||||
.getService( ClassLoaderService.class ) )
|
||||
.classForName( JBOSS_UT_CLASS_NAME );
|
||||
return (UserTransaction) jbossUtClass.getMethod( "userTransaction" ).invoke( null );
|
||||
return (UserTransaction) serviceRegistry()
|
||||
.requireService( ClassLoaderService.class )
|
||||
.classForName( JBOSS_UT_CLASS_NAME )
|
||||
.getMethod( "userTransaction" )
|
||||
.invoke( null );
|
||||
}
|
||||
catch ( Exception e ) {
|
||||
throw new JtaPlatformException( "Could not obtain JBoss Transactions user transaction instance", e );
|
||||
|
|
|
@ -6,13 +6,11 @@
|
|||
*/
|
||||
package org.hibernate.engine.transaction.jta.platform.internal;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import jakarta.transaction.TransactionManager;
|
||||
import jakarta.transaction.UserTransaction;
|
||||
|
||||
import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
|
||||
import org.hibernate.engine.transaction.jta.platform.spi.JtaPlatformException;
|
||||
import org.hibernate.internal.util.NullnessUtil;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
|
@ -24,9 +22,11 @@ public class JOTMJtaPlatform extends AbstractJtaPlatform {
|
|||
@Override
|
||||
protected TransactionManager locateTransactionManager() {
|
||||
try {
|
||||
final Class tmClass = NullnessUtil.castNonNull( serviceRegistry().getService( ClassLoaderService.class ) ).classForName( TM_CLASS_NAME );
|
||||
final Method getTransactionManagerMethod = tmClass.getMethod( "getTransactionManager" );
|
||||
return (TransactionManager) getTransactionManagerMethod.invoke( null, (Object[]) null );
|
||||
return (TransactionManager) serviceRegistry()
|
||||
.requireService( ClassLoaderService.class )
|
||||
.classForName( TM_CLASS_NAME )
|
||||
.getMethod( "getTransactionManager" )
|
||||
.invoke( null, (Object[]) null );
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new JtaPlatformException( "Could not obtain JOTM transaction manager instance", e );
|
||||
|
|
|
@ -14,7 +14,6 @@ import org.hibernate.cfg.AvailableSettings;
|
|||
import org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform;
|
||||
import org.hibernate.engine.transaction.jta.platform.spi.JtaPlatformResolver;
|
||||
import org.hibernate.internal.CoreMessageLogger;
|
||||
import org.hibernate.internal.util.NullnessUtil;
|
||||
import org.hibernate.service.spi.ServiceRegistryImplementor;
|
||||
|
||||
import org.jboss.logging.Logger;
|
||||
|
@ -39,11 +38,13 @@ public class JtaPlatformInitiator implements StandardServiceInitiator<JtaPlatfor
|
|||
@Override
|
||||
public @Nullable JtaPlatform initiateService(Map<String, Object> configurationValues, ServiceRegistryImplementor registry) {
|
||||
final Object setting = configurationValues.get( AvailableSettings.JTA_PLATFORM );
|
||||
JtaPlatform platform = NullnessUtil.castNonNull( registry.getService( StrategySelector.class ) ).resolveStrategy( JtaPlatform.class, setting );
|
||||
JtaPlatform platform = registry.requireService( StrategySelector.class )
|
||||
.resolveStrategy( JtaPlatform.class, setting );
|
||||
|
||||
if ( platform == null ) {
|
||||
LOG.debug( "No JtaPlatform was specified, checking resolver" );
|
||||
platform = NullnessUtil.castNonNull( registry.getService( JtaPlatformResolver.class ) ).resolveJtaPlatform( configurationValues, registry );
|
||||
platform = registry.requireService( JtaPlatformResolver.class )
|
||||
.resolveJtaPlatform( configurationValues, registry );
|
||||
}
|
||||
|
||||
if ( platform == null ) {
|
||||
|
|
|
@ -28,8 +28,9 @@ public class JtaPlatformResolverInitiator implements StandardServiceInitiator<Jt
|
|||
@Override
|
||||
public JtaPlatformResolver initiateService(Map<String, Object> configurationValues, ServiceRegistryImplementor registry) {
|
||||
final Object setting = configurationValues.get( AvailableSettings.JTA_PLATFORM_RESOLVER );
|
||||
final JtaPlatformResolver resolver = NullnessUtil.castNonNull( registry.getService( StrategySelector.class ) )
|
||||
.resolveStrategy( JtaPlatformResolver.class, setting );
|
||||
final JtaPlatformResolver resolver =
|
||||
registry.requireService( StrategySelector.class )
|
||||
.resolveStrategy( JtaPlatformResolver.class, setting );
|
||||
if ( resolver == null ) {
|
||||
log.debugf( "No JtaPlatformResolver was specified, using default [%s]", StandardJtaPlatformResolver.class.getName() );
|
||||
return StandardJtaPlatformResolver.INSTANCE;
|
||||
|
|
|
@ -28,7 +28,7 @@ public class StandardJtaPlatformResolver implements JtaPlatformResolver {
|
|||
|
||||
@Override
|
||||
public JtaPlatform resolveJtaPlatform(Map configurationValues, ServiceRegistryImplementor registry) {
|
||||
final ClassLoaderService classLoaderService = NullnessUtil.castNonNull( registry.getService( ClassLoaderService.class ) );
|
||||
final ClassLoaderService classLoaderService = registry.requireService( ClassLoaderService.class );
|
||||
|
||||
// Initially look for a JtaPlatformProvider
|
||||
for ( JtaPlatformProvider provider : classLoaderService.loadJavaServices( JtaPlatformProvider.class ) ) {
|
||||
|
|
|
@ -24,7 +24,6 @@ import org.hibernate.internal.util.NullnessUtil;
|
|||
* @author Andrew Guibert
|
||||
* @author Nathan Rauh
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class WebSphereLibertyJtaPlatform extends AbstractJtaPlatform {
|
||||
|
||||
public static final String TMF_CLASS_NAME = "com.ibm.tx.jta.TransactionManagerFactory";
|
||||
|
@ -34,10 +33,10 @@ public class WebSphereLibertyJtaPlatform extends AbstractJtaPlatform {
|
|||
@Override
|
||||
protected TransactionManager locateTransactionManager() {
|
||||
try {
|
||||
final Class<?> TransactionManagerFactory = NullnessUtil.castNonNull( serviceRegistry()
|
||||
.getService( ClassLoaderService.class ) )
|
||||
.classForName( TMF_CLASS_NAME );
|
||||
return (TransactionManager) TransactionManagerFactory.getMethod("getTransactionManager").invoke(null);
|
||||
return (TransactionManager) serviceRegistry().requireService( ClassLoaderService.class )
|
||||
.classForName( TMF_CLASS_NAME )
|
||||
.getMethod("getTransactionManager")
|
||||
.invoke(null);
|
||||
}
|
||||
catch ( Exception e ) {
|
||||
throw new JtaPlatformException( "Could not obtain WebSphere Liberty transaction manager instance", e );
|
||||
|
|
|
@ -11,7 +11,6 @@ import jakarta.transaction.UserTransaction;
|
|||
|
||||
import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
|
||||
import org.hibernate.engine.transaction.jta.platform.spi.JtaPlatformException;
|
||||
import org.hibernate.internal.util.NullnessUtil;
|
||||
|
||||
/**
|
||||
* Return a standalone JTA transaction manager for WildFly transaction client
|
||||
|
@ -26,10 +25,11 @@ public class WildFlyStandAloneJtaPlatform extends AbstractJtaPlatform {
|
|||
@Override
|
||||
protected TransactionManager locateTransactionManager() {
|
||||
try {
|
||||
final Class wildflyTmClass = NullnessUtil.castNonNull( serviceRegistry()
|
||||
.getService( ClassLoaderService.class ) )
|
||||
.classForName( WILDFLY_TM_CLASS_NAME );
|
||||
return (TransactionManager) wildflyTmClass.getMethod( "getInstance" ).invoke( null );
|
||||
return (TransactionManager) serviceRegistry()
|
||||
.requireService( ClassLoaderService.class )
|
||||
.classForName( WILDFLY_TM_CLASS_NAME )
|
||||
.getMethod( "getInstance" )
|
||||
.invoke( null );
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new JtaPlatformException(
|
||||
|
@ -42,10 +42,9 @@ public class WildFlyStandAloneJtaPlatform extends AbstractJtaPlatform {
|
|||
@Override
|
||||
protected UserTransaction locateUserTransaction() {
|
||||
try {
|
||||
final Class jbossUtClass = NullnessUtil.castNonNull( serviceRegistry()
|
||||
.getService( ClassLoaderService.class ) )
|
||||
.classForName( WILDFLY_UT_CLASS_NAME );
|
||||
return (UserTransaction) jbossUtClass.getMethod( "getInstance" ).invoke( null );
|
||||
return (UserTransaction) serviceRegistry()
|
||||
.requireService( ClassLoaderService.class )
|
||||
.classForName( WILDFLY_UT_CLASS_NAME ).getMethod( "getInstance" ).invoke( null );
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new JtaPlatformException(
|
||||
|
|
|
@ -53,8 +53,9 @@ public class EntityCopyObserverFactoryInitiator implements StandardServiceInitia
|
|||
//We load an "example instance" just to get its Class;
|
||||
//this might look excessive, but it also happens to test eagerly (at boot) that we can actually construct these
|
||||
//and that they are indeed of the right type.
|
||||
EntityCopyObserver exampleInstance = registry.getService( StrategySelector.class )
|
||||
.resolveStrategy( EntityCopyObserver.class, value );
|
||||
EntityCopyObserver exampleInstance =
|
||||
registry.requireService( StrategySelector.class )
|
||||
.resolveStrategy( EntityCopyObserver.class, value );
|
||||
Class<?> observerType = exampleInstance.getClass();
|
||||
LOG.debugf( "Configured EntityCopyObserver is a custom implementation of type %s", observerType.getName() );
|
||||
return new EntityObserversFactoryFromClass( observerType );
|
||||
|
|
|
@ -124,7 +124,7 @@ public class EventEngine {
|
|||
|
||||
final Collection<EventEngineContributor> discoveredContributors =
|
||||
sessionFactory.getServiceRegistry()
|
||||
.getService( ClassLoaderService.class )
|
||||
.requireService( ClassLoaderService.class )
|
||||
.loadJavaServices( EventEngineContributor.class );
|
||||
if ( CollectionHelper.isNotEmpty( discoveredContributors ) ) {
|
||||
for ( EventEngineContributor contributor : discoveredContributors ) {
|
||||
|
|
|
@ -89,7 +89,7 @@ public class IncrementGenerator implements IdentifierGenerator, StandardGenerato
|
|||
public void configure(Type type, Properties parameters, ServiceRegistry serviceRegistry) throws MappingException {
|
||||
returnClass = type.getReturnedClass();
|
||||
|
||||
final JdbcEnvironment jdbcEnvironment = serviceRegistry.getService( JdbcEnvironment.class );
|
||||
final JdbcEnvironment jdbcEnvironment = serviceRegistry.requireService( JdbcEnvironment.class );
|
||||
final ObjectNameNormalizer normalizer =
|
||||
(ObjectNameNormalizer) parameters.get( IDENTIFIER_NORMALIZER );
|
||||
|
||||
|
|
|
@ -60,8 +60,9 @@ public class UUIDGenerator implements IdentifierGenerator, StandardGenerator {
|
|||
final String strategyClassName = parameters.getProperty( UUID_GEN_STRATEGY_CLASS );
|
||||
if ( strategyClassName != null ) {
|
||||
try {
|
||||
final ClassLoaderService cls = serviceRegistry.getService( ClassLoaderService.class );
|
||||
final Class<?> strategyClass = cls.classForName( strategyClassName );
|
||||
final Class<?> strategyClass =
|
||||
serviceRegistry.requireService( ClassLoaderService.class )
|
||||
.classForName( strategyClassName );
|
||||
try {
|
||||
strategy = (UUIDGenerationStrategy) strategyClass.newInstance();
|
||||
}
|
||||
|
|
|
@ -74,7 +74,7 @@ public class LegacyNamingStrategy implements ImplicitDatabaseObjectNamingStrateg
|
|||
return new QualifiedSequenceName(
|
||||
catalogName,
|
||||
schemaName,
|
||||
serviceRegistry.getService( JdbcEnvironment.class )
|
||||
serviceRegistry.requireService( JdbcEnvironment.class )
|
||||
.getIdentifierHelper()
|
||||
.toIdentifier( sequenceName )
|
||||
);
|
||||
|
@ -110,11 +110,12 @@ public class LegacyNamingStrategy implements ImplicitDatabaseObjectNamingStrateg
|
|||
return QualifiedNameParser.INSTANCE.parse( implicitName );
|
||||
}
|
||||
|
||||
final JdbcEnvironment jdbcEnvironment = serviceRegistry.getService( JdbcEnvironment.class );
|
||||
return new QualifiedNameParser.NameParts(
|
||||
catalogName,
|
||||
schemaName,
|
||||
jdbcEnvironment.getIdentifierHelper().toIdentifier( implicitName )
|
||||
serviceRegistry.requireService( JdbcEnvironment.class )
|
||||
.getIdentifierHelper()
|
||||
.toIdentifier( implicitName )
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -191,7 +191,7 @@ public class SequenceStyleGenerator
|
|||
|
||||
@Override
|
||||
public void configure(Type type, Properties parameters, ServiceRegistry serviceRegistry) throws MappingException {
|
||||
final JdbcEnvironment jdbcEnvironment = serviceRegistry.getService( JdbcEnvironment.class );
|
||||
final JdbcEnvironment jdbcEnvironment = serviceRegistry.requireService( JdbcEnvironment.class );
|
||||
final Dialect dialect = jdbcEnvironment.getDialect();
|
||||
|
||||
this.identifierType = type;
|
||||
|
@ -245,7 +245,7 @@ public class SequenceStyleGenerator
|
|||
boolean physicalSequence,
|
||||
OptimizerDescriptor optimizationStrategy,
|
||||
ServiceRegistry serviceRegistry) {
|
||||
final ConfigurationService configurationService = serviceRegistry.getService( ConfigurationService.class );
|
||||
final ConfigurationService configurationService = serviceRegistry.requireService( ConfigurationService.class );
|
||||
final SequenceMismatchStrategy sequenceMismatchStrategy = configurationService.getSetting(
|
||||
AvailableSettings.SEQUENCE_INCREMENT_SIZE_MISMATCH_STRATEGY,
|
||||
SequenceMismatchStrategy::interpret,
|
||||
|
@ -343,7 +343,7 @@ public class SequenceStyleGenerator
|
|||
Identifier schema,
|
||||
Properties params,
|
||||
ServiceRegistry serviceRegistry) {
|
||||
final StrategySelector strategySelector = serviceRegistry.getService( StrategySelector.class );
|
||||
final StrategySelector strategySelector = serviceRegistry.requireService( StrategySelector.class );
|
||||
|
||||
final String namingStrategySetting = coalesceSuppliedValues(
|
||||
() -> {
|
||||
|
@ -354,7 +354,7 @@ public class SequenceStyleGenerator
|
|||
return localSetting;
|
||||
},
|
||||
() -> {
|
||||
final ConfigurationService configurationService = serviceRegistry.getService( ConfigurationService.class );
|
||||
final ConfigurationService configurationService = serviceRegistry.requireService( ConfigurationService.class );
|
||||
final String globalSetting = getString( ID_DB_STRUCTURE_NAMING_STRATEGY, configurationService.getSettings() );
|
||||
if ( globalSetting != null ) {
|
||||
INCUBATION_LOGGER.incubatingSetting( ID_DB_STRUCTURE_NAMING_STRATEGY );
|
||||
|
|
|
@ -36,12 +36,13 @@ public class SingleNamingStrategy implements ImplicitDatabaseObjectNamingStrateg
|
|||
Identifier schemaName,
|
||||
Map<?, ?> configValues,
|
||||
ServiceRegistry serviceRegistry) {
|
||||
final JdbcEnvironment jdbcEnvironment = serviceRegistry.getService( JdbcEnvironment.class );
|
||||
|
||||
return new QualifiedSequenceName(
|
||||
catalogName,
|
||||
schemaName,
|
||||
jdbcEnvironment.getIdentifierHelper().toIdentifier( DEF_SEQUENCE )
|
||||
serviceRegistry.requireService( JdbcEnvironment.class )
|
||||
.getIdentifierHelper()
|
||||
.toIdentifier( DEF_SEQUENCE )
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -50,11 +51,12 @@ public class SingleNamingStrategy implements ImplicitDatabaseObjectNamingStrateg
|
|||
Identifier schemaName,
|
||||
Map<?, ?> configValues,
|
||||
ServiceRegistry serviceRegistry) {
|
||||
final JdbcEnvironment jdbcEnvironment = serviceRegistry.getService( JdbcEnvironment.class );
|
||||
return new QualifiedNameParser.NameParts(
|
||||
catalogName,
|
||||
schemaName,
|
||||
jdbcEnvironment.getIdentifierHelper().toIdentifier( DEF_TABLE )
|
||||
serviceRegistry.requireService( JdbcEnvironment.class )
|
||||
.getIdentifierHelper()
|
||||
.toIdentifier( DEF_TABLE )
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -86,7 +86,7 @@ public class StandardNamingStrategy implements ImplicitDatabaseObjectNamingStrat
|
|||
return new QualifiedSequenceName(
|
||||
catalogName,
|
||||
schemaName,
|
||||
serviceRegistry.getService( JdbcEnvironment.class )
|
||||
serviceRegistry.requireService( JdbcEnvironment.class )
|
||||
.getIdentifierHelper()
|
||||
.toIdentifier( implicitName )
|
||||
);
|
||||
|
@ -137,8 +137,9 @@ public class StandardNamingStrategy implements ImplicitDatabaseObjectNamingStrat
|
|||
return new QualifiedNameParser.NameParts(
|
||||
catalogName,
|
||||
schemaName,
|
||||
serviceRegistry.getService( JdbcEnvironment.class )
|
||||
.getIdentifierHelper().toIdentifier( tableName )
|
||||
serviceRegistry.requireService( JdbcEnvironment.class )
|
||||
.getIdentifierHelper()
|
||||
.toIdentifier( tableName )
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -332,11 +332,11 @@ public class TableGenerator implements PersistentIdentifierGenerator {
|
|||
|
||||
@Override
|
||||
public void configure(Type type, Properties parameters, ServiceRegistry serviceRegistry) throws MappingException {
|
||||
storeLastUsedValue = serviceRegistry.getService( ConfigurationService.class )
|
||||
storeLastUsedValue = serviceRegistry.requireService( ConfigurationService.class )
|
||||
.getSetting( AvailableSettings.TABLE_GENERATOR_STORE_LAST_USED, StandardConverters.BOOLEAN, true );
|
||||
identifierType = type;
|
||||
|
||||
final JdbcEnvironment jdbcEnvironment = serviceRegistry.getService( JdbcEnvironment.class );
|
||||
final JdbcEnvironment jdbcEnvironment = serviceRegistry.requireService( JdbcEnvironment.class );
|
||||
|
||||
qualifiedTableName = determineGeneratorTableName( parameters, jdbcEnvironment, serviceRegistry );
|
||||
segmentColumnName = determineSegmentColumnName( parameters, jdbcEnvironment );
|
||||
|
@ -398,7 +398,7 @@ public class TableGenerator implements PersistentIdentifierGenerator {
|
|||
}
|
||||
}
|
||||
|
||||
final StrategySelector strategySelector = serviceRegistry.getService( StrategySelector.class );
|
||||
final StrategySelector strategySelector = serviceRegistry.requireService( StrategySelector.class );
|
||||
|
||||
final String namingStrategySetting = coalesceSuppliedValues(
|
||||
() -> {
|
||||
|
@ -409,7 +409,7 @@ public class TableGenerator implements PersistentIdentifierGenerator {
|
|||
return localSetting;
|
||||
},
|
||||
() -> {
|
||||
final ConfigurationService configurationService = serviceRegistry.getService( ConfigurationService.class );
|
||||
final ConfigurationService configurationService = serviceRegistry.requireService( ConfigurationService.class );
|
||||
final String globalSetting = getString( ID_DB_STRUCTURE_NAMING_STRATEGY, configurationService.getSettings() );
|
||||
if ( globalSetting != null ) {
|
||||
INCUBATION_LOGGER.incubatingSetting( ID_DB_STRUCTURE_NAMING_STRATEGY );
|
||||
|
|
|
@ -50,7 +50,7 @@ public class IdentifierGeneratorUtil {
|
|||
// default initial value and allocation size per-JPA defaults
|
||||
params.setProperty( OptimizableGenerator.INITIAL_PARAM, String.valueOf( OptimizableGenerator.DEFAULT_INITIAL_VALUE ) );
|
||||
final ConfigurationService cs = simpleValue.getMetadata().getMetadataBuildingOptions().getServiceRegistry()
|
||||
.getService( ConfigurationService.class );
|
||||
.requireService( ConfigurationService.class );
|
||||
|
||||
final String idNamingStrategy = cs.getSetting(
|
||||
AvailableSettings.ID_DB_STRUCTURE_NAMING_STRATEGY,
|
||||
|
|
|
@ -95,7 +95,9 @@ public class StandardIdentifierGeneratorFactory
|
|||
return null;
|
||||
}
|
||||
else {
|
||||
final BeanContainer beanContainer = serviceRegistry.getService( ManagedBeanRegistry.class ).getBeanContainer();
|
||||
final BeanContainer beanContainer =
|
||||
serviceRegistry.requireService( ManagedBeanRegistry.class )
|
||||
.getBeanContainer();
|
||||
if ( beanContainer == null ) {
|
||||
ID_GEN_FAC_LOGGER.debug( "Resolving IdentifierGenerator instances will not use CDI as it was not configured" );
|
||||
}
|
||||
|
@ -112,7 +114,7 @@ public class StandardIdentifierGeneratorFactory
|
|||
}
|
||||
|
||||
private void logOverrides() {
|
||||
serviceRegistry.getService( ClassLoaderService.class )
|
||||
serviceRegistry.requireService( ClassLoaderService.class )
|
||||
.loadJavaServices( GenerationTypeStrategyRegistration.class )
|
||||
.forEach( (registration) -> registration.registerStrategies(
|
||||
(generationType, generationTypeStrategy) -> {
|
||||
|
@ -148,7 +150,7 @@ public class StandardIdentifierGeneratorFactory
|
|||
}
|
||||
|
||||
private void registerUsingLegacyContributor() {
|
||||
final ConfigurationService configService = serviceRegistry.getService( ConfigurationService.class );
|
||||
final ConfigurationService configService = serviceRegistry.requireService( ConfigurationService.class );
|
||||
final Object providerSetting = configService.getSettings().get( IDENTIFIER_GENERATOR_STRATEGY_PROVIDER );
|
||||
if ( providerSetting != null ) {
|
||||
DEPRECATION_LOGGER.deprecatedSetting2(
|
||||
|
@ -156,7 +158,7 @@ public class StandardIdentifierGeneratorFactory
|
|||
"supply a org.hibernate.id.factory.spi.GenerationTypeStrategyRegistration Java service"
|
||||
);
|
||||
final IdentifierGeneratorStrategyProvider idGeneratorStrategyProvider =
|
||||
serviceRegistry.getService( StrategySelector.class )
|
||||
serviceRegistry.requireService( StrategySelector.class )
|
||||
.resolveStrategy( IdentifierGeneratorStrategyProvider.class, providerSetting );
|
||||
for ( Map.Entry<String,Class<?>> entry : idGeneratorStrategyProvider.getStrategies().entrySet() ) {
|
||||
@SuppressWarnings({"rawtypes", "unchecked"})
|
||||
|
@ -199,7 +201,7 @@ public class StandardIdentifierGeneratorFactory
|
|||
@Override @Deprecated
|
||||
public Dialect getDialect() {
|
||||
if ( dialect == null ) {
|
||||
dialect = serviceRegistry.getService( JdbcEnvironment.class ).getDialect();
|
||||
dialect = serviceRegistry.requireService( JdbcEnvironment.class ).getDialect();
|
||||
}
|
||||
return dialect;
|
||||
}
|
||||
|
@ -258,7 +260,7 @@ public class StandardIdentifierGeneratorFactory
|
|||
protected Class<? extends Generator> generatorClassForName(String strategy) {
|
||||
try {
|
||||
Class<? extends Generator> clazz =
|
||||
serviceRegistry.getService( ClassLoaderService.class )
|
||||
serviceRegistry.requireService( ClassLoaderService.class )
|
||||
.classForName( strategy );
|
||||
if ( !Generator.class.isAssignableFrom( clazz ) ) {
|
||||
// in principle, this shouldn't happen, since @GenericGenerator
|
||||
|
|
|
@ -1570,7 +1570,7 @@ public abstract class AbstractSharedSessionContract implements SharedSessionCont
|
|||
cacheTransactionSync = factory.getCache().getRegionFactory().createTransactionContext( this );
|
||||
|
||||
transactionCoordinator = factory.getServiceRegistry()
|
||||
.getService( TransactionCoordinatorBuilder.class )
|
||||
.requireService( TransactionCoordinatorBuilder.class )
|
||||
.buildTransactionCoordinator( jdbcCoordinator, this );
|
||||
|
||||
entityNameResolver = new CoordinatingEntityNameResolver( factory, interceptor );
|
||||
|
|
|
@ -196,7 +196,7 @@ public final class FastSessionServices {
|
|||
final SessionFactoryOptions sessionFactoryOptions = sessionFactory.getSessionFactoryOptions();
|
||||
|
||||
// Pre-compute all iterators on Event listeners:
|
||||
final EventListenerRegistry eventListenerRegistry = serviceRegistry.getService( EventListenerRegistry.class );
|
||||
final EventListenerRegistry eventListenerRegistry = serviceRegistry.requireService( EventListenerRegistry.class );
|
||||
this.eventListenerGroup_AUTO_FLUSH = listeners( eventListenerRegistry, EventType.AUTO_FLUSH );
|
||||
this.eventListenerGroup_CLEAR = listeners( eventListenerRegistry, EventType.CLEAR );
|
||||
this.eventListenerGroup_DELETE = listeners( eventListenerRegistry, EventType.DELETE );
|
||||
|
@ -250,9 +250,9 @@ public final class FastSessionServices {
|
|||
? null
|
||||
: serviceRegistry.getService( ConnectionProvider.class );
|
||||
this.multiTenantConnectionProvider = requiresMultiTenantConnectionProvider
|
||||
? serviceRegistry.getService( MultiTenantConnectionProvider.class )
|
||||
? serviceRegistry.requireService( MultiTenantConnectionProvider.class )
|
||||
: null;
|
||||
this.classLoaderService = serviceRegistry.getService( ClassLoaderService.class );
|
||||
this.classLoaderService = serviceRegistry.requireService( ClassLoaderService.class );
|
||||
this.transactionCoordinatorBuilder = serviceRegistry.getService( TransactionCoordinatorBuilder.class );
|
||||
this.jdbcServices = serviceRegistry.getService( JdbcServices.class );
|
||||
this.entityCopyObserverFactory = serviceRegistry.getService( EntityCopyObserverFactory.class );
|
||||
|
|
|
@ -229,7 +229,7 @@ public class SessionFactoryImpl extends QueryParameterBindingTypeResolverImpl im
|
|||
name = getSessionFactoryName( options, serviceRegistry );
|
||||
uuid = options.getUuid();
|
||||
|
||||
jdbcServices = serviceRegistry.getService( JdbcServices.class );
|
||||
jdbcServices = serviceRegistry.requireService( JdbcServices.class );
|
||||
|
||||
settings = getSettings( options, serviceRegistry );
|
||||
maskOutSensitiveInformation( settings );
|
||||
|
@ -489,7 +489,7 @@ public class SessionFactoryImpl extends QueryParameterBindingTypeResolverImpl im
|
|||
SessionFactoryImplementor self) {
|
||||
return options
|
||||
.getServiceRegistry()
|
||||
.getService( SessionFactoryServiceRegistryFactory.class )
|
||||
.requireService( SessionFactoryServiceRegistryFactory.class )
|
||||
// it is not great how we pass in an instance to
|
||||
// an incompletely-initialized instance here:
|
||||
.buildServiceRegistry( self, options );
|
||||
|
@ -507,7 +507,7 @@ public class SessionFactoryImpl extends QueryParameterBindingTypeResolverImpl im
|
|||
}
|
||||
|
||||
private void integrate(MetadataImplementor bootMetamodel, BootstrapContext bootstrapContext, IntegratorObserver integratorObserver) {
|
||||
for ( Integrator integrator : serviceRegistry.getService( IntegratorService.class ).getIntegrators() ) {
|
||||
for ( Integrator integrator : serviceRegistry.requireService( IntegratorService.class ).getIntegrators() ) {
|
||||
integrator.integrate(bootMetamodel, bootstrapContext, this );
|
||||
integratorObserver.integrators.add( integrator );
|
||||
}
|
||||
|
@ -527,7 +527,7 @@ public class SessionFactoryImpl extends QueryParameterBindingTypeResolverImpl im
|
|||
|
||||
|
||||
private static Map<String, Object> getSettings(SessionFactoryOptions options, SessionFactoryServiceRegistry serviceRegistry) {
|
||||
final Map<String, Object> settings = serviceRegistry.getService( ConfigurationService.class ).getSettings();
|
||||
final Map<String, Object> settings = serviceRegistry.requireService( ConfigurationService.class ).getSettings();
|
||||
final Map<String,Object> result = new HashMap<>( settings );
|
||||
if ( !settings.containsKey( JPA_VALIDATION_FACTORY ) && !settings.containsKey( JAKARTA_VALIDATION_FACTORY ) ) {
|
||||
final Object reference = options.getValidatorFactoryReference();
|
||||
|
@ -540,11 +540,14 @@ public class SessionFactoryImpl extends QueryParameterBindingTypeResolverImpl im
|
|||
}
|
||||
|
||||
private static String getSessionFactoryName(SessionFactoryOptions options, SessionFactoryServiceRegistry serviceRegistry) {
|
||||
final CfgXmlAccessService cfgXmlAccessService = serviceRegistry.getService( CfgXmlAccessService.class );
|
||||
final String sessionFactoryName = options.getSessionFactoryName();
|
||||
return sessionFactoryName == null && cfgXmlAccessService.getAggregatedConfig() != null
|
||||
? cfgXmlAccessService.getAggregatedConfig().getSessionFactoryName()
|
||||
: sessionFactoryName;
|
||||
if ( sessionFactoryName == null ) {
|
||||
final CfgXmlAccessService cfgXmlAccessService = serviceRegistry.requireService( CfgXmlAccessService.class );
|
||||
if ( cfgXmlAccessService.getAggregatedConfig() != null ) {
|
||||
return cfgXmlAccessService.getAggregatedConfig().getSessionFactoryName();
|
||||
}
|
||||
}
|
||||
return sessionFactoryName;
|
||||
}
|
||||
|
||||
private SessionBuilderImpl createDefaultSessionOpenOptionsIfPossible() {
|
||||
|
@ -792,7 +795,7 @@ public class SessionFactoryImpl extends QueryParameterBindingTypeResolverImpl im
|
|||
// JPA requires that we throw IllegalStateException in cases where:
|
||||
// 1) the PersistenceUnitTransactionType (TransactionCoordinator) is non-JTA
|
||||
// 2) an explicit SynchronizationType is specified
|
||||
if ( !getServiceRegistry().getService( TransactionCoordinatorBuilder.class ).isJta() ) {
|
||||
if ( !getServiceRegistry().requireService( TransactionCoordinatorBuilder.class ).isJta() ) {
|
||||
throw new IllegalStateException(
|
||||
"Illegal attempt to specify a SynchronizationType when building an EntityManager from an " +
|
||||
"EntityManagerFactory defined as RESOURCE_LOCAL (as opposed to JTA)"
|
||||
|
@ -978,10 +981,7 @@ public class SessionFactoryImpl extends QueryParameterBindingTypeResolverImpl im
|
|||
try {
|
||||
final ProcedureCallImplementor<?> unwrapped = query.unwrap( ProcedureCallImplementor.class );
|
||||
if ( unwrapped != null ) {
|
||||
namedObjectRepository.registerCallableQueryMemento(
|
||||
name,
|
||||
unwrapped.toMemento( name )
|
||||
);
|
||||
namedObjectRepository.registerCallableQueryMemento( name, unwrapped.toMemento( name ) );
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -1076,7 +1076,7 @@ public class SessionFactoryImpl extends QueryParameterBindingTypeResolverImpl im
|
|||
|
||||
public StatisticsImplementor getStatistics() {
|
||||
if ( statistics == null ) {
|
||||
statistics = serviceRegistry.getService( StatisticsImplementor.class );
|
||||
statistics = serviceRegistry.requireService( StatisticsImplementor.class );
|
||||
}
|
||||
return statistics;
|
||||
}
|
||||
|
@ -1114,7 +1114,7 @@ public class SessionFactoryImpl extends QueryParameterBindingTypeResolverImpl im
|
|||
|
||||
private boolean canAccessTransactionManager() {
|
||||
try {
|
||||
return serviceRegistry.getService( JtaPlatform.class ).retrieveTransactionManager() != null;
|
||||
return serviceRegistry.requireService( JtaPlatform.class ).retrieveTransactionManager() != null;
|
||||
}
|
||||
catch ( Exception e ) {
|
||||
return false;
|
||||
|
@ -1151,7 +1151,7 @@ public class SessionFactoryImpl extends QueryParameterBindingTypeResolverImpl im
|
|||
default:
|
||||
try {
|
||||
return (CurrentSessionContext)
|
||||
serviceRegistry.getService( ClassLoaderService.class )
|
||||
serviceRegistry.requireService( ClassLoaderService.class )
|
||||
.classForName( sessionContextType )
|
||||
.getConstructor( new Class[]{ SessionFactoryImplementor.class } )
|
||||
.newInstance( this );
|
||||
|
@ -1247,8 +1247,8 @@ public class SessionFactoryImpl extends QueryParameterBindingTypeResolverImpl im
|
|||
private Object tenantIdentifier;
|
||||
private TimeZone jdbcTimeZone;
|
||||
private boolean explicitNoInterceptor;
|
||||
private int defaultBatchFetchSize;
|
||||
private boolean subselectFetchEnabled;
|
||||
private final int defaultBatchFetchSize;
|
||||
private final boolean subselectFetchEnabled;
|
||||
|
||||
// Lazy: defaults can be built by invoking the builder in fastSessionServices.defaultSessionEventListeners
|
||||
// (Need a fresh build for each Session as the listener instances can't be reused across sessions)
|
||||
|
|
|
@ -691,7 +691,7 @@ public class StatelessSessionImpl extends AbstractSharedSessionContract implemen
|
|||
}
|
||||
|
||||
private JtaPlatform getJtaPlatform() {
|
||||
return getFactory().getServiceRegistry().getService( JtaPlatform.class );
|
||||
return getFactory().getServiceRegistry().requireService( JtaPlatform.class );
|
||||
}
|
||||
|
||||
private LockMode getNullSafeLockMode(LockMode lockMode) {
|
||||
|
|
|
@ -519,7 +519,7 @@ public final class ConfigurationHelper {
|
|||
|
||||
@Incubating
|
||||
public static synchronized int getPreferredSqlTypeCodeForBoolean(StandardServiceRegistry serviceRegistry) {
|
||||
final Integer typeCode = serviceRegistry.getService( ConfigurationService.class ).getSetting(
|
||||
final Integer typeCode = serviceRegistry.requireService( ConfigurationService.class ).getSetting(
|
||||
AvailableSettings.PREFERRED_BOOLEAN_JDBC_TYPE,
|
||||
TypeCodeConverter.INSTANCE
|
||||
);
|
||||
|
@ -529,7 +529,7 @@ public final class ConfigurationHelper {
|
|||
}
|
||||
|
||||
// default to the Dialect answer
|
||||
return serviceRegistry.getService( JdbcServices.class )
|
||||
return serviceRegistry.requireService( JdbcServices.class )
|
||||
.getJdbcEnvironment()
|
||||
.getDialect()
|
||||
.getPreferredSqlTypeCodeForBoolean();
|
||||
|
@ -537,7 +537,7 @@ public final class ConfigurationHelper {
|
|||
|
||||
@Incubating
|
||||
public static synchronized int getPreferredSqlTypeCodeForDuration(StandardServiceRegistry serviceRegistry) {
|
||||
final Integer explicitSetting = serviceRegistry.getService( ConfigurationService.class ).getSetting(
|
||||
final Integer explicitSetting = serviceRegistry.requireService( ConfigurationService.class ).getSetting(
|
||||
AvailableSettings.PREFERRED_DURATION_JDBC_TYPE,
|
||||
TypeCodeConverter.INSTANCE
|
||||
);
|
||||
|
@ -551,7 +551,7 @@ public final class ConfigurationHelper {
|
|||
|
||||
@Incubating
|
||||
public static synchronized int getPreferredSqlTypeCodeForUuid(StandardServiceRegistry serviceRegistry) {
|
||||
final Integer explicitSetting = serviceRegistry.getService( ConfigurationService.class ).getSetting(
|
||||
final Integer explicitSetting = serviceRegistry.requireService( ConfigurationService.class ).getSetting(
|
||||
AvailableSettings.PREFERRED_UUID_JDBC_TYPE,
|
||||
TypeCodeConverter.INSTANCE
|
||||
);
|
||||
|
@ -565,7 +565,7 @@ public final class ConfigurationHelper {
|
|||
|
||||
@Incubating
|
||||
public static synchronized int getPreferredSqlTypeCodeForInstant(StandardServiceRegistry serviceRegistry) {
|
||||
final Integer explicitSetting = serviceRegistry.getService( ConfigurationService.class ).getSetting(
|
||||
final Integer explicitSetting = serviceRegistry.requireService( ConfigurationService.class ).getSetting(
|
||||
AvailableSettings.PREFERRED_INSTANT_JDBC_TYPE,
|
||||
TypeCodeConverter.INSTANCE
|
||||
);
|
||||
|
@ -580,7 +580,7 @@ public final class ConfigurationHelper {
|
|||
@Incubating
|
||||
public static synchronized int getPreferredSqlTypeCodeForArray(StandardServiceRegistry serviceRegistry) {
|
||||
// default to the Dialect answer
|
||||
return serviceRegistry.getService( JdbcServices.class )
|
||||
return serviceRegistry.requireService( JdbcServices.class )
|
||||
.getJdbcEnvironment()
|
||||
.getDialect()
|
||||
.getPreferredSqlTypeCodeForArray();
|
||||
|
|
|
@ -76,7 +76,6 @@ import org.hibernate.jpa.boot.spi.StrategyRegistrationProviderList;
|
|||
import org.hibernate.jpa.boot.spi.TypeContributorList;
|
||||
import org.hibernate.jpa.internal.util.LogHelper;
|
||||
import org.hibernate.jpa.internal.util.PersistenceUnitTransactionTypeHelper;
|
||||
import org.hibernate.mapping.PersistentClass;
|
||||
import org.hibernate.proxy.EntityNotFoundDelegate;
|
||||
import org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorBuilderImpl;
|
||||
import org.hibernate.resource.transaction.backend.jta.internal.JtaTransactionCoordinatorBuilderImpl;
|
||||
|
@ -283,7 +282,7 @@ public class EntityManagerFactoryBuilderImpl implements EntityManagerFactoryBuil
|
|||
|
||||
// todo : would be nice to have MetadataBuilder still do the handling of CfgXmlAccessService here
|
||||
// another option is to immediately handle them here (probably in mergeSettings?) as we encounter them...
|
||||
final CfgXmlAccessService cfgXmlAccessService = standardServiceRegistry.getService( CfgXmlAccessService.class );
|
||||
final CfgXmlAccessService cfgXmlAccessService = standardServiceRegistry.requireService( CfgXmlAccessService.class );
|
||||
if ( cfgXmlAccessService.getAggregatedConfig() != null ) {
|
||||
if ( cfgXmlAccessService.getAggregatedConfig().getMappingReferences() != null ) {
|
||||
for ( MappingReference mappingReference : cfgXmlAccessService.getAggregatedConfig()
|
||||
|
@ -414,10 +413,10 @@ public class EntityManagerFactoryBuilderImpl implements EntityManagerFactoryBuil
|
|||
}
|
||||
}
|
||||
|
||||
final StandardServiceRegistry serviceRegistry = metamodelBuilder.getBootstrapContext().getServiceRegistry();
|
||||
final ClassLoaderService cls = serviceRegistry.getService( ClassLoaderService.class );
|
||||
final Collection<MetadataBuilderContributor> contributors = cls.loadJavaServices( MetadataBuilderContributor.class );
|
||||
contributors.forEach( (contributor) -> contributor.contribute( metamodelBuilder ) );
|
||||
metamodelBuilder.getBootstrapContext().getServiceRegistry()
|
||||
.requireService( ClassLoaderService.class )
|
||||
.loadJavaServices( MetadataBuilderContributor.class )
|
||||
.forEach( (contributor) -> contributor.contribute( metamodelBuilder ) );
|
||||
}
|
||||
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
@ -1398,10 +1397,10 @@ public class EntityManagerFactoryBuilderImpl implements EntityManagerFactoryBuil
|
|||
typeContributorList.getTypeContributors().forEach( metamodelBuilder::applyTypes );
|
||||
}
|
||||
|
||||
final StandardServiceRegistry serviceRegistry = metamodelBuilder.getBootstrapContext().getServiceRegistry();
|
||||
final ClassLoaderService cls = serviceRegistry.getService( ClassLoaderService.class );
|
||||
final Collection<TypeContributor> typeContributors = cls.loadJavaServices( TypeContributor.class );
|
||||
typeContributors.forEach( metamodelBuilder::applyTypes );
|
||||
metamodelBuilder.getBootstrapContext().getServiceRegistry()
|
||||
.requireService( ClassLoaderService.class )
|
||||
.loadJavaServices( TypeContributor.class )
|
||||
.forEach( metamodelBuilder::applyTypes );
|
||||
}
|
||||
|
||||
|
||||
|
@ -1521,7 +1520,7 @@ public class EntityManagerFactoryBuilderImpl implements EntityManagerFactoryBuil
|
|||
|
||||
protected void populateSfBuilder(SessionFactoryBuilder sfBuilder, StandardServiceRegistry ssr) {
|
||||
|
||||
final StrategySelector strategySelector = ssr.getService( StrategySelector.class );
|
||||
final StrategySelector strategySelector = ssr.requireService( StrategySelector.class );
|
||||
|
||||
// // Locate and apply the requested SessionFactory-level interceptor (if one)
|
||||
// final Object sessionFactoryInterceptorSetting = configurationValues.remove( org.hibernate.cfg.AvailableSettings.INTERCEPTOR );
|
||||
|
@ -1660,9 +1659,8 @@ public class EntityManagerFactoryBuilderImpl implements EntityManagerFactoryBuil
|
|||
else if ( settingValue instanceof String ) {
|
||||
String settingStringValue = (String) settingValue;
|
||||
if ( standardServiceRegistry != null ) {
|
||||
final ClassLoaderService classLoaderService = standardServiceRegistry.getService( ClassLoaderService.class );
|
||||
|
||||
instanceClass = classLoaderService.classForName( settingStringValue );
|
||||
instanceClass = standardServiceRegistry.requireService( ClassLoaderService.class )
|
||||
.classForName( settingStringValue );
|
||||
}
|
||||
else {
|
||||
try {
|
||||
|
|
|
@ -253,9 +253,8 @@ public class Any extends SimpleValue {
|
|||
final JdbcServices jdbcServices = buildingContext
|
||||
.getBootstrapContext()
|
||||
.getServiceRegistry()
|
||||
.getService( JdbcServices.class );
|
||||
|
||||
return column.getQuotedName( jdbcServices .getDialect() );
|
||||
.requireService( JdbcServices.class );
|
||||
return column.getQuotedName( jdbcServices.getDialect() );
|
||||
}
|
||||
|
||||
public void setDiscriminator(BasicValue discriminatorDescriptor) {
|
||||
|
|
|
@ -57,7 +57,7 @@ public class Array extends List {
|
|||
try {
|
||||
return getMetadata().getMetadataBuildingOptions()
|
||||
.getServiceRegistry()
|
||||
.getService( ClassLoaderService.class )
|
||||
.requireService( ClassLoaderService.class )
|
||||
.classForName( elementClassName );
|
||||
}
|
||||
catch (ClassLoadingException e) {
|
||||
|
|
|
@ -661,7 +661,7 @@ public class BasicValue extends SimpleValue implements JdbcTypeIndicators, Resol
|
|||
|
||||
@Override
|
||||
public ManagedBeanRegistry getManagedBeanRegistry() {
|
||||
return getServiceRegistry().getService( ManagedBeanRegistry.class );
|
||||
return getServiceRegistry().requireService( ManagedBeanRegistry.class );
|
||||
}
|
||||
|
||||
private Resolution<?> converterResolution(JavaType<?> javaType, ConverterDescriptor attributeConverterDescriptor) {
|
||||
|
@ -803,7 +803,7 @@ public class BasicValue extends SimpleValue implements JdbcTypeIndicators, Resol
|
|||
MetadataBuildingContext context) {
|
||||
|
||||
final StandardServiceRegistry serviceRegistry = context.getBootstrapContext().getServiceRegistry();
|
||||
final ManagedBeanRegistry managedBeanRegistry = serviceRegistry.getService( ManagedBeanRegistry.class );
|
||||
final ManagedBeanRegistry managedBeanRegistry = serviceRegistry.requireService( ManagedBeanRegistry.class );
|
||||
final TypeConfiguration typeConfiguration = context.getBootstrapContext().getTypeConfiguration();
|
||||
|
||||
final JpaAttributeConverterCreationContext converterCreationContext = new JpaAttributeConverterCreationContext() {
|
||||
|
|
|
@ -225,7 +225,7 @@ public abstract class Collection implements Fetchable, Value, Filterable, SoftDe
|
|||
try {
|
||||
final ClassLoaderService classLoaderService = getMetadata().getMetadataBuildingOptions()
|
||||
.getServiceRegistry()
|
||||
.getService( ClassLoaderService.class );
|
||||
.requireService( ClassLoaderService.class );
|
||||
setComparator( (Comparator<?>) classLoaderService.classForName( comparatorClassName ).getConstructor().newInstance() );
|
||||
}
|
||||
catch (Exception e) {
|
||||
|
|
|
@ -295,7 +295,7 @@ public class Component extends SimpleValue implements MetaAttributable, Sortable
|
|||
final ClassLoaderService classLoaderService = getMetadata()
|
||||
.getMetadataBuildingOptions()
|
||||
.getServiceRegistry()
|
||||
.getService( ClassLoaderService.class );
|
||||
.requireService( ClassLoaderService.class );
|
||||
try {
|
||||
return classLoaderService.classForName( componentClassName );
|
||||
}
|
||||
|
|
|
@ -54,8 +54,10 @@ public final class MappingHelper {
|
|||
String role,
|
||||
String propertyRef,
|
||||
MetadataImplementor metadata) {
|
||||
final ClassLoaderService cls = metadata.getMetadataBuildingOptions().getServiceRegistry().getService( ClassLoaderService.class );
|
||||
final Class<? extends UserCollectionType> userCollectionTypeClass = cls.classForName( typeName );
|
||||
final Class<? extends UserCollectionType> userCollectionTypeClass =
|
||||
metadata.getMetadataBuildingOptions().getServiceRegistry()
|
||||
.requireService( ClassLoaderService.class )
|
||||
.classForName( typeName );
|
||||
|
||||
final boolean hasParameters = CollectionHelper.isNotEmpty( typeParameters );
|
||||
final ManagedBean<? extends UserCollectionType> userTypeBean;
|
||||
|
@ -70,11 +72,11 @@ public final class MappingHelper {
|
|||
);
|
||||
}
|
||||
else {
|
||||
final ManagedBeanRegistry beanRegistry = metadata
|
||||
.getMetadataBuildingOptions()
|
||||
.getServiceRegistry()
|
||||
.getService( ManagedBeanRegistry.class );
|
||||
final ManagedBean<? extends UserCollectionType> userCollectionTypeBean = beanRegistry.getBean( userCollectionTypeClass );
|
||||
final ManagedBean<? extends UserCollectionType> userCollectionTypeBean =
|
||||
metadata.getMetadataBuildingOptions()
|
||||
.getServiceRegistry()
|
||||
.requireService( ManagedBeanRegistry.class )
|
||||
.getBean( userCollectionTypeClass );
|
||||
|
||||
if ( hasParameters ) {
|
||||
if ( ParameterizedType.class.isAssignableFrom( userCollectionTypeBean.getBeanClass() ) ) {
|
||||
|
|
|
@ -403,11 +403,8 @@ public class Property implements Serializable, MetaAttributable {
|
|||
? RepresentationMode.MAP
|
||||
: RepresentationMode.POJO;
|
||||
|
||||
return resolveServiceRegistry().getService( PropertyAccessStrategyResolver.class ).resolvePropertyAccessStrategy(
|
||||
clazz,
|
||||
accessName,
|
||||
representationMode
|
||||
);
|
||||
return resolveServiceRegistry().requireService( PropertyAccessStrategyResolver.class )
|
||||
.resolvePropertyAccessStrategy( clazz, accessName, representationMode );
|
||||
}
|
||||
|
||||
protected ServiceRegistry resolveServiceRegistry() {
|
||||
|
|
|
@ -300,7 +300,7 @@ public abstract class SimpleValue implements KeyValue {
|
|||
final ClassLoaderService cls = getMetadata()
|
||||
.getMetadataBuildingOptions()
|
||||
.getServiceRegistry()
|
||||
.getService( ClassLoaderService.class );
|
||||
.requireService( ClassLoaderService.class );
|
||||
try {
|
||||
final Class<? extends AttributeConverter<?,?>> converterClass = cls.classForName( converterClassName );
|
||||
this.attributeConverterDescriptor = new ClassBasedConverterDescriptor(
|
||||
|
@ -658,7 +658,7 @@ public abstract class SimpleValue implements KeyValue {
|
|||
getMetadata()
|
||||
.getMetadataBuildingOptions()
|
||||
.getServiceRegistry()
|
||||
.getService(ClassLoaderService.class)
|
||||
.requireService( ClassLoaderService.class )
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -702,7 +702,7 @@ public abstract class SimpleValue implements KeyValue {
|
|||
return getMetadata()
|
||||
.getMetadataBuildingOptions()
|
||||
.getServiceRegistry()
|
||||
.getService( ManagedBeanRegistry.class );
|
||||
.requireService( ManagedBeanRegistry.class );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -935,7 +935,7 @@ public abstract class SimpleValue implements KeyValue {
|
|||
final ClassLoaderService classLoaderService = getMetadata()
|
||||
.getMetadataBuildingOptions()
|
||||
.getServiceRegistry()
|
||||
.getService( ClassLoaderService.class );
|
||||
.requireService( ClassLoaderService.class );
|
||||
typeParameters.put(
|
||||
DynamicParameterizedType.PARAMETER_TYPE,
|
||||
new ParameterTypeImpl(
|
||||
|
@ -980,7 +980,7 @@ public abstract class SimpleValue implements KeyValue {
|
|||
final ClassLoaderService classLoaderService = getMetadata()
|
||||
.getMetadataBuildingOptions()
|
||||
.getServiceRegistry()
|
||||
.getService( ClassLoaderService.class );
|
||||
.requireService( ClassLoaderService.class );
|
||||
|
||||
return new ParameterTypeImpl(
|
||||
classLoaderService.classForTypeName(typeParameters.getProperty(DynamicParameterizedType.RETURNED_CLASS)),
|
||||
|
|
|
@ -92,7 +92,7 @@ public abstract class ToOne extends SimpleValue implements Fetchable, SortableVa
|
|||
if ( referencedEntityName == null ) {
|
||||
final ClassLoaderService cls = getMetadata().getMetadataBuildingOptions()
|
||||
.getServiceRegistry()
|
||||
.getService( ClassLoaderService.class );
|
||||
.requireService( ClassLoaderService.class );
|
||||
referencedEntityName = ReflectHelper.reflectedPropertyClass( className, propertyName, cls ).getName();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -101,7 +101,7 @@ public class EmbeddableRepresentationStrategyPojo extends AbstractEmbeddableRepr
|
|||
bootDescriptor.getComponentClass(),
|
||||
runtimeDescriptorAccess,
|
||||
creationContext.getServiceRegistry()
|
||||
.getService( ProxyFactoryFactory.class )
|
||||
.requireService( ProxyFactoryFactory.class )
|
||||
.buildBasicProxyFactory( bootDescriptor.getComponentClass() )
|
||||
);
|
||||
}
|
||||
|
@ -181,12 +181,10 @@ public class EmbeddableRepresentationStrategyPojo extends AbstractEmbeddableRepr
|
|||
propertyAccessMap.put( property.getName(), getPropertyAccesses()[i] );
|
||||
i++;
|
||||
}
|
||||
final BytecodeProvider bytecodeProvider = creationContext.getServiceRegistry().getService( BytecodeProvider.class );
|
||||
|
||||
return bytecodeProvider.getReflectionOptimizer(
|
||||
bootDescriptor.getComponentClass(),
|
||||
propertyAccessMap
|
||||
);
|
||||
return creationContext.getServiceRegistry()
|
||||
.requireService( BytecodeProvider.class )
|
||||
.getReflectionOptimizer( bootDescriptor.getComponentClass(), propertyAccessMap );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -138,7 +138,9 @@ public class EntityRepresentationStrategyPojoStandard implements EntityRepresent
|
|||
identifierPropertyAccess = makePropertyAccess( identifierProperty );
|
||||
}
|
||||
|
||||
final BytecodeProvider bytecodeProvider = creationContext.getBootstrapContext().getServiceRegistry().getService( BytecodeProvider.class );
|
||||
final BytecodeProvider bytecodeProvider =
|
||||
creationContext.getBootstrapContext().getServiceRegistry()
|
||||
.requireService( BytecodeProvider.class );
|
||||
|
||||
final EntityMetamodel entityMetamodel = runtimeDescriptor.getEntityMetamodel();
|
||||
ProxyFactory proxyFactory = null;
|
||||
|
|
|
@ -88,7 +88,7 @@ public class ManagedTypeRepresentationResolverStandard implements ManagedTypeRep
|
|||
else {
|
||||
compositeUserType = creationContext.getBootstrapContext()
|
||||
.getServiceRegistry()
|
||||
.getService( ManagedBeanRegistry.class )
|
||||
.requireService( ManagedBeanRegistry.class )
|
||||
.getBean( userTypeClass )
|
||||
.getBeanInstance();
|
||||
}
|
||||
|
@ -105,7 +105,7 @@ public class ManagedTypeRepresentationResolverStandard implements ManagedTypeRep
|
|||
else {
|
||||
customInstantiator = creationContext.getBootstrapContext()
|
||||
.getServiceRegistry()
|
||||
.getService( ManagedBeanRegistry.class )
|
||||
.requireService( ManagedBeanRegistry.class )
|
||||
.getBean( instantiatorClass )
|
||||
.getBeanInstance();
|
||||
}
|
||||
|
|
|
@ -166,7 +166,9 @@ public class EmbeddableMappingTypeImpl extends AbstractEmbeddableMapping impleme
|
|||
|
||||
this.createEmptyCompositesEnabled = ConfigurationHelper.getBoolean(
|
||||
Environment.CREATE_EMPTY_COMPOSITES_ENABLED,
|
||||
creationContext.getServiceRegistry().getService( ConfigurationService.class ).getSettings()
|
||||
creationContext.getServiceRegistry()
|
||||
.requireService( ConfigurationService.class )
|
||||
.getSettings()
|
||||
);
|
||||
final AggregateColumn aggregateColumn = bootDescriptor.getAggregateColumn();
|
||||
if ( aggregateColumn != null ) {
|
||||
|
|
|
@ -42,7 +42,7 @@ public class VirtualIdRepresentationStrategy implements EmbeddableRepresentation
|
|||
bootDescriptor.getComponentClass(),
|
||||
() -> virtualIdEmbeddable,
|
||||
creationContext.getServiceRegistry()
|
||||
.getService( ProxyFactoryFactory.class )
|
||||
.requireService( ProxyFactoryFactory.class )
|
||||
.buildBasicProxyFactory( bootDescriptor.getComponentClass() )
|
||||
|
||||
);
|
||||
|
|
|
@ -46,7 +46,7 @@ public class DomainModelHelper {
|
|||
// it could still be a mapped-superclass
|
||||
try {
|
||||
final Class<?> javaType = jpaMetamodel.getServiceRegistry()
|
||||
.getService( ClassLoaderService.class )
|
||||
.requireService( ClassLoaderService.class )
|
||||
.classForName( subTypeName );
|
||||
return (ManagedDomainType<S>) jpaMetamodel.managedType( javaType );
|
||||
}
|
||||
|
|
|
@ -408,7 +408,7 @@ public class JpaMetamodelImpl implements JpaMetamodelImplementor, Serializable {
|
|||
|
||||
private <X> Class<X> resolveRequestedClass(String entityName) {
|
||||
try {
|
||||
return getServiceRegistry().getService( ClassLoaderService.class ).classForName( entityName );
|
||||
return getServiceRegistry().requireService( ClassLoaderService.class ).classForName( entityName );
|
||||
}
|
||||
catch (ClassLoadingException e) {
|
||||
return null;
|
||||
|
|
|
@ -177,7 +177,7 @@ public class MappingMetamodelImpl extends QueryParameterBindingTypeResolverImpl
|
|||
bootModel.getEntityBindings().forEach( persistentClass -> persistentClass.prepareForMappingModel( context ) );
|
||||
|
||||
final PersisterFactory persisterFactory =
|
||||
jpaMetamodel.getServiceRegistry().getService( PersisterFactory.class );
|
||||
jpaMetamodel.getServiceRegistry().requireService( PersisterFactory.class );
|
||||
final CacheImplementor cache = context.getCache();
|
||||
processBootEntities(
|
||||
bootModel.getEntityBindings(),
|
||||
|
@ -534,7 +534,7 @@ public class MappingMetamodelImpl extends QueryParameterBindingTypeResolverImpl
|
|||
|
||||
try {
|
||||
final Class<?> clazz =
|
||||
jpaMetamodel.getServiceRegistry().getService( ClassLoaderService.class )
|
||||
jpaMetamodel.getServiceRegistry().requireService( ClassLoaderService.class )
|
||||
.classForName( className );
|
||||
implementors = doGetImplementors( clazz );
|
||||
if ( implementors.length > 0 ) {
|
||||
|
|
|
@ -793,7 +793,7 @@ public abstract class AbstractCollectionPersister
|
|||
if ( loadQueryInfluencers.effectivelyBatchLoadable( this ) ) {
|
||||
final int batchSize = loadQueryInfluencers.effectiveBatchSize( this );
|
||||
return factory.getServiceRegistry()
|
||||
.getService( BatchLoaderFactory.class )
|
||||
.requireService( BatchLoaderFactory.class )
|
||||
.createCollectionBatchLoader( batchSize, loadQueryInfluencers, attributeMapping, factory );
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -874,7 +874,7 @@ public abstract class AbstractEntityPersister
|
|||
if ( loadQueryInfluencers.effectivelyBatchLoadable( this ) ) {
|
||||
final int batchSize = loadQueryInfluencers.effectiveBatchSize( this );
|
||||
return factory.getServiceRegistry()
|
||||
.getService( BatchLoaderFactory.class )
|
||||
.requireService( BatchLoaderFactory.class )
|
||||
.createEntityBatchLoader( batchSize, this, factory );
|
||||
}
|
||||
else {
|
||||
|
@ -5312,7 +5312,7 @@ public abstract class AbstractEntityPersister
|
|||
}
|
||||
|
||||
final ServiceRegistry serviceRegistry = creationProcess.getCreationContext().getServiceRegistry();
|
||||
return serviceRegistry.getService( SqmMultiTableMutationStrategyProvider.class )
|
||||
return serviceRegistry.requireService( SqmMultiTableMutationStrategyProvider.class )
|
||||
.createMutationStrategy( entityMappingDescriptor, creationProcess );
|
||||
}
|
||||
|
||||
|
@ -5320,7 +5320,7 @@ public abstract class AbstractEntityPersister
|
|||
AbstractEntityPersister entityMappingDescriptor,
|
||||
MappingModelCreationProcess creationProcess) {
|
||||
final ServiceRegistry serviceRegistry = creationProcess.getCreationContext().getServiceRegistry();
|
||||
return serviceRegistry.getService( SqmMultiTableMutationStrategyProvider.class )
|
||||
return serviceRegistry.requireService( SqmMultiTableMutationStrategyProvider.class )
|
||||
.createInsertStrategy( entityMappingDescriptor, creationProcess );
|
||||
}
|
||||
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue