HHH-13595 Deprecate ConnectionObserver

This commit is contained in:
Sanne Grinovero 2019-08-23 15:10:02 +01:00
parent 952bf6f9c0
commit c94117cedc
3 changed files with 11 additions and 15 deletions

View File

@ -125,7 +125,7 @@ final class FastSessionServices {
private final Dialect dialect;
private final CacheStoreMode defaultCacheStoreMode;
private final CacheRetrieveMode defaultCacheRetrieveMode;
private List<ConnectionObserver> defaultJdbcObservers;
private final ConnectionObserverStatsBridge defaultJdbcObservers;
FastSessionServices(SessionFactoryImpl sf) {
Objects.requireNonNull( sf );
@ -174,7 +174,7 @@ final class FastSessionServices {
this.defaultCacheRetrieveMode = determineCacheRetrieveMode( defaultSessionProperties );
this.initialSessionCacheMode = CacheModeHelper.interpretCacheMode( defaultCacheStoreMode, defaultCacheRetrieveMode );
this.discardOnClose = sessionFactoryOptions.isReleaseResourcesOnCloseEnabled();
this.defaultJdbcObservers = Collections.singletonList( new ConnectionObserverStatsBridge( sf ) );
this.defaultJdbcObservers = new ConnectionObserverStatsBridge( sf );
this.defaultSessionEventListeners = sessionFactoryOptions.getBaselineSessionEventsListenerBuilder();
this.defaultLockOptions = initializeDefaultLockOptions( defaultSessionProperties );
}
@ -273,7 +273,7 @@ final class FastSessionServices {
return ( CacheStoreMode ) settings.get( JPA_SHARED_CACHE_STORE_MODE );
}
public Iterable<ConnectionObserver> getDefaultJdbcObservers() {
public ConnectionObserverStatsBridge getDefaultJdbcObserver() {
return defaultJdbcObservers;
}

View File

@ -8,7 +8,6 @@ package org.hibernate.internal;
import java.sql.Connection;
import org.hibernate.engine.jdbc.spi.ConnectionObserver;
import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.resource.jdbc.spi.JdbcObserver;
@ -18,11 +17,11 @@ import org.hibernate.resource.jdbc.spi.JdbcObserver;
public class JdbcObserverImpl implements JdbcObserver {
private final SharedSessionContractImplementor session;
private final Iterable<ConnectionObserver> observers;
private final ConnectionObserverStatsBridge observer;
public JdbcObserverImpl(SharedSessionContractImplementor session, FastSessionServices fastSessionServices) {
this.session = session;
this.observers = fastSessionServices.getDefaultJdbcObservers();
this.observer = fastSessionServices.getDefaultJdbcObserver();
}
@Override
@ -32,10 +31,8 @@ public class JdbcObserverImpl implements JdbcObserver {
@Override
public void jdbcConnectionAcquisitionEnd(Connection connection) {
for ( ConnectionObserver observer : observers ) {
observer.physicalConnectionObtained( connection );
}
}
@Override
public void jdbcConnectionReleaseStart() {
@ -44,10 +41,8 @@ public class JdbcObserverImpl implements JdbcObserver {
@Override
public void jdbcConnectionReleaseEnd() {
for ( ConnectionObserver observer : observers ) {
observer.physicalConnectionReleased();
}
}
@Override
public void jdbcPrepareStatementStart() {
@ -56,9 +51,7 @@ public class JdbcObserverImpl implements JdbcObserver {
@Override
public void jdbcPrepareStatementEnd() {
for ( ConnectionObserver observer : observers ) {
observer.statementPrepared();
}
session.getEventListenerManager().jdbcPrepareStatementEnd();
}

View File

@ -9,8 +9,11 @@ package org.hibernate.resource.jdbc.spi;
import java.sql.Connection;
/**
* @deprecated It is no longer possible to plug custom implementations of
* this SPI. It will be removed.
* @author Steve Ebersole
*/
@Deprecated
public interface JdbcObserver {
public void jdbcConnectionAcquisitionStart();
public void jdbcConnectionAcquisitionEnd(Connection connection);