HHH-13447 Minimize number of EventListenerRegistry lookups within a Session use

This commit is contained in:
Sanne Grinovero 2019-06-20 10:33:45 +01:00
parent e476a99250
commit 33f02f411f
1 changed files with 5 additions and 1 deletions

View File

@ -242,6 +242,7 @@ public final class SessionImpl
private transient boolean discardOnClose; private transient boolean discardOnClose;
private transient TransactionObserver transactionObserver; private transient TransactionObserver transactionObserver;
private transient EventListenerRegistry eventListenerRegistry;
public SessionImpl(SessionFactoryImpl factory, SessionCreationOptions options) { public SessionImpl(SessionFactoryImpl factory, SessionCreationOptions options) {
super( factory, options ); super( factory, options );
@ -678,7 +679,10 @@ public final class SessionImpl
} }
private <T> EventListenerGroup<T> eventListenerGroup(EventType<T> type) { private <T> EventListenerGroup<T> eventListenerGroup(EventType<T> type) {
return getFactory().getServiceRegistry().getService( EventListenerRegistry.class ).getEventListenerGroup( type ); if ( this.eventListenerRegistry == null ) {
this.eventListenerRegistry = getFactory().getServiceRegistry().getService( EventListenerRegistry.class );
}
return eventListenerRegistry.getEventListenerGroup( type );
} }