mirror of
https://github.com/hibernate/hibernate-orm
synced 2025-02-10 21:24:49 +00:00
HHH-11051 : Cache EventListenerRegistry and StatisticsImplementor
(cherry picked from commit 97318b71f0eb22296d46077b0eac527fa454329e) Conflicts: hibernate-core/src/main/java/org/hibernate/internal/SessionFactoryImpl.java (cherry picked from commit 836691b5a7ffbba92cedf9472f383b9b4f9a31ce) Conflicts: hibernate-core/src/main/java/org/hibernate/internal/SessionFactoryImpl.java
This commit is contained in:
parent
f201d2829e
commit
65422a6750
@ -191,6 +191,7 @@ public final class SessionFactoryImpl implements SessionFactoryImplementor {
|
||||
|
||||
private final transient TypeResolver typeResolver;
|
||||
private final transient TypeHelper typeHelper;
|
||||
private transient StatisticsImplementor statisticsImplementor;
|
||||
|
||||
|
||||
public SessionFactoryImpl(final MetadataImplementor metadata, SessionFactoryOptions options) {
|
||||
|
@ -10,7 +10,9 @@
|
||||
|
||||
import org.hibernate.boot.spi.SessionFactoryOptions;
|
||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||
import org.hibernate.event.service.spi.EventListenerRegistry;
|
||||
import org.hibernate.service.Service;
|
||||
import org.hibernate.service.UnknownServiceException;
|
||||
import org.hibernate.service.spi.ServiceBinding;
|
||||
import org.hibernate.service.spi.ServiceInitiator;
|
||||
import org.hibernate.service.spi.ServiceRegistryImplementor;
|
||||
@ -24,6 +26,7 @@ public class SessionFactoryServiceRegistryImpl extends AbstractServiceRegistryIm
|
||||
|
||||
private final SessionFactoryOptions sessionFactoryOptions;
|
||||
private final SessionFactoryImplementor sessionFactory;
|
||||
private EventListenerRegistry cachedEventListenerRegistry;
|
||||
|
||||
@SuppressWarnings( {"unchecked"})
|
||||
public SessionFactoryServiceRegistryImpl(
|
||||
@ -59,4 +62,19 @@ public <R extends Service> R initiateService(ServiceInitiator<R> serviceInitiato
|
||||
public <R extends Service> void configureService(ServiceBinding<R> serviceBinding) {
|
||||
//TODO nothing to do here or should we inject SessionFactory properties?
|
||||
}
|
||||
|
||||
@Override
|
||||
public <R extends Service> R getService(Class<R> serviceRole) {
|
||||
|
||||
//HHH-11051 cache EventListenerRegistry
|
||||
if ( serviceRole.equals( EventListenerRegistry.class ) ) {
|
||||
if ( cachedEventListenerRegistry == null ) {
|
||||
cachedEventListenerRegistry = (EventListenerRegistry) super.getService( serviceRole );
|
||||
}
|
||||
return (R) cachedEventListenerRegistry;
|
||||
}
|
||||
|
||||
return super.getService( serviceRole );
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user