HHH-13565 Promote JDBCServices as hot service to be retrieved from FastSessionService as well
This commit is contained in:
parent
185ef2edb7
commit
8931ef0962
|
@ -82,7 +82,8 @@ public class JdbcCoordinatorImpl implements JdbcCoordinator {
|
|||
*/
|
||||
public JdbcCoordinatorImpl(
|
||||
Connection userSuppliedConnection,
|
||||
JdbcSessionOwner owner) {
|
||||
JdbcSessionOwner owner,
|
||||
JdbcServices jdbcServices) {
|
||||
this.isUserSuppliedConnection = userSuppliedConnection != null;
|
||||
|
||||
final ResourceRegistry resourceRegistry = new ResourceRegistryStandardImpl(
|
||||
|
@ -95,13 +96,12 @@ public class JdbcCoordinatorImpl implements JdbcCoordinator {
|
|||
this.logicalConnection = new LogicalConnectionManagedImpl(
|
||||
owner.getJdbcConnectionAccess(),
|
||||
owner.getJdbcSessionContext(),
|
||||
resourceRegistry
|
||||
resourceRegistry,
|
||||
jdbcServices
|
||||
);
|
||||
}
|
||||
this.owner = owner;
|
||||
this.jdbcServices = owner.getJdbcSessionContext()
|
||||
.getServiceRegistry()
|
||||
.getService( JdbcServices.class );
|
||||
this.jdbcServices = jdbcServices;
|
||||
}
|
||||
|
||||
private JdbcCoordinatorImpl(
|
||||
|
|
|
@ -210,7 +210,7 @@ public abstract class AbstractSharedSessionContract implements SharedSessionCont
|
|||
else {
|
||||
this.isTransactionCoordinatorShared = false;
|
||||
this.autoJoinTransactions = options.shouldAutoJoinTransactions();
|
||||
this.jdbcCoordinator = new JdbcCoordinatorImpl( options.getConnection(), this );
|
||||
this.jdbcCoordinator = new JdbcCoordinatorImpl( options.getConnection(), this, fastSessionServices.jdbcServices );
|
||||
this.transactionCoordinator = fastSessionServices.transactionCoordinatorBuilder.buildTransactionCoordinator( jdbcCoordinator, this );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -86,6 +86,7 @@ final class FastSessionServices {
|
|||
final MultiTenantConnectionProvider multiTenantConnectionProvider;
|
||||
final ClassLoaderService classLoaderService;
|
||||
final TransactionCoordinatorBuilder transactionCoordinatorBuilder;
|
||||
final JdbcServices jdbcServices;
|
||||
|
||||
//Private fields:
|
||||
private final Dialect dialect;
|
||||
|
@ -128,6 +129,7 @@ final class FastSessionServices {
|
|||
this.multiTenantConnectionProvider = requiresMultiTenantConnectionProvider ? sr.getService( MultiTenantConnectionProvider.class ) : null;
|
||||
this.classLoaderService = sr.getService( ClassLoaderService.class );
|
||||
this.transactionCoordinatorBuilder = sr.getService( TransactionCoordinatorBuilder.class );
|
||||
this.jdbcServices = sr.getService( JdbcServices.class );
|
||||
}
|
||||
|
||||
Iterable<ClearEventListener> getClearEventListeners() {
|
||||
|
|
|
@ -48,20 +48,17 @@ public class LogicalConnectionManagedImpl extends AbstractLogicalConnectionImple
|
|||
public LogicalConnectionManagedImpl(
|
||||
JdbcConnectionAccess jdbcConnectionAccess,
|
||||
JdbcSessionContext jdbcSessionContext,
|
||||
ResourceRegistry resourceRegistry) {
|
||||
ResourceRegistry resourceRegistry,
|
||||
JdbcServices jdbcServices) {
|
||||
this.jdbcConnectionAccess = jdbcConnectionAccess;
|
||||
this.observer = jdbcSessionContext.getObserver();
|
||||
this.resourceRegistry = resourceRegistry;
|
||||
|
||||
this.connectionHandlingMode = determineConnectionHandlingMode(
|
||||
jdbcSessionContext.getPhysicalConnectionHandlingMode(),
|
||||
jdbcConnectionAccess
|
||||
jdbcConnectionAccess );
|
||||
|
||||
);
|
||||
|
||||
this.sqlExceptionHelper = jdbcSessionContext.getServiceRegistry()
|
||||
.getService( JdbcServices.class )
|
||||
.getSqlExceptionHelper();
|
||||
this.sqlExceptionHelper = jdbcServices.getSqlExceptionHelper();
|
||||
|
||||
if ( connectionHandlingMode.getAcquisitionMode() == ConnectionAcquisitionMode.IMMEDIATELY ) {
|
||||
acquireConnectionIfNeeded();
|
||||
|
@ -94,7 +91,9 @@ public class LogicalConnectionManagedImpl extends AbstractLogicalConnectionImple
|
|||
JdbcConnectionAccess jdbcConnectionAccess,
|
||||
JdbcSessionContext jdbcSessionContext,
|
||||
boolean closed) {
|
||||
this( jdbcConnectionAccess, jdbcSessionContext, new ResourceRegistryStandardImpl() );
|
||||
this( jdbcConnectionAccess, jdbcSessionContext, new ResourceRegistryStandardImpl(),
|
||||
jdbcSessionContext.getServiceRegistry().getService( JdbcServices.class )
|
||||
);
|
||||
this.closed = closed;
|
||||
}
|
||||
|
||||
|
@ -221,7 +220,7 @@ public class LogicalConnectionManagedImpl extends AbstractLogicalConnectionImple
|
|||
public static LogicalConnectionManagedImpl deserialize(
|
||||
ObjectInputStream ois,
|
||||
JdbcConnectionAccess jdbcConnectionAccess,
|
||||
JdbcSessionContext jdbcSessionContext) throws IOException, ClassNotFoundException {
|
||||
JdbcSessionContext jdbcSessionContext) throws IOException {
|
||||
final boolean isClosed = ois.readBoolean();
|
||||
return new LogicalConnectionManagedImpl( jdbcConnectionAccess, jdbcSessionContext, isClosed );
|
||||
}
|
||||
|
|
|
@ -62,8 +62,6 @@ public class JdbcCoordinatorTest {
|
|||
when( sessionContext.getObserver() ).thenReturn( jdbcObserver );
|
||||
|
||||
JdbcServices jdbcServices = Mockito.mock( JdbcServices.class );
|
||||
when( serviceRegistry.getService( eq( JdbcServices.class ) ) ).thenReturn(
|
||||
jdbcServices );
|
||||
|
||||
ConfigurationService configurationService = Mockito.mock( ConfigurationService.class );
|
||||
when( serviceRegistry.getService( eq( ConfigurationService.class ) ) ).thenReturn(
|
||||
|
@ -77,7 +75,8 @@ public class JdbcCoordinatorTest {
|
|||
|
||||
JdbcCoordinatorImpl jdbcCoordinator = new JdbcCoordinatorImpl(
|
||||
null,
|
||||
sessionOwner
|
||||
sessionOwner,
|
||||
jdbcServices
|
||||
);
|
||||
|
||||
Batch currentBatch = Mockito.mock( Batch.class );
|
||||
|
|
Loading…
Reference in New Issue