diff --git a/hibernate-core/src/main/java/org/hibernate/boot/registry/BootstrapServiceRegistryBuilder.java b/hibernate-core/src/main/java/org/hibernate/boot/registry/BootstrapServiceRegistryBuilder.java index 9c8fca374885..fe6c6ec7c08c 100644 --- a/hibernate-core/src/main/java/org/hibernate/boot/registry/BootstrapServiceRegistryBuilder.java +++ b/hibernate-core/src/main/java/org/hibernate/boot/registry/BootstrapServiceRegistryBuilder.java @@ -14,7 +14,6 @@ import org.hibernate.boot.registry.classloading.internal.TcclLookupPrecedence; import org.hibernate.boot.registry.classloading.spi.ClassLoaderService; import org.hibernate.boot.registry.internal.BootstrapServiceRegistryImpl; -import org.hibernate.boot.registry.selector.StrategyRegistration; import org.hibernate.boot.registry.selector.StrategyRegistrationProvider; import org.hibernate.boot.registry.selector.internal.StrategySelectorBuilder; import org.hibernate.integrator.internal.IntegratorServiceImpl; @@ -129,7 +128,7 @@ public BootstrapServiceRegistryBuilder applyStrategySelector(Class strate * @see org.hibernate.boot.registry.selector.spi.StrategySelector#registerStrategyImplementor(Class, String, Class) */ public BootstrapServiceRegistryBuilder applyStrategySelectors(StrategyRegistrationProvider strategyRegistrationProvider) { - for ( StrategyRegistration strategyRegistration : strategyRegistrationProvider.getStrategyRegistrations() ) { + for ( var strategyRegistration : strategyRegistrationProvider.getStrategyRegistrations() ) { this.strategySelectorBuilder.addExplicitStrategyRegistration( strategyRegistration ); } return this; @@ -169,33 +168,28 @@ public BootstrapServiceRegistryBuilder enableAutoClose() { * @return The built bootstrap registry */ public BootstrapServiceRegistry build() { - final ClassLoaderService classLoaderService; + final var classLoaderService = classLoaderService(); + return new BootstrapServiceRegistryImpl( + autoCloseRegistry, + classLoaderService, + strategySelectorBuilder.buildSelector( classLoaderService ), + new IntegratorServiceImpl( providedIntegrators, classLoaderService ) + ); + } + + private ClassLoaderService classLoaderService() { if ( providedClassLoaderService == null ) { // Use a set. As an example, in JPA, OsgiClassLoader may be in both // the providedClassLoaders and the overriddenClassLoader. final Set classLoaders = new HashSet<>(); - if ( providedClassLoaders != null ) { classLoaders.addAll( providedClassLoaders ); } - - classLoaderService = new ClassLoaderServiceImpl( classLoaders,tcclLookupPrecedence ); + return new ClassLoaderServiceImpl( classLoaders,tcclLookupPrecedence ); } else { - classLoaderService = providedClassLoaderService; + return providedClassLoaderService; } - - final IntegratorServiceImpl integratorService = IntegratorServiceImpl.create( - providedIntegrators, - classLoaderService - ); - - return new BootstrapServiceRegistryImpl( - autoCloseRegistry, - classLoaderService, - strategySelectorBuilder.buildSelector( classLoaderService ), - integratorService - ); } /** @@ -204,10 +198,8 @@ public BootstrapServiceRegistry build() { * @param serviceRegistry The registry to be closed. */ public static void destroy(ServiceRegistry serviceRegistry) { - if ( serviceRegistry == null ) { - return; + if ( serviceRegistry != null ) { + ((BootstrapServiceRegistryImpl) serviceRegistry).destroy(); } - - ( (BootstrapServiceRegistryImpl) serviceRegistry ).destroy(); } } diff --git a/hibernate-core/src/main/java/org/hibernate/boot/registry/internal/BootstrapServiceRegistryImpl.java b/hibernate-core/src/main/java/org/hibernate/boot/registry/internal/BootstrapServiceRegistryImpl.java index 6148256b47fc..9969081b2610 100644 --- a/hibernate-core/src/main/java/org/hibernate/boot/registry/internal/BootstrapServiceRegistryImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/boot/registry/internal/BootstrapServiceRegistryImpl.java @@ -105,17 +105,16 @@ public BootstrapServiceRegistryImpl( classLoaderService ); - final StrategySelectorImpl strategySelector = new StrategySelectorImpl( classLoaderService ); this.strategySelectorBinding = new ServiceBinding<>( this, StrategySelector.class, - strategySelector + new StrategySelectorImpl( classLoaderService ) ); this.integratorServiceBinding = new ServiceBinding<>( this, IntegratorService.class, - IntegratorServiceImpl.create( providedIntegrators, classLoaderService ) + new IntegratorServiceImpl( providedIntegrators, classLoaderService ) ); } @@ -184,7 +183,7 @@ public BootstrapServiceRegistryImpl( @Override public @Nullable R getService(Class serviceRole) { - final ServiceBinding binding = locateServiceBinding( serviceRole ); + final var binding = locateServiceBinding( serviceRole ); return binding == null ? null : binding.getService(); } @@ -206,24 +205,20 @@ else if ( IntegratorService.class.equals( serviceRole ) ) { @Override public synchronized void destroy() { - if ( !active ) { - return; - } - active = false; - destroy( classLoaderServiceBinding ); - destroy( strategySelectorBinding ); - destroy( integratorServiceBinding ); - - if ( childRegistries != null ) { - for ( ServiceRegistry serviceRegistry : childRegistries ) { - if ( serviceRegistry instanceof ServiceRegistryImplementor serviceRegistryImplementor ) { - serviceRegistryImplementor.destroy(); + if ( active ) { + active = false; + destroy( classLoaderServiceBinding ); + destroy( strategySelectorBinding ); + destroy( integratorServiceBinding ); + if ( childRegistries != null ) { + for ( var serviceRegistry : childRegistries ) { + serviceRegistry.destroy(); } } } } - private synchronized void destroy(ServiceBinding serviceBinding) { + private synchronized void destroy(ServiceBinding serviceBinding) { serviceBinding.getLifecycleOwner().stopService( serviceBinding ); } diff --git a/hibernate-core/src/main/java/org/hibernate/integrator/internal/IntegratorServiceImpl.java b/hibernate-core/src/main/java/org/hibernate/integrator/internal/IntegratorServiceImpl.java index 3651f0a34d05..f1138d57ebc4 100644 --- a/hibernate-core/src/main/java/org/hibernate/integrator/internal/IntegratorServiceImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/integrator/internal/IntegratorServiceImpl.java @@ -12,42 +12,33 @@ import org.hibernate.integrator.spi.Integrator; import org.hibernate.integrator.spi.IntegratorService; -import org.jboss.logging.Logger; +import static org.hibernate.service.internal.ServiceLogger.SERVICE_LOGGER; /** * @author Steve Ebersole */ public class IntegratorServiceImpl implements IntegratorService { - private static final Logger LOG = Logger.getLogger( IntegratorServiceImpl.class ); - private final LinkedHashSet integrators = new LinkedHashSet<>(); - private IntegratorServiceImpl() { - } - - public static IntegratorServiceImpl create(LinkedHashSet providedIntegrators, ClassLoaderService classLoaderService) { - IntegratorServiceImpl instance = new IntegratorServiceImpl(); - - // register standard integrators. Envers and JPA, for example, need to be handled by discovery because in - // separate project/jars. - instance.addIntegrator( new BeanValidationIntegrator() ); - instance.addIntegrator( new CollectionCacheInvalidator() ); + public IntegratorServiceImpl(Iterable providedIntegrators, ClassLoaderService classLoaderService) { + // Register standard integrators. + // Envers, for example, needs to be handled by discovery because in separate project/jar. + addIntegrator( integrators, new BeanValidationIntegrator() ); + addIntegrator( integrators, new CollectionCacheInvalidator() ); // register provided integrators - for ( Integrator integrator : providedIntegrators ) { - instance.addIntegrator( integrator ); + for ( var integrator : providedIntegrators ) { + addIntegrator( integrators, integrator ); } - for ( Integrator integrator : classLoaderService.loadJavaServices( Integrator.class ) ) { - instance.addIntegrator( integrator ); + for ( var integrator : classLoaderService.loadJavaServices( Integrator.class ) ) { + addIntegrator( integrators, integrator ); } - - return instance; } - private void addIntegrator(Integrator integrator) { - if ( LOG.isDebugEnabled() ) { - LOG.debugf( "Adding Integrator [%s]", integrator.getClass().getName() ); + private static void addIntegrator(LinkedHashSet integrators, Integrator integrator) { + if ( SERVICE_LOGGER.isDebugEnabled() ) { + SERVICE_LOGGER.addingIntegrator( integrator.getClass().getName() ); } integrators.add( integrator ); } diff --git a/hibernate-core/src/main/java/org/hibernate/service/NullServiceException.java b/hibernate-core/src/main/java/org/hibernate/service/NullServiceException.java index 634fc14653fd..61373bd0982c 100644 --- a/hibernate-core/src/main/java/org/hibernate/service/NullServiceException.java +++ b/hibernate-core/src/main/java/org/hibernate/service/NullServiceException.java @@ -10,14 +10,14 @@ * @author Andrea Boriero */ public class NullServiceException extends ServiceException { - public final Class serviceRole; + public final Class serviceRole; - public NullServiceException(Class serviceRole) { + public NullServiceException(Class serviceRole) { super( "Unknown service requested [" + serviceRole.getName() + "]" ); this.serviceRole = serviceRole; } - public Class getServiceRole() { + public Class getServiceRole() { return serviceRole; } } diff --git a/hibernate-core/src/main/java/org/hibernate/service/StandardServiceInitiators.java b/hibernate-core/src/main/java/org/hibernate/service/StandardServiceInitiators.java index 5406367fcaa0..c8bcee23f0fc 100644 --- a/hibernate-core/src/main/java/org/hibernate/service/StandardServiceInitiators.java +++ b/hibernate-core/src/main/java/org/hibernate/service/StandardServiceInitiators.java @@ -59,7 +59,7 @@ private static List> buildStandardServiceInitiatorLi // Please do not rearrange - it's useful to maintain this particular order // so to simplify comparisons with custom initiator lists in other projects; - // for example we customize this list in Hibernate Reactive and Quarkus. + // for example, we customize this list in Hibernate Reactive and Quarkus. final ArrayList> serviceInitiators = new ArrayList<>(); diff --git a/hibernate-core/src/main/java/org/hibernate/service/UnknownServiceException.java b/hibernate-core/src/main/java/org/hibernate/service/UnknownServiceException.java index 56919d7b859d..2de73e254590 100644 --- a/hibernate-core/src/main/java/org/hibernate/service/UnknownServiceException.java +++ b/hibernate-core/src/main/java/org/hibernate/service/UnknownServiceException.java @@ -11,14 +11,14 @@ * @author Steve Ebersole */ public class UnknownServiceException extends ServiceException { - public final Class serviceRole; + public final Class serviceRole; - public UnknownServiceException(Class serviceRole) { + public UnknownServiceException(Class serviceRole) { super( "Unknown service requested [" + serviceRole.getName() + "]" ); this.serviceRole = serviceRole; } - public Class getServiceRole() { + public Class getServiceRole() { return serviceRole; } } diff --git a/hibernate-core/src/main/java/org/hibernate/service/UnknownUnwrapTypeException.java b/hibernate-core/src/main/java/org/hibernate/service/UnknownUnwrapTypeException.java index 2523bf1fade9..c7226b77a70c 100644 --- a/hibernate-core/src/main/java/org/hibernate/service/UnknownUnwrapTypeException.java +++ b/hibernate-core/src/main/java/org/hibernate/service/UnknownUnwrapTypeException.java @@ -10,11 +10,11 @@ * @author Steve Ebersole */ public class UnknownUnwrapTypeException extends HibernateException { - public UnknownUnwrapTypeException(Class unwrapType) { + public UnknownUnwrapTypeException(Class unwrapType) { super( "Cannot unwrap to requested type [" + unwrapType.getName() + "]" ); } - public UnknownUnwrapTypeException(Class unwrapType, Throwable root) { + public UnknownUnwrapTypeException(Class unwrapType, Throwable root) { this( unwrapType ); super.initCause( root ); } diff --git a/hibernate-core/src/main/java/org/hibernate/service/internal/AbstractServiceRegistryImpl.java b/hibernate-core/src/main/java/org/hibernate/service/internal/AbstractServiceRegistryImpl.java index d3963157147e..8270d686354e 100644 --- a/hibernate-core/src/main/java/org/hibernate/service/internal/AbstractServiceRegistryImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/service/internal/AbstractServiceRegistryImpl.java @@ -110,12 +110,12 @@ protected void createServiceBinding(ServiceInitiator init } protected void createServiceBinding(ProvidedService providedService) { - var binding = locateServiceBinding( providedService.getServiceRole(), false ); + var binding = locateServiceBinding( providedService.serviceRole(), false ); if ( binding == null ) { - binding = new ServiceBinding<>( this, providedService.getServiceRole(), providedService.getService() ); - serviceBindingMap.put( providedService.getServiceRole(), binding ); + binding = new ServiceBinding<>( this, providedService.serviceRole(), providedService.service() ); + serviceBindingMap.put( providedService.serviceRole(), binding ); } - registerService( binding, providedService.getService() ); + registerService( binding, providedService.service() ); } protected void visitServiceBindings(Consumer> action) { @@ -156,18 +156,21 @@ protected void visitServiceBindings(Consumer> action) { // perform a crawl looking for an alternate registration for ( var binding : serviceBindingMap.values() ) { - if ( serviceRole.isAssignableFrom( binding.getServiceRole() ) ) { + final Class bindingServiceRole = binding.getServiceRole(); + if ( serviceRole.isAssignableFrom( bindingServiceRole ) ) { // we found an alternate... - SERVICE_LOGGER.alternateServiceRole( serviceRole.getName(), binding.getServiceRole().getName() ); - registerAlternate( serviceRole, binding.getServiceRole() ); + SERVICE_LOGGER.alternateServiceRole( serviceRole.getName(), bindingServiceRole.getName() ); + registerAlternate( serviceRole, bindingServiceRole ); return (ServiceBinding) binding; } - - if ( binding.getService() != null && serviceRole.isInstance( binding.getService() ) ) { - // we found an alternate... - SERVICE_LOGGER.alternateServiceRole( serviceRole.getName(), binding.getServiceRole().getName() ); - registerAlternate( serviceRole, binding.getServiceRole() ); - return (ServiceBinding) binding; + else { + final var bindingService = binding.getService(); + if ( serviceRole.isInstance( bindingService ) ) { + // we found an alternate... + SERVICE_LOGGER.alternateServiceRole( serviceRole.getName(), bindingServiceRole.getName() ); + registerAlternate( serviceRole, bindingServiceRole ); + return (ServiceBinding) binding; + } } } @@ -183,10 +186,8 @@ private void registerAlternate(Class alternate, Class target) { // Fast-path for ClassLoaderService as it's extremely hot during bootstrap // (and after bootstrap service loading performance is less interesting as it's // ideally being cached by long-term consumers) - if ( ClassLoaderService.class == serviceRole ) { - if ( parent != null ) { - return parent.getService( serviceRole ); - } + if ( ClassLoaderService.class == serviceRole && parent != null ) { + return parent.getService( serviceRole ); } // TODO: should an exception be thrown if active == false??? R service = serviceRole.cast( initializedServiceByRole.get( serviceRole ) ); @@ -231,7 +232,7 @@ protected void registerService(ServiceBinding serviceBind } // PHASE 1: create service - R service = createService( serviceBinding ); + final R service = createService( serviceBinding ); if ( service == null ) { return null; } @@ -256,7 +257,7 @@ protected void registerService(ServiceBinding serviceBind } try { - R service = serviceBinding.getLifecycleOwner().initiateService( serviceInitiator ); + final R service = serviceBinding.getLifecycleOwner().initiateService( serviceInitiator ); // IMPL NOTE: the register call here is important to avoid potential stack overflow issues // from recursive calls through #configureService if ( service != null ) { @@ -276,9 +277,7 @@ protected void registerService(ServiceBinding serviceBind @Override public void injectDependencies(ServiceBinding serviceBinding) { final R service = serviceBinding.getService(); - applyInjections( service ); - if ( service instanceof ServiceRegistryAwareService serviceRegistryAwareService ) { serviceRegistryAwareService.injectServices( this ); } @@ -286,8 +285,8 @@ public void injectDependencies(ServiceBinding serviceBind private void applyInjections(R service) { try { - for ( Method method : service.getClass().getMethods() ) { - final InjectService injectService = method.getAnnotation( InjectService.class ); + for ( var method : service.getClass().getMethods() ) { + final var injectService = method.getAnnotation( InjectService.class ); if ( injectService != null ) { processInjection( service, method, injectService ); } @@ -299,23 +298,14 @@ private void applyInjections(R service) { } private void processInjection(T service, Method injectionMethod, InjectService injectService) { - final Class[] parameterTypes = injectionMethod.getParameterTypes(); - if ( injectionMethod.getParameterCount() != 1 ) { - throw new ServiceDependencyException( - "Encountered @InjectService on method with unexpected number of parameters" - ); - } - - //noinspection rawtypes - Class dependentServiceRole = injectService.serviceRole(); - if ( dependentServiceRole == null || dependentServiceRole.equals( Void.class ) ) { - dependentServiceRole = parameterTypes[0]; - } + injectDependentService( service, injectionMethod, injectService, + dependentServiceRole( injectionMethod, injectService ) ); + } + private void injectDependentService(T service, Method injectionMethod, InjectService injectService, Class dependentServiceRole) { // todo : because of the use of proxies, this is no longer returning null here... - //noinspection unchecked - final Service dependantService = getService( dependentServiceRole ); + final var dependantService = getService( dependentServiceRole ); if ( dependantService == null ) { if ( injectService.required() ) { throw new ServiceDependencyException( @@ -333,6 +323,25 @@ private void processInjection(T service, Method injectionMet } } + private static Class dependentServiceRole(Method injectionMethod, InjectService injectService) { + final var parameterTypes = injectionMethod.getParameterTypes(); + if ( injectionMethod.getParameterCount() != 1 ) { + throw new ServiceDependencyException( + "Encountered @InjectService on method with unexpected number of parameters" + ); + } + + final var dependentServiceRole = injectService.serviceRole(); + if ( dependentServiceRole == null + || Void.class.equals( dependentServiceRole ) // old default value + || Service.class.equals( dependentServiceRole ) ) { // new default value + return (Class) parameterTypes[0]; + } + else { + return dependentServiceRole; + } + } + @Override public void startService(ServiceBinding serviceBinding) { if ( serviceBinding.getService() instanceof Startable startable ) { diff --git a/hibernate-core/src/main/java/org/hibernate/service/internal/ProvidedService.java b/hibernate-core/src/main/java/org/hibernate/service/internal/ProvidedService.java index 6349be39900d..bf16f23d0b6d 100644 --- a/hibernate-core/src/main/java/org/hibernate/service/internal/ProvidedService.java +++ b/hibernate-core/src/main/java/org/hibernate/service/internal/ProvidedService.java @@ -9,20 +9,5 @@ * * @author Steve Ebersole */ -public class ProvidedService { - private final Class serviceRole; - private final R service; - - public ProvidedService(Class serviceRole, R service) { - this.serviceRole = serviceRole; - this.service = service; - } - - public Class getServiceRole() { - return serviceRole; - } - - public R getService() { - return service; - } +public record ProvidedService(Class serviceRole, R service) { } diff --git a/hibernate-core/src/main/java/org/hibernate/service/internal/ServiceLogger.java b/hibernate-core/src/main/java/org/hibernate/service/internal/ServiceLogger.java index 99da662cd264..be65f14508eb 100644 --- a/hibernate-core/src/main/java/org/hibernate/service/internal/ServiceLogger.java +++ b/hibernate-core/src/main/java/org/hibernate/service/internal/ServiceLogger.java @@ -19,16 +19,17 @@ import java.lang.invoke.MethodHandles; import java.util.ServiceConfigurationError; +import static org.jboss.logging.Logger.Level.DEBUG; import static org.jboss.logging.Logger.Level.INFO; import static org.jboss.logging.Logger.Level.TRACE; import static org.jboss.logging.Logger.Level.WARN; /** - * Miscellaneous logging related to Hibernate ORM Core. + * Logging related to Hibernate Services. */ @SubSystemLogging( name = SessionLogging.NAME, - description = "Miscellaneous Logging related to Hibernate ORM Core" + description = "Logging related to Hibernate Services" ) @MessageLogger(projectCode = "HHH") @ValidIdRange(min=10002,max = 20000) @@ -67,4 +68,13 @@ public interface ServiceLogger extends BasicLogger { @LogMessage(level = TRACE) @Message(id = 10453, value = "Skipping destroying bootstrap registry after deregistration of every child ServiceRegistry") void skippingBootstrapRegistryDestruction(); + + @LogMessage(level = DEBUG) + @Message( id = 10454, value = "EventListenerRegistry access via ServiceRegistry is deprecated - " + + "use 'sessionFactory.getEventEngine().getListenerRegistry()' instead" ) + void eventListenerRegistryAccessDeprecated(); + + @LogMessage(level = DEBUG) + @Message(id = 10455, value = "Adding integrator: %s") + void addingIntegrator(String name); } diff --git a/hibernate-core/src/main/java/org/hibernate/service/internal/ServiceProxyGenerationException.java b/hibernate-core/src/main/java/org/hibernate/service/internal/ServiceProxyGenerationException.java deleted file mode 100644 index 0752ccc07a20..000000000000 --- a/hibernate-core/src/main/java/org/hibernate/service/internal/ServiceProxyGenerationException.java +++ /dev/null @@ -1,22 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * Copyright Red Hat Inc. and Hibernate Authors - */ -package org.hibernate.service.internal; - -import org.hibernate.HibernateException; - -/** - * Indicates a problem generating a service proxy - * - * @author Steve Ebersole - */ -public class ServiceProxyGenerationException extends HibernateException { - public ServiceProxyGenerationException(String string, Throwable root) { - super( string, root ); - } - - public ServiceProxyGenerationException(Throwable root) { - super( root ); - } -} diff --git a/hibernate-core/src/main/java/org/hibernate/service/internal/SessionFactoryServiceRegistryBuilderImpl.java b/hibernate-core/src/main/java/org/hibernate/service/internal/SessionFactoryServiceRegistryBuilderImpl.java index 32de60d7bd10..11c5289562c0 100644 --- a/hibernate-core/src/main/java/org/hibernate/service/internal/SessionFactoryServiceRegistryBuilderImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/service/internal/SessionFactoryServiceRegistryBuilderImpl.java @@ -29,14 +29,8 @@ public class SessionFactoryServiceRegistryBuilderImpl implements SessionFactoryS public SessionFactoryServiceRegistryBuilderImpl(ServiceRegistryImplementor parent) { this.parent = parent; if ( parent != null ) { - for ( var iterator = initiators.iterator(); iterator.hasNext(); ) { - final var initiator = iterator.next(); - if ( parent.locateServiceBinding( initiator.getServiceInitiated() ) != null ) { - // Parent takes precedence over the standard service initiators - iterator.remove(); - } - } - + // Parent takes precedence over the standard service initiators + initiators.removeIf( initiator -> parent.locateServiceBinding( initiator.getServiceInitiated() ) != null ); } } diff --git a/hibernate-core/src/main/java/org/hibernate/service/internal/SessionFactoryServiceRegistryImpl.java b/hibernate-core/src/main/java/org/hibernate/service/internal/SessionFactoryServiceRegistryImpl.java index beef8f4c7952..6a921040fd2a 100644 --- a/hibernate-core/src/main/java/org/hibernate/service/internal/SessionFactoryServiceRegistryImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/service/internal/SessionFactoryServiceRegistryImpl.java @@ -19,10 +19,10 @@ import org.hibernate.service.spi.SessionFactoryServiceInitiatorContext; import org.hibernate.service.spi.SessionFactoryServiceRegistry; -import org.jboss.logging.Logger; - import org.checkerframework.checker.nullness.qual.Nullable; +import static org.hibernate.service.internal.ServiceLogger.SERVICE_LOGGER; + /** * @author Steve Ebersole */ @@ -30,8 +30,6 @@ public class SessionFactoryServiceRegistryImpl extends AbstractServiceRegistryImpl implements SessionFactoryServiceRegistry, SessionFactoryServiceInitiatorContext { - private static final Logger LOG = Logger.getLogger( SessionFactoryServiceRegistryImpl.class ); - private final SessionFactoryOptions sessionFactoryOptions; private final SessionFactoryImplementor sessionFactory; @@ -101,11 +99,7 @@ public ServiceRegistryImplementor getServiceRegistry() { @Override public @Nullable R getService(Class serviceRole) { if ( serviceRole.equals( EventListenerRegistry.class ) ) { - LOG.debug( - "EventListenerRegistry access via ServiceRegistry is deprecated - " - + "use 'sessionFactory.getEventEngine().getListenerRegistry()' instead" - ); - + SERVICE_LOGGER.eventListenerRegistryAccessDeprecated(); //noinspection unchecked return (R) sessionFactory.getEventEngine().getListenerRegistry(); } diff --git a/hibernate-core/src/main/java/org/hibernate/service/spi/InjectService.java b/hibernate-core/src/main/java/org/hibernate/service/spi/InjectService.java index 73f495dd6282..37af7b9604d8 100644 --- a/hibernate-core/src/main/java/org/hibernate/service/spi/InjectService.java +++ b/hibernate-core/src/main/java/org/hibernate/service/spi/InjectService.java @@ -3,6 +3,9 @@ * Copyright Red Hat Inc. and Hibernate Authors */ package org.hibernate.service.spi; + +import org.hibernate.service.Service; + import java.lang.annotation.Retention; import java.lang.annotation.Target; @@ -23,7 +26,7 @@ * * @return The service role. */ - Class serviceRole() default Void.class; + Class serviceRole() default Service.class; /** * Is the service to be injected required (not optional)?