HHH-13997 Use functions for the creation of ActionQueue and PersistenceContext

This commit is contained in:
Davide D'Alto 2020-05-15 10:47:49 +01:00
parent 9cd2236fd3
commit 00acb1f213
1 changed files with 10 additions and 10 deletions

View File

@ -28,6 +28,7 @@ import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.function.Function;
import java.util.function.Supplier;
import javax.persistence.CacheRetrieveMode;
import javax.persistence.CacheStoreMode;
@ -219,10 +220,17 @@ public class SessionImpl
private transient GraphImplementor fetchGraphLoadContext;
public SessionImpl(SessionFactoryImpl factory, SessionCreationOptions options) {
this( factory, options, StatefulPersistenceContext::new, ActionQueue::new );
}
public SessionImpl(
SessionFactoryImpl factory, SessionCreationOptions options,
Function<SharedSessionContractImplementor, StatefulPersistenceContext> persistenceContextFunction,
Function<SessionImplementor, ActionQueue> actionQueueFunction) {
super( factory, options );
this.persistenceContext = createPersistenceContext();
this.actionQueue = createActionQueue();
this.persistenceContext = persistenceContextFunction.apply( this );
this.actionQueue = actionQueueFunction.apply( this );
this.autoClear = options.shouldAutoClear();
this.autoClose = options.shouldAutoClose();
@ -269,14 +277,6 @@ public class SessionImpl
}
}
protected StatefulPersistenceContext createPersistenceContext() {
return new StatefulPersistenceContext( this );
}
protected ActionQueue createActionQueue() {
return new ActionQueue( this );
}
private LockOptions getLockOptionsForRead() {
return this.lockOptions == null ? fastSessionServices.defaultLockOptions : this.lockOptions;
}