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 6ad8eaa896
commit c320c6e8dd
1 changed files with 5 additions and 1 deletions

View File

@ -249,6 +249,7 @@ public final class SessionImpl
private transient boolean discardOnClose;
private transient TransactionObserver transactionObserver;
private transient EventListenerRegistry eventListenerRegistry;
public SessionImpl(SessionFactoryImpl factory, SessionCreationOptions options) {
super( factory, options );
@ -685,7 +686,10 @@ public final class SessionImpl
}
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 );
}