HHH-8654 - Ability to get notified of interesting Session events

This commit is contained in:
Steve Ebersole 2013-11-15 12:01:14 -06:00
parent 9e58a6de69
commit 1e74abf511
32 changed files with 149 additions and 155 deletions

View File

@ -24,13 +24,13 @@
package org.hibernate; package org.hibernate;
/** /**
* A no-op implementation of SessionEventsListener. Intended as a convenient base class for developing * A no-op implementation of SessionEventListener. Intended as a convenient base class for developing
* SessionEventsListener implementations. * SessionEventListener implementations.
* *
* @author Steve Ebersole * @author Steve Ebersole
*/ */
@SuppressWarnings("UnusedDeclaration") @SuppressWarnings("UnusedDeclaration")
public class EmptySessionEventsListener implements SessionEventsListener { public class BaseSessionEventListener implements SessionEventListener {
@Override @Override
public void transactionCompletion(boolean successful) { public void transactionCompletion(boolean successful) {
} }

View File

@ -1104,5 +1104,5 @@ public interface Session extends SharedSessionContract {
* *
* @param listeners The listener(s) to add * @param listeners The listener(s) to add
*/ */
public void addEventsListeners(SessionEventsListener... listeners); public void addEventListeners(SessionEventListener... listeners);
} }

View File

@ -119,13 +119,13 @@ public interface SessionBuilder {
public SessionBuilder tenantIdentifier(String tenantIdentifier); public SessionBuilder tenantIdentifier(String tenantIdentifier);
/** /**
* Apply one or more SessionEventsListener instances to the listeners for the Session to be built. * Apply one or more SessionEventListener instances to the listeners for the Session to be built.
* *
* @param listeners The listeners to incorporate into the built Session * @param listeners The listeners to incorporate into the built Session
* *
* @return {@code this}, for method chaining * @return {@code this}, for method chaining
*/ */
public SessionBuilder eventListeners(SessionEventsListener... listeners); public SessionBuilder eventListeners(SessionEventListener... listeners);
/** /**
* Remove all listeners intended for the built Session currently held here, including any auto-apply ones; in other * Remove all listeners intended for the built Session currently held here, including any auto-apply ones; in other

View File

@ -30,7 +30,7 @@ import java.io.Serializable;
* *
* @author Steve Ebersole * @author Steve Ebersole
*/ */
public interface SessionEventsListener extends Serializable { public interface SessionEventListener extends Serializable {
public void transactionCompletion(boolean successful); public void transactionCompletion(boolean successful);
public void jdbcConnectionAcquisitionStart(); public void jdbcConnectionAcquisitionStart();

View File

@ -152,11 +152,11 @@ public final class EntityInsertAction extends AbstractEntityInsertAction {
private boolean cacheInsert(EntityPersister persister, CacheKey ck) { private boolean cacheInsert(EntityPersister persister, CacheKey ck) {
try { try {
getSession().getSessionEventsManager().cachePutStart(); getSession().getEventListenerManager().cachePutStart();
return persister.getCacheAccessStrategy().insert( ck, cacheEntry, version ); return persister.getCacheAccessStrategy().insert( ck, cacheEntry, version );
} }
finally { finally {
getSession().getSessionEventsManager().cachePutEnd(); getSession().getEventListenerManager().cachePutEnd();
} }
} }
@ -214,7 +214,7 @@ public final class EntityInsertAction extends AbstractEntityInsertAction {
if ( success && isCachePutEnabled( persister, getSession() ) ) { if ( success && isCachePutEnabled( persister, getSession() ) ) {
final CacheKey ck = getSession().generateCacheKey( getId(), persister.getIdentifierType(), persister.getRootEntityName() ); final CacheKey ck = getSession().generateCacheKey( getId(), persister.getIdentifierType(), persister.getRootEntityName() );
try { try {
getSession().getSessionEventsManager().cachePutStart(); getSession().getEventListenerManager().cachePutStart();
final boolean put = persister.getCacheAccessStrategy().afterInsert( ck, cacheEntry, version ); final boolean put = persister.getCacheAccessStrategy().afterInsert( ck, cacheEntry, version );
if ( put && getSession().getFactory().getStatistics().isStatisticsEnabled() ) { if ( put && getSession().getFactory().getStatistics().isStatisticsEnabled() ) {
@ -223,7 +223,7 @@ public final class EntityInsertAction extends AbstractEntityInsertAction {
} }
} }
finally { finally {
getSession().getSessionEventsManager().cachePutEnd(); getSession().getEventListenerManager().cachePutEnd();
} }
} }
postCommitInsert(); postCommitInsert();

View File

@ -316,7 +316,7 @@ public final class EntityUpdateAction extends EntityAction {
if ( success && cacheEntry!=null /*!persister.isCacheInvalidationRequired()*/ ) { if ( success && cacheEntry!=null /*!persister.isCacheInvalidationRequired()*/ ) {
try { try {
session.getSessionEventsManager().cachePutStart(); session.getEventListenerManager().cachePutStart();
final boolean put = persister.getCacheAccessStrategy().afterUpdate( ck, cacheEntry, nextVersion, previousVersion, lock ); final boolean put = persister.getCacheAccessStrategy().afterUpdate( ck, cacheEntry, nextVersion, previousVersion, lock );
if ( put && getSession().getFactory().getStatistics().isStatisticsEnabled() ) { if ( put && getSession().getFactory().getStatistics().isStatisticsEnabled() ) {
@ -324,7 +324,7 @@ public final class EntityUpdateAction extends EntityAction {
} }
} }
finally { finally {
session.getSessionEventsManager().cachePutEnd(); session.getEventListenerManager().cachePutEnd();
} }
} }
else { else {

View File

@ -144,11 +144,11 @@ public class StandardQueryCache implements QueryCache {
} }
try { try {
session.getSessionEventsManager().cachePutStart(); session.getEventListenerManager().cachePutStart();
cacheRegion.put( key, cacheable ); cacheRegion.put( key, cacheable );
} }
finally { finally {
session.getSessionEventsManager().cachePutEnd(); session.getEventListenerManager().cachePutEnd();
} }
return true; return true;
@ -233,11 +233,11 @@ public class StandardQueryCache implements QueryCache {
private List getCachedResults(QueryKey key, SessionImplementor session) { private List getCachedResults(QueryKey key, SessionImplementor session) {
List cacheable = null; List cacheable = null;
try { try {
session.getSessionEventsManager().cacheGetStart(); session.getEventListenerManager().cacheGetStart();
cacheable = (List) cacheRegion.get( key ); cacheable = (List) cacheRegion.get( key );
} }
finally { finally {
session.getSessionEventsManager().cacheGetEnd( cacheable != null ); session.getEventListenerManager().cacheGetEnd( cacheable != null );
} }
return cacheable; return cacheable;
} }

View File

@ -104,14 +104,14 @@ public class UpdateTimestampsCache {
} }
try { try {
session.getSessionEventsManager().cachePutStart(); session.getEventListenerManager().cachePutStart();
//put() has nowait semantics, is this really appropriate? //put() has nowait semantics, is this really appropriate?
//note that it needs to be async replication, never local or sync //note that it needs to be async replication, never local or sync
region.put( space, ts ); region.put( space, ts );
} }
finally { finally {
session.getSessionEventsManager().cachePutEnd(); session.getEventListenerManager().cachePutEnd();
} }
if ( stats ) { if ( stats ) {
@ -140,14 +140,14 @@ public class UpdateTimestampsCache {
} }
try { try {
session.getSessionEventsManager().cachePutStart(); session.getEventListenerManager().cachePutStart();
//put() has nowait semantics, is this really appropriate? //put() has nowait semantics, is this really appropriate?
//note that it needs to be async replication, never local or sync //note that it needs to be async replication, never local or sync
region.put( space, ts ); region.put( space, ts );
} }
finally { finally {
session.getSessionEventsManager().cachePutEnd(); session.getEventListenerManager().cachePutEnd();
} }
if ( stats ) { if ( stats ) {
@ -204,11 +204,11 @@ public class UpdateTimestampsCache {
private Long getLastUpdateTimestampForSpace(Serializable space, SessionImplementor session) { private Long getLastUpdateTimestampForSpace(Serializable space, SessionImplementor session) {
Long ts = null; Long ts = null;
try { try {
session.getSessionEventsManager().cacheGetStart(); session.getEventListenerManager().cacheGetStart();
ts = (Long) region.get( space ); ts = (Long) region.get( space );
} }
finally { finally {
session.getSessionEventsManager().cacheGetEnd( ts != null ); session.getEventListenerManager().cacheGetEnd( ts != null );
} }
return ts; return ts;
} }

View File

@ -670,7 +670,7 @@ public interface AvailableSettings {
String UNIQUE_CONSTRAINT_SCHEMA_UPDATE_STRATEGY = "hibernate.schema_update.unique_constraint_strategy"; String UNIQUE_CONSTRAINT_SCHEMA_UPDATE_STRATEGY = "hibernate.schema_update.unique_constraint_strategy";
/** /**
* A setting to control whether to {@link org.hibernate.engine.internal.LoggingSessionEventsListener} is * A setting to control whether to {@link org.hibernate.engine.internal.StatisticalLoggingSessionEventListener} is
* enabled on all Sessions (unless explicitly disabled for a given Session). The default value of this * enabled on all Sessions (unless explicitly disabled for a given Session). The default value of this
* setting is determined by the value for {@link #GENERATE_STATISTICS}, meaning that if collection of statistics * setting is determined by the value for {@link #GENERATE_STATISTICS}, meaning that if collection of statistics
* is enabled logging of Session metrics is enabled by default too. * is enabled logging of Session metrics is enabled by default too.

View File

@ -27,19 +27,19 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.hibernate.HibernateException; import org.hibernate.HibernateException;
import org.hibernate.SessionEventsListener; import org.hibernate.SessionEventListener;
import org.hibernate.engine.internal.LoggingSessionEventsListener; import org.hibernate.engine.internal.StatisticalLoggingSessionEventListener;
/** /**
* @author Steve Ebersole * @author Steve Ebersole
*/ */
public class BaselineSessionEventsListenerBuilder { public class BaselineSessionEventsListenerBuilder {
private boolean logSessionMetrics; private boolean logSessionMetrics;
private Class<? extends SessionEventsListener> autoListener; private Class<? extends SessionEventListener> autoListener;
public BaselineSessionEventsListenerBuilder( public BaselineSessionEventsListenerBuilder(
boolean logSessionMetrics, boolean logSessionMetrics,
Class<? extends SessionEventsListener> autoListener) { Class<? extends SessionEventListener> autoListener) {
this.logSessionMetrics = logSessionMetrics; this.logSessionMetrics = logSessionMetrics;
this.autoListener = autoListener; this.autoListener = autoListener;
} }
@ -55,19 +55,19 @@ public class BaselineSessionEventsListenerBuilder {
} }
@SuppressWarnings("UnusedDeclaration") @SuppressWarnings("UnusedDeclaration")
public Class<? extends SessionEventsListener> getAutoListener() { public Class<? extends SessionEventListener> getAutoListener() {
return autoListener; return autoListener;
} }
@SuppressWarnings("UnusedDeclaration") @SuppressWarnings("UnusedDeclaration")
public void setAutoListener(Class<? extends SessionEventsListener> autoListener) { public void setAutoListener(Class<? extends SessionEventListener> autoListener) {
this.autoListener = autoListener; this.autoListener = autoListener;
} }
public List<SessionEventsListener> buildBaselineList() { public List<SessionEventListener> buildBaselineList() {
List<SessionEventsListener> list = new ArrayList<SessionEventsListener>(); List<SessionEventListener> list = new ArrayList<SessionEventListener>();
if ( logSessionMetrics && LoggingSessionEventsListener.isLoggingEnabled() ) { if ( logSessionMetrics && StatisticalLoggingSessionEventListener.isLoggingEnabled() ) {
list.add( new LoggingSessionEventsListener() ); list.add( new StatisticalLoggingSessionEventListener() );
} }
if ( autoListener != null ) { if ( autoListener != null ) {
try { try {
@ -75,7 +75,7 @@ public class BaselineSessionEventsListenerBuilder {
} }
catch (Exception e) { catch (Exception e) {
throw new HibernateException( throw new HibernateException(
"Unable to instantiate specified auto SessionEventsListener : " + autoListener.getName(), "Unable to instantiate specified auto SessionEventListener : " + autoListener.getName(),
e e
); );
} }

View File

@ -34,14 +34,13 @@ import org.hibernate.EntityMode;
import org.hibernate.HibernateException; import org.hibernate.HibernateException;
import org.hibernate.MultiTenancyStrategy; import org.hibernate.MultiTenancyStrategy;
import org.hibernate.NullPrecedence; import org.hibernate.NullPrecedence;
import org.hibernate.SessionEventsListener; import org.hibernate.SessionEventListener;
import org.hibernate.boot.registry.selector.spi.StrategySelector; import org.hibernate.boot.registry.selector.spi.StrategySelector;
import org.hibernate.cache.internal.NoCachingRegionFactory; import org.hibernate.cache.internal.NoCachingRegionFactory;
import org.hibernate.cache.internal.RegionFactoryInitiator; import org.hibernate.cache.internal.RegionFactoryInitiator;
import org.hibernate.cache.internal.StandardQueryCacheFactory; import org.hibernate.cache.internal.StandardQueryCacheFactory;
import org.hibernate.cache.spi.QueryCacheFactory; import org.hibernate.cache.spi.QueryCacheFactory;
import org.hibernate.cache.spi.RegionFactory; import org.hibernate.cache.spi.RegionFactory;
import org.hibernate.engine.internal.LoggingSessionEventsListener;
import org.hibernate.engine.jdbc.spi.ExtractedDatabaseMetaData; import org.hibernate.engine.jdbc.spi.ExtractedDatabaseMetaData;
import org.hibernate.engine.jdbc.spi.JdbcServices; import org.hibernate.engine.jdbc.spi.JdbcServices;
import org.hibernate.engine.transaction.spi.TransactionFactory; import org.hibernate.engine.transaction.spi.TransactionFactory;
@ -416,9 +415,9 @@ public class SettingsFactory implements Serializable {
settings.setJtaTrackByThread( jtaTrackByThread ); settings.setJtaTrackByThread( jtaTrackByThread );
final String autoSessionEventsListenerName = properties.getProperty( AvailableSettings.AUTO_SESSION_EVENTS_LISTENER ); final String autoSessionEventsListenerName = properties.getProperty( AvailableSettings.AUTO_SESSION_EVENTS_LISTENER );
final Class<? extends SessionEventsListener> autoSessionEventsListener = autoSessionEventsListenerName == null final Class<? extends SessionEventListener> autoSessionEventsListener = autoSessionEventsListenerName == null
? null ? null
: strategySelector.selectStrategyImplementor( SessionEventsListener.class, autoSessionEventsListenerName ); : strategySelector.selectStrategyImplementor( SessionEventListener.class, autoSessionEventsListenerName );
final boolean logSessionMetrics = ConfigurationHelper.getBoolean( final boolean logSessionMetrics = ConfigurationHelper.getBoolean(
AvailableSettings.LOG_SESSION_METRICS, AvailableSettings.LOG_SESSION_METRICS,

View File

@ -27,18 +27,18 @@ import java.io.Serializable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.hibernate.SessionEventsListener; import org.hibernate.SessionEventListener;
import org.hibernate.engine.spi.SessionEventsManager; import org.hibernate.engine.spi.SessionEventListenerManager;
/** /**
* @author Steve Ebersole * @author Steve Ebersole
*/ */
public class SessionEventsManagerImpl implements SessionEventsManager, Serializable { public class SessionEventListenerManagerImpl implements SessionEventListenerManager, Serializable {
private List<SessionEventsListener> listenerList; private List<SessionEventListener> listenerList;
public void addListener(SessionEventsListener... listeners) { public void addListener(SessionEventListener... listeners) {
if ( listenerList == null ) { if ( listenerList == null ) {
listenerList = new ArrayList<SessionEventsListener>(); listenerList = new ArrayList<SessionEventListener>();
} }
java.util.Collections.addAll( listenerList, listeners ); java.util.Collections.addAll( listenerList, listeners );
@ -50,7 +50,7 @@ public class SessionEventsManagerImpl implements SessionEventsManager, Serializa
return; return;
} }
for ( SessionEventsListener listener : listenerList ) { for ( SessionEventListener listener : listenerList ) {
listener.transactionCompletion( successful ); listener.transactionCompletion( successful );
} }
} }
@ -61,7 +61,7 @@ public class SessionEventsManagerImpl implements SessionEventsManager, Serializa
return; return;
} }
for ( SessionEventsListener listener : listenerList ) { for ( SessionEventListener listener : listenerList ) {
listener.jdbcConnectionAcquisitionStart(); listener.jdbcConnectionAcquisitionStart();
} }
} }
@ -72,7 +72,7 @@ public class SessionEventsManagerImpl implements SessionEventsManager, Serializa
return; return;
} }
for ( SessionEventsListener listener : listenerList ) { for ( SessionEventListener listener : listenerList ) {
listener.jdbcConnectionAcquisitionEnd(); listener.jdbcConnectionAcquisitionEnd();
} }
} }
@ -83,7 +83,7 @@ public class SessionEventsManagerImpl implements SessionEventsManager, Serializa
return; return;
} }
for ( SessionEventsListener listener : listenerList ) { for ( SessionEventListener listener : listenerList ) {
listener.jdbcConnectionReleaseStart(); listener.jdbcConnectionReleaseStart();
} }
} }
@ -94,7 +94,7 @@ public class SessionEventsManagerImpl implements SessionEventsManager, Serializa
return; return;
} }
for ( SessionEventsListener listener : listenerList ) { for ( SessionEventListener listener : listenerList ) {
listener.jdbcConnectionReleaseEnd(); listener.jdbcConnectionReleaseEnd();
} }
} }
@ -105,7 +105,7 @@ public class SessionEventsManagerImpl implements SessionEventsManager, Serializa
return; return;
} }
for ( SessionEventsListener listener : listenerList ) { for ( SessionEventListener listener : listenerList ) {
listener.jdbcPrepareStatementStart(); listener.jdbcPrepareStatementStart();
} }
} }
@ -116,7 +116,7 @@ public class SessionEventsManagerImpl implements SessionEventsManager, Serializa
return; return;
} }
for ( SessionEventsListener listener : listenerList ) { for ( SessionEventListener listener : listenerList ) {
listener.jdbcPrepareStatementEnd(); listener.jdbcPrepareStatementEnd();
} }
} }
@ -127,7 +127,7 @@ public class SessionEventsManagerImpl implements SessionEventsManager, Serializa
return; return;
} }
for ( SessionEventsListener listener : listenerList ) { for ( SessionEventListener listener : listenerList ) {
listener.jdbcExecuteStatementStart(); listener.jdbcExecuteStatementStart();
} }
} }
@ -138,7 +138,7 @@ public class SessionEventsManagerImpl implements SessionEventsManager, Serializa
return; return;
} }
for ( SessionEventsListener listener : listenerList ) { for ( SessionEventListener listener : listenerList ) {
listener.jdbcExecuteStatementEnd(); listener.jdbcExecuteStatementEnd();
} }
} }
@ -149,7 +149,7 @@ public class SessionEventsManagerImpl implements SessionEventsManager, Serializa
return; return;
} }
for ( SessionEventsListener listener : listenerList ) { for ( SessionEventListener listener : listenerList ) {
listener.jdbcExecuteBatchStart(); listener.jdbcExecuteBatchStart();
} }
} }
@ -160,7 +160,7 @@ public class SessionEventsManagerImpl implements SessionEventsManager, Serializa
return; return;
} }
for ( SessionEventsListener listener : listenerList ) { for ( SessionEventListener listener : listenerList ) {
listener.jdbcExecuteBatchEnd(); listener.jdbcExecuteBatchEnd();
} }
} }
@ -171,7 +171,7 @@ public class SessionEventsManagerImpl implements SessionEventsManager, Serializa
return; return;
} }
for ( SessionEventsListener listener : listenerList ) { for ( SessionEventListener listener : listenerList ) {
listener.cachePutStart(); listener.cachePutStart();
} }
} }
@ -182,7 +182,7 @@ public class SessionEventsManagerImpl implements SessionEventsManager, Serializa
return; return;
} }
for ( SessionEventsListener listener : listenerList ) { for ( SessionEventListener listener : listenerList ) {
listener.cachePutEnd(); listener.cachePutEnd();
} }
} }
@ -193,7 +193,7 @@ public class SessionEventsManagerImpl implements SessionEventsManager, Serializa
return; return;
} }
for ( SessionEventsListener listener : listenerList ) { for ( SessionEventListener listener : listenerList ) {
listener.cacheGetStart(); listener.cacheGetStart();
} }
} }
@ -204,7 +204,7 @@ public class SessionEventsManagerImpl implements SessionEventsManager, Serializa
return; return;
} }
for ( SessionEventsListener listener : listenerList ) { for ( SessionEventListener listener : listenerList ) {
listener.cacheGetEnd( hit ); listener.cacheGetEnd( hit );
} }
} }
@ -215,7 +215,7 @@ public class SessionEventsManagerImpl implements SessionEventsManager, Serializa
return; return;
} }
for ( SessionEventsListener listener : listenerList ) { for ( SessionEventListener listener : listenerList ) {
listener.flushStart(); listener.flushStart();
} }
} }
@ -226,7 +226,7 @@ public class SessionEventsManagerImpl implements SessionEventsManager, Serializa
return; return;
} }
for ( SessionEventsListener listener : listenerList ) { for ( SessionEventListener listener : listenerList ) {
listener.flushEnd( numberOfEntities, numberOfCollections ); listener.flushEnd( numberOfEntities, numberOfCollections );
} }
} }
@ -237,7 +237,7 @@ public class SessionEventsManagerImpl implements SessionEventsManager, Serializa
return; return;
} }
for ( SessionEventsListener listener : listenerList ) { for ( SessionEventListener listener : listenerList ) {
listener.partialFlushStart(); listener.partialFlushStart();
} }
} }
@ -248,7 +248,7 @@ public class SessionEventsManagerImpl implements SessionEventsManager, Serializa
return; return;
} }
for ( SessionEventsListener listener : listenerList ) { for ( SessionEventListener listener : listenerList ) {
listener.partialFlushEnd( numberOfEntities, numberOfCollections ); listener.partialFlushEnd( numberOfEntities, numberOfCollections );
} }
} }
@ -259,7 +259,7 @@ public class SessionEventsManagerImpl implements SessionEventsManager, Serializa
return; return;
} }
for ( SessionEventsListener listener : listenerList ) { for ( SessionEventListener listener : listenerList ) {
listener.dirtyCalculationStart(); listener.dirtyCalculationStart();
} }
} }
@ -270,7 +270,7 @@ public class SessionEventsManagerImpl implements SessionEventsManager, Serializa
return; return;
} }
for ( SessionEventsListener listener : listenerList ) { for ( SessionEventListener listener : listenerList ) {
listener.dirtyCalculationEnd( dirty ); listener.dirtyCalculationEnd( dirty );
} }
} }
@ -281,7 +281,7 @@ public class SessionEventsManagerImpl implements SessionEventsManager, Serializa
return; return;
} }
for ( SessionEventsListener listener : listenerList ) { for ( SessionEventListener listener : listenerList ) {
listener.end(); listener.end();
} }
} }

View File

@ -25,13 +25,13 @@ package org.hibernate.engine.internal;
import org.jboss.logging.Logger; import org.jboss.logging.Logger;
import org.hibernate.EmptySessionEventsListener; import org.hibernate.BaseSessionEventListener;
/** /**
* @author Steve Ebersole * @author Steve Ebersole
*/ */
public class LoggingSessionEventsListener extends EmptySessionEventsListener { public class StatisticalLoggingSessionEventListener extends BaseSessionEventListener {
private static final Logger log = Logger.getLogger( LoggingSessionEventsListener.class ); private static final Logger log = Logger.getLogger( StatisticalLoggingSessionEventListener.class );
/** /**
* Used by SettingsFactory (in conjunction with stats being enabled) to determine whether to apply this listener * Used by SettingsFactory (in conjunction with stats being enabled) to determine whether to apply this listener

View File

@ -217,7 +217,7 @@ public final class TwoPhaseLoad {
} }
else { else {
try { try {
session.getSessionEventsManager().cachePutStart(); session.getEventListenerManager().cachePutStart();
final boolean put = persister.getCacheAccessStrategy().putFromLoad( final boolean put = persister.getCacheAccessStrategy().putFromLoad(
cacheKey, cacheKey,
persister.getCacheEntryStructure().structure( entry ), persister.getCacheEntryStructure().structure( entry ),
@ -231,7 +231,7 @@ public final class TwoPhaseLoad {
} }
} }
finally { finally {
session.getSessionEventsManager().cachePutEnd(); session.getEventListenerManager().cachePutEnd();
} }
} }
} }

View File

@ -350,7 +350,7 @@ public class CollectionLoadContext {
final CacheKey cacheKey = session.generateCacheKey( lce.getKey(), persister.getKeyType(), persister.getRole() ); final CacheKey cacheKey = session.generateCacheKey( lce.getKey(), persister.getKeyType(), persister.getRole() );
try { try {
session.getSessionEventsManager().cachePutStart(); session.getEventListenerManager().cachePutStart();
final boolean put = persister.getCacheAccessStrategy().putFromLoad( final boolean put = persister.getCacheAccessStrategy().putFromLoad(
cacheKey, cacheKey,
persister.getCacheEntryStructure().structure( entry ), persister.getCacheEntryStructure().structure( entry ),
@ -364,7 +364,7 @@ public class CollectionLoadContext {
} }
} }
finally { finally {
session.getSessionEventsManager().cachePutEnd(); session.getEventListenerManager().cachePutEnd();
} }
} }

View File

@ -46,7 +46,7 @@ import org.hibernate.SQLQuery;
import org.hibernate.ScrollMode; import org.hibernate.ScrollMode;
import org.hibernate.ScrollableResults; import org.hibernate.ScrollableResults;
import org.hibernate.Session; import org.hibernate.Session;
import org.hibernate.SessionEventsListener; import org.hibernate.SessionEventListener;
import org.hibernate.SessionFactory; import org.hibernate.SessionFactory;
import org.hibernate.SharedSessionBuilder; import org.hibernate.SharedSessionBuilder;
import org.hibernate.SimpleNaturalIdLoadAccess; import org.hibernate.SimpleNaturalIdLoadAccess;
@ -390,8 +390,8 @@ public class SessionDelegatorBaseImpl implements SessionImplementor, Session {
} }
@Override @Override
public SessionEventsManager getSessionEventsManager() { public SessionEventListenerManager getEventListenerManager() {
return sessionImplementor.getSessionEventsManager(); return sessionImplementor.getEventListenerManager();
} }
// Delegates to Session // Delegates to Session
@ -807,7 +807,7 @@ public class SessionDelegatorBaseImpl implements SessionImplementor, Session {
} }
@Override @Override
public void addEventsListeners(SessionEventsListener... listeners) { public void addEventListeners(SessionEventListener... listeners) {
session.addEventsListeners( listeners ); session.addEventListeners( listeners );
} }
} }

View File

@ -23,10 +23,10 @@
*/ */
package org.hibernate.engine.spi; package org.hibernate.engine.spi;
import org.hibernate.SessionEventsListener; import org.hibernate.SessionEventListener;
/** /**
* @author Steve Ebersole * @author Steve Ebersole
*/ */
public interface SessionEventsManager extends SessionEventsListener { public interface SessionEventListenerManager extends SessionEventListener {
} }

View File

@ -408,5 +408,5 @@ public interface SessionImplementor extends Serializable, LobCreationContext {
*/ */
SQLQuery createSQLQuery(NamedSQLQueryDefinition namedQueryDefinition); SQLQuery createSQLQuery(NamedSQLQueryDefinition namedQueryDefinition);
public SessionEventsManager getSessionEventsManager(); public SessionEventListenerManager getEventListenerManager();
} }

View File

@ -52,7 +52,7 @@ public class DefaultAutoFlushEventListener extends AbstractFlushingEventListener
public void onAutoFlush(AutoFlushEvent event) throws HibernateException { public void onAutoFlush(AutoFlushEvent event) throws HibernateException {
final EventSource source = event.getSession(); final EventSource source = event.getSession();
try { try {
source.getSessionEventsManager().partialFlushStart(); source.getEventListenerManager().partialFlushStart();
if ( flushMightBeNeeded(source) ) { if ( flushMightBeNeeded(source) ) {
// Need to get the number of collection removals before flushing to executions // Need to get the number of collection removals before flushing to executions
@ -82,7 +82,7 @@ public class DefaultAutoFlushEventListener extends AbstractFlushingEventListener
} }
} }
finally { finally {
source.getSessionEventsManager().partialFlushEnd( source.getEventListenerManager().partialFlushEnd(
event.getNumberOfEntitiesProcessed(), event.getNumberOfEntitiesProcessed(),
event.getNumberOfEntitiesProcessed() event.getNumberOfEntitiesProcessed()
); );

View File

@ -527,7 +527,7 @@ public class DefaultFlushEntityEventListener implements FlushEntityEventListener
if ( dirtyProperties==null ) { if ( dirtyProperties==null ) {
// Interceptor returned null, so do the dirtycheck ourself, if possible // Interceptor returned null, so do the dirtycheck ourself, if possible
try { try {
session.getSessionEventsManager().dirtyCalculationStart(); session.getEventListenerManager().dirtyCalculationStart();
interceptorHandledDirtyCheck = false; interceptorHandledDirtyCheck = false;
// object loaded by update() // object loaded by update()
@ -567,7 +567,7 @@ public class DefaultFlushEntityEventListener implements FlushEntityEventListener
} }
} }
finally { finally {
session.getSessionEventsManager().dirtyCalculationEnd( dirtyProperties != null ); session.getEventListenerManager().dirtyCalculationEnd( dirtyProperties != null );
} }
} }
else { else {

View File

@ -50,14 +50,14 @@ public class DefaultFlushEventListener extends AbstractFlushingEventListener imp
persistenceContext.getCollectionEntries().size() > 0 ) { persistenceContext.getCollectionEntries().size() > 0 ) {
try { try {
source.getSessionEventsManager().flushStart(); source.getEventListenerManager().flushStart();
flushEverythingToExecutions( event ); flushEverythingToExecutions( event );
performExecutions( source ); performExecutions( source );
postFlush( source ); postFlush( source );
} }
finally { finally {
source.getSessionEventsManager().flushEnd( source.getEventListenerManager().flushEnd(
event.getNumberOfEntitiesProcessed(), event.getNumberOfEntitiesProcessed(),
event.getNumberOfCollectionsProcessed() event.getNumberOfCollectionsProcessed()
); );

View File

@ -128,7 +128,7 @@ public class DefaultInitializeCollectionEventListener implements InitializeColle
Object ce = null; Object ce = null;
try { try {
source.getSessionEventsManager().cacheGetStart(); source.getEventListenerManager().cacheGetStart();
ce = persister.getCacheAccessStrategy().get(ck, source.getTimestamp()); ce = persister.getCacheAccessStrategy().get(ck, source.getTimestamp());
if ( factory.getStatistics().isStatisticsEnabled() ) { if ( factory.getStatistics().isStatisticsEnabled() ) {
@ -143,7 +143,7 @@ public class DefaultInitializeCollectionEventListener implements InitializeColle
} }
} }
finally { finally {
source.getSessionEventsManager().cacheGetEnd( ce == null ); source.getEventListenerManager().cacheGetEnd( ce == null );
} }
if ( ce == null ) { if ( ce == null ) {

View File

@ -549,7 +549,7 @@ public class DefaultLoadEventListener extends AbstractLockUpgradeEventListener i
Object ce = null; Object ce = null;
try { try {
source.getSessionEventsManager().cacheGetStart(); source.getEventListenerManager().cacheGetStart();
ce = persister.getCacheAccessStrategy().get( ck, source.getTimestamp() ); ce = persister.getCacheAccessStrategy().get( ck, source.getTimestamp() );
if ( factory.getStatistics().isStatisticsEnabled() ) { if ( factory.getStatistics().isStatisticsEnabled() ) {
@ -566,7 +566,7 @@ public class DefaultLoadEventListener extends AbstractLockUpgradeEventListener i
} }
} }
finally { finally {
source.getSessionEventsManager().cacheGetEnd( ce == null ); source.getEventListenerManager().cacheGetEnd( ce == null );
} }
if ( ce == null ) { if ( ce == null ) {

View File

@ -41,7 +41,7 @@ import org.hibernate.dialect.Dialect;
import org.hibernate.engine.jdbc.internal.FormatStyle; import org.hibernate.engine.jdbc.internal.FormatStyle;
import org.hibernate.engine.jdbc.spi.JdbcServices; import org.hibernate.engine.jdbc.spi.JdbcServices;
import org.hibernate.engine.jdbc.spi.SqlStatementLogger; import org.hibernate.engine.jdbc.spi.SqlStatementLogger;
import org.hibernate.engine.spi.SessionEventsManager; import org.hibernate.engine.spi.SessionEventListenerManager;
import org.hibernate.engine.spi.SessionImplementor; import org.hibernate.engine.spi.SessionImplementor;
import org.hibernate.id.enhanced.AccessCallback; import org.hibernate.id.enhanced.AccessCallback;
import org.hibernate.id.enhanced.LegacyHiLoAlgorithmOptimizer; import org.hibernate.id.enhanced.LegacyHiLoAlgorithmOptimizer;
@ -146,7 +146,7 @@ public class MultipleHiLoPerTableGenerator implements PersistentIdentifierGenera
final SqlStatementLogger statementLogger = session.getFactory().getServiceRegistry() final SqlStatementLogger statementLogger = session.getFactory().getServiceRegistry()
.getService( JdbcServices.class ) .getService( JdbcServices.class )
.getSqlStatementLogger(); .getSqlStatementLogger();
final SessionEventsManager statsCollector = session.getSessionEventsManager(); final SessionEventListenerManager statsCollector = session.getEventListenerManager();
final WorkExecutorVisitable<IntegralDataTypeHolder> work = new AbstractReturningWork<IntegralDataTypeHolder>() { final WorkExecutorVisitable<IntegralDataTypeHolder> work = new AbstractReturningWork<IntegralDataTypeHolder>() {
@Override @Override
@ -235,7 +235,7 @@ public class MultipleHiLoPerTableGenerator implements PersistentIdentifierGenera
Connection connection, Connection connection,
String sql, String sql,
SqlStatementLogger statementLogger, SqlStatementLogger statementLogger,
SessionEventsManager statsCollector) throws SQLException { SessionEventListenerManager statsCollector) throws SQLException {
statementLogger.logStatement( sql, FormatStyle.BASIC.getFormatter() ); statementLogger.logStatement( sql, FormatStyle.BASIC.getFormatter() );
try { try {
statsCollector.jdbcPrepareStatementStart(); statsCollector.jdbcPrepareStatementStart();
@ -246,7 +246,7 @@ public class MultipleHiLoPerTableGenerator implements PersistentIdentifierGenera
} }
} }
private int executeUpdate(PreparedStatement ps, SessionEventsManager statsCollector) throws SQLException { private int executeUpdate(PreparedStatement ps, SessionEventListenerManager statsCollector) throws SQLException {
try { try {
statsCollector.jdbcExecuteStatementStart(); statsCollector.jdbcExecuteStatementStart();
return ps.executeUpdate(); return ps.executeUpdate();
@ -257,7 +257,7 @@ public class MultipleHiLoPerTableGenerator implements PersistentIdentifierGenera
} }
private ResultSet executeQuery(PreparedStatement ps, SessionEventsManager statsCollector) throws SQLException { private ResultSet executeQuery(PreparedStatement ps, SessionEventListenerManager statsCollector) throws SQLException {
try { try {
statsCollector.jdbcExecuteStatementStart(); statsCollector.jdbcExecuteStatementStart();
return ps.executeQuery(); return ps.executeQuery();

View File

@ -40,7 +40,7 @@ import org.hibernate.dialect.Dialect;
import org.hibernate.engine.jdbc.internal.FormatStyle; import org.hibernate.engine.jdbc.internal.FormatStyle;
import org.hibernate.engine.jdbc.spi.JdbcServices; import org.hibernate.engine.jdbc.spi.JdbcServices;
import org.hibernate.engine.jdbc.spi.SqlStatementLogger; import org.hibernate.engine.jdbc.spi.SqlStatementLogger;
import org.hibernate.engine.spi.SessionEventsManager; import org.hibernate.engine.spi.SessionEventListenerManager;
import org.hibernate.engine.spi.SessionImplementor; import org.hibernate.engine.spi.SessionImplementor;
import org.hibernate.id.enhanced.SequenceStyleGenerator; import org.hibernate.id.enhanced.SequenceStyleGenerator;
import org.hibernate.internal.CoreMessageLogger; import org.hibernate.internal.CoreMessageLogger;
@ -148,7 +148,7 @@ public class TableGenerator implements PersistentIdentifierGenerator, Configurab
final SqlStatementLogger statementLogger = session.getFactory().getServiceRegistry() final SqlStatementLogger statementLogger = session.getFactory().getServiceRegistry()
.getService( JdbcServices.class ) .getService( JdbcServices.class )
.getSqlStatementLogger(); .getSqlStatementLogger();
final SessionEventsManager statsCollector = session.getSessionEventsManager(); final SessionEventListenerManager listeners = session.getEventListenerManager();
return session.getTransactionCoordinator().getTransaction().createIsolationDelegate().delegateWork( return session.getTransactionCoordinator().getTransaction().createIsolationDelegate().delegateWork(
new AbstractReturningWork<IntegralDataTypeHolder>() { new AbstractReturningWork<IntegralDataTypeHolder>() {
@ -160,9 +160,9 @@ public class TableGenerator implements PersistentIdentifierGenerator, Configurab
// The loop ensures atomicity of the select + update even for no transaction or // The loop ensures atomicity of the select + update even for no transaction or
// read committed isolation level // read committed isolation level
do { do {
final PreparedStatement qps = prepareStatement( connection, query, statementLogger, statsCollector ); final PreparedStatement qps = prepareStatement( connection, query, statementLogger, listeners );
try { try {
ResultSet rs = executeQuery( qps, statsCollector ); ResultSet rs = executeQuery( qps, listeners );
if ( !rs.next() ) { if ( !rs.next() ) {
String err = "could not read a hi value - you need to populate the table: " + tableName; String err = "could not read a hi value - you need to populate the table: " + tableName;
LOG.error(err); LOG.error(err);
@ -179,11 +179,11 @@ public class TableGenerator implements PersistentIdentifierGenerator, Configurab
qps.close(); qps.close();
} }
final PreparedStatement ups = prepareStatement( connection, update, statementLogger, statsCollector ); final PreparedStatement ups = prepareStatement( connection, update, statementLogger, listeners );
try { try {
value.copy().increment().bind( ups, 1 ); value.copy().increment().bind( ups, 1 );
value.bind( ups, 2 ); value.bind( ups, 2 );
rows = executeUpdate( ups, statsCollector ); rows = executeUpdate( ups, listeners );
} }
catch (SQLException sqle) { catch (SQLException sqle) {
LOG.error(LOG.unableToUpdateHiValue(tableName), sqle); LOG.error(LOG.unableToUpdateHiValue(tableName), sqle);
@ -205,7 +205,7 @@ public class TableGenerator implements PersistentIdentifierGenerator, Configurab
Connection connection, Connection connection,
String sql, String sql,
SqlStatementLogger statementLogger, SqlStatementLogger statementLogger,
SessionEventsManager statsCollector) throws SQLException { SessionEventListenerManager statsCollector) throws SQLException {
statementLogger.logStatement( sql, FormatStyle.BASIC.getFormatter() ); statementLogger.logStatement( sql, FormatStyle.BASIC.getFormatter() );
try { try {
statsCollector.jdbcPrepareStatementStart(); statsCollector.jdbcPrepareStatementStart();
@ -216,7 +216,7 @@ public class TableGenerator implements PersistentIdentifierGenerator, Configurab
} }
} }
private int executeUpdate(PreparedStatement ps, SessionEventsManager statsCollector) throws SQLException { private int executeUpdate(PreparedStatement ps, SessionEventListenerManager statsCollector) throws SQLException {
try { try {
statsCollector.jdbcExecuteStatementStart(); statsCollector.jdbcExecuteStatementStart();
return ps.executeUpdate(); return ps.executeUpdate();
@ -227,7 +227,7 @@ public class TableGenerator implements PersistentIdentifierGenerator, Configurab
} }
private ResultSet executeQuery(PreparedStatement ps, SessionEventsManager statsCollector) throws SQLException { private ResultSet executeQuery(PreparedStatement ps, SessionEventListenerManager statsCollector) throws SQLException {
try { try {
statsCollector.jdbcExecuteStatementStart(); statsCollector.jdbcExecuteStatementStart();
return ps.executeQuery(); return ps.executeQuery();

View File

@ -45,7 +45,7 @@ import org.hibernate.dialect.Dialect;
import org.hibernate.engine.jdbc.internal.FormatStyle; import org.hibernate.engine.jdbc.internal.FormatStyle;
import org.hibernate.engine.jdbc.spi.JdbcServices; import org.hibernate.engine.jdbc.spi.JdbcServices;
import org.hibernate.engine.jdbc.spi.SqlStatementLogger; import org.hibernate.engine.jdbc.spi.SqlStatementLogger;
import org.hibernate.engine.spi.SessionEventsManager; import org.hibernate.engine.spi.SessionEventListenerManager;
import org.hibernate.engine.spi.SessionImplementor; import org.hibernate.engine.spi.SessionImplementor;
import org.hibernate.id.Configurable; import org.hibernate.id.Configurable;
import org.hibernate.id.IdentifierGeneratorHelper; import org.hibernate.id.IdentifierGeneratorHelper;
@ -529,7 +529,7 @@ public class TableGenerator implements PersistentIdentifierGenerator, Configurab
final SqlStatementLogger statementLogger = session.getFactory().getServiceRegistry() final SqlStatementLogger statementLogger = session.getFactory().getServiceRegistry()
.getService( JdbcServices.class ) .getService( JdbcServices.class )
.getSqlStatementLogger(); .getSqlStatementLogger();
final SessionEventsManager statsCollector = session.getSessionEventsManager(); final SessionEventListenerManager statsCollector = session.getEventListenerManager();
return optimizer.generate( return optimizer.generate(
new AccessCallback() { new AccessCallback() {
@ -619,7 +619,7 @@ public class TableGenerator implements PersistentIdentifierGenerator, Configurab
Connection connection, Connection connection,
String sql, String sql,
SqlStatementLogger statementLogger, SqlStatementLogger statementLogger,
SessionEventsManager statsCollector) throws SQLException { SessionEventListenerManager statsCollector) throws SQLException {
statementLogger.logStatement( sql, FormatStyle.BASIC.getFormatter() ); statementLogger.logStatement( sql, FormatStyle.BASIC.getFormatter() );
try { try {
statsCollector.jdbcPrepareStatementStart(); statsCollector.jdbcPrepareStatementStart();
@ -630,7 +630,7 @@ public class TableGenerator implements PersistentIdentifierGenerator, Configurab
} }
} }
private int executeUpdate(PreparedStatement ps, SessionEventsManager statsCollector) throws SQLException { private int executeUpdate(PreparedStatement ps, SessionEventListenerManager statsCollector) throws SQLException {
try { try {
statsCollector.jdbcExecuteStatementStart(); statsCollector.jdbcExecuteStatementStart();
return ps.executeUpdate(); return ps.executeUpdate();
@ -641,7 +641,7 @@ public class TableGenerator implements PersistentIdentifierGenerator, Configurab
} }
private ResultSet executeQuery(PreparedStatement ps, SessionEventsManager statsCollector) throws SQLException { private ResultSet executeQuery(PreparedStatement ps, SessionEventListenerManager statsCollector) throws SQLException {
try { try {
statsCollector.jdbcExecuteStatementStart(); statsCollector.jdbcExecuteStatementStart();
return ps.executeQuery(); return ps.executeQuery();

View File

@ -37,7 +37,7 @@ import org.hibernate.dialect.Dialect;
import org.hibernate.engine.jdbc.internal.FormatStyle; import org.hibernate.engine.jdbc.internal.FormatStyle;
import org.hibernate.engine.jdbc.spi.JdbcServices; import org.hibernate.engine.jdbc.spi.JdbcServices;
import org.hibernate.engine.jdbc.spi.SqlStatementLogger; import org.hibernate.engine.jdbc.spi.SqlStatementLogger;
import org.hibernate.engine.spi.SessionEventsManager; import org.hibernate.engine.spi.SessionEventListenerManager;
import org.hibernate.engine.spi.SessionImplementor; import org.hibernate.engine.spi.SessionImplementor;
import org.hibernate.id.IdentifierGenerationException; import org.hibernate.id.IdentifierGenerationException;
import org.hibernate.id.IdentifierGeneratorHelper; import org.hibernate.id.IdentifierGeneratorHelper;
@ -123,7 +123,7 @@ public class TableStructure implements DatabaseStructure {
final SqlStatementLogger statementLogger = session.getFactory().getServiceRegistry() final SqlStatementLogger statementLogger = session.getFactory().getServiceRegistry()
.getService( JdbcServices.class ) .getService( JdbcServices.class )
.getSqlStatementLogger(); .getSqlStatementLogger();
final SessionEventsManager statsCollector = session.getSessionEventsManager(); final SessionEventListenerManager statsCollector = session.getEventListenerManager();
return new AccessCallback() { return new AccessCallback() {
@Override @Override
@ -192,7 +192,7 @@ public class TableStructure implements DatabaseStructure {
Connection connection, Connection connection,
String sql, String sql,
SqlStatementLogger statementLogger, SqlStatementLogger statementLogger,
SessionEventsManager statsCollector) throws SQLException { SessionEventListenerManager statsCollector) throws SQLException {
statementLogger.logStatement( sql, FormatStyle.BASIC.getFormatter() ); statementLogger.logStatement( sql, FormatStyle.BASIC.getFormatter() );
try { try {
statsCollector.jdbcPrepareStatementStart(); statsCollector.jdbcPrepareStatementStart();
@ -203,7 +203,7 @@ public class TableStructure implements DatabaseStructure {
} }
} }
private int executeUpdate(PreparedStatement ps, SessionEventsManager statsCollector) throws SQLException { private int executeUpdate(PreparedStatement ps, SessionEventListenerManager statsCollector) throws SQLException {
try { try {
statsCollector.jdbcExecuteStatementStart(); statsCollector.jdbcExecuteStatementStart();
return ps.executeUpdate(); return ps.executeUpdate();
@ -214,7 +214,7 @@ public class TableStructure implements DatabaseStructure {
} }
private ResultSet executeQuery(PreparedStatement ps, SessionEventsManager statsCollector) throws SQLException { private ResultSet executeQuery(PreparedStatement ps, SessionEventListenerManager statsCollector) throws SQLException {
try { try {
statsCollector.jdbcExecuteStatementStart(); statsCollector.jdbcExecuteStatementStart();
return ps.executeQuery(); return ps.executeQuery();

View File

@ -35,10 +35,9 @@ import org.hibernate.MultiTenancyStrategy;
import org.hibernate.Query; import org.hibernate.Query;
import org.hibernate.SQLQuery; import org.hibernate.SQLQuery;
import org.hibernate.ScrollableResults; import org.hibernate.ScrollableResults;
import org.hibernate.SessionEventsListener; import org.hibernate.SessionEventListener;
import org.hibernate.SessionException; import org.hibernate.SessionException;
import org.hibernate.SharedSessionContract; import org.hibernate.SharedSessionContract;
import org.hibernate.engine.spi.SessionEventsManager;
import org.hibernate.procedure.ProcedureCall; import org.hibernate.procedure.ProcedureCall;
import org.hibernate.cache.spi.CacheKey; import org.hibernate.cache.spi.CacheKey;
import org.hibernate.engine.jdbc.LobCreationContext; import org.hibernate.engine.jdbc.LobCreationContext;
@ -340,13 +339,13 @@ public abstract class AbstractSessionImpl
if ( jdbcConnectionAccess == null ) { if ( jdbcConnectionAccess == null ) {
if ( MultiTenancyStrategy.NONE == factory.getSettings().getMultiTenancyStrategy() ) { if ( MultiTenancyStrategy.NONE == factory.getSettings().getMultiTenancyStrategy() ) {
jdbcConnectionAccess = new NonContextualJdbcConnectionAccess( jdbcConnectionAccess = new NonContextualJdbcConnectionAccess(
getSessionEventsManager(), getEventListenerManager(),
factory.getServiceRegistry().getService( ConnectionProvider.class ) factory.getServiceRegistry().getService( ConnectionProvider.class )
); );
} }
else { else {
jdbcConnectionAccess = new ContextualJdbcConnectionAccess( jdbcConnectionAccess = new ContextualJdbcConnectionAccess(
getSessionEventsManager(), getEventListenerManager(),
factory.getServiceRegistry().getService( MultiTenantConnectionProvider.class ) factory.getServiceRegistry().getService( MultiTenantConnectionProvider.class )
); );
} }
@ -364,11 +363,11 @@ public abstract class AbstractSessionImpl
} }
private static class NonContextualJdbcConnectionAccess implements JdbcConnectionAccess, Serializable { private static class NonContextualJdbcConnectionAccess implements JdbcConnectionAccess, Serializable {
private final SessionEventsListener listener; private final SessionEventListener listener;
private final ConnectionProvider connectionProvider; private final ConnectionProvider connectionProvider;
private NonContextualJdbcConnectionAccess( private NonContextualJdbcConnectionAccess(
SessionEventsListener listener, SessionEventListener listener,
ConnectionProvider connectionProvider) { ConnectionProvider connectionProvider) {
this.listener = listener; this.listener = listener;
this.connectionProvider = connectionProvider; this.connectionProvider = connectionProvider;
@ -403,11 +402,11 @@ public abstract class AbstractSessionImpl
} }
private class ContextualJdbcConnectionAccess implements JdbcConnectionAccess, Serializable { private class ContextualJdbcConnectionAccess implements JdbcConnectionAccess, Serializable {
private final SessionEventsListener listener; private final SessionEventListener listener;
private final MultiTenantConnectionProvider connectionProvider; private final MultiTenantConnectionProvider connectionProvider;
private ContextualJdbcConnectionAccess( private ContextualJdbcConnectionAccess(
SessionEventsListener listener, SessionEventListener listener,
MultiTenantConnectionProvider connectionProvider) { MultiTenantConnectionProvider connectionProvider) {
this.listener = listener; this.listener = listener;
this.connectionProvider = connectionProvider; this.connectionProvider = connectionProvider;

View File

@ -57,7 +57,7 @@ import org.hibernate.MultiTenancyStrategy;
import org.hibernate.ObjectNotFoundException; import org.hibernate.ObjectNotFoundException;
import org.hibernate.Session; import org.hibernate.Session;
import org.hibernate.SessionBuilder; import org.hibernate.SessionBuilder;
import org.hibernate.SessionEventsListener; import org.hibernate.SessionEventListener;
import org.hibernate.SessionFactory; import org.hibernate.SessionFactory;
import org.hibernate.SessionFactoryObserver; import org.hibernate.SessionFactoryObserver;
import org.hibernate.StatelessSession; import org.hibernate.StatelessSession;
@ -1553,7 +1553,7 @@ public final class SessionFactoryImpl
private boolean autoJoinTransactions = true; private boolean autoJoinTransactions = true;
private boolean flushBeforeCompletion; private boolean flushBeforeCompletion;
private String tenantIdentifier; private String tenantIdentifier;
private List<SessionEventsListener> listeners; private List<SessionEventListener> listeners;
SessionBuilderImpl(SessionFactoryImpl sessionFactory) { SessionBuilderImpl(SessionFactoryImpl sessionFactory) {
this.sessionFactory = sessionFactory; this.sessionFactory = sessionFactory;
@ -1594,8 +1594,8 @@ public final class SessionFactoryImpl
tenantIdentifier tenantIdentifier
); );
for ( SessionEventsListener listener : listeners ) { for ( SessionEventListener listener : listeners ) {
session.getSessionEventsManager().addListener( listener ); session.getEventListenerManager().addListener( listener );
} }
return session; return session;
@ -1656,7 +1656,7 @@ public final class SessionFactoryImpl
} }
@Override @Override
public SessionBuilder eventListeners(SessionEventsListener... listeners) { public SessionBuilder eventListeners(SessionEventListener... listeners) {
Collections.addAll( this.listeners, listeners ); Collections.addAll( this.listeners, listeners );
return this; return this;
} }

View File

@ -73,7 +73,7 @@ import org.hibernate.ScrollMode;
import org.hibernate.ScrollableResults; import org.hibernate.ScrollableResults;
import org.hibernate.Session; import org.hibernate.Session;
import org.hibernate.SessionBuilder; import org.hibernate.SessionBuilder;
import org.hibernate.SessionEventsListener; import org.hibernate.SessionEventListener;
import org.hibernate.SessionException; import org.hibernate.SessionException;
import org.hibernate.SharedSessionBuilder; import org.hibernate.SharedSessionBuilder;
import org.hibernate.SimpleNaturalIdLoadAccess; import org.hibernate.SimpleNaturalIdLoadAccess;
@ -84,7 +84,7 @@ import org.hibernate.UnknownProfileException;
import org.hibernate.UnresolvableObjectException; import org.hibernate.UnresolvableObjectException;
import org.hibernate.collection.spi.PersistentCollection; import org.hibernate.collection.spi.PersistentCollection;
import org.hibernate.criterion.NaturalIdentifier; import org.hibernate.criterion.NaturalIdentifier;
import org.hibernate.engine.internal.SessionEventsManagerImpl; import org.hibernate.engine.internal.SessionEventListenerManagerImpl;
import org.hibernate.engine.internal.StatefulPersistenceContext; import org.hibernate.engine.internal.StatefulPersistenceContext;
import org.hibernate.engine.jdbc.LobCreator; import org.hibernate.engine.jdbc.LobCreator;
import org.hibernate.engine.jdbc.NonContextualLobCreator; import org.hibernate.engine.jdbc.NonContextualLobCreator;
@ -213,6 +213,8 @@ public final class SessionImpl extends AbstractSessionImpl implements EventSourc
private final transient boolean isTransactionCoordinatorShared; private final transient boolean isTransactionCoordinatorShared;
private transient TransactionObserver transactionObserver; private transient TransactionObserver transactionObserver;
private SessionEventListenerManagerImpl sessionEventsManager = new SessionEventListenerManagerImpl();
/** /**
* Constructor used for openSession(...) processing, as well as construction * Constructor used for openSession(...) processing, as well as construction
* of sessions for getCurrentSession(). * of sessions for getCurrentSession().
@ -357,7 +359,7 @@ public final class SessionImpl extends AbstractSessionImpl implements EventSourc
if ( factory.getStatistics().isStatisticsEnabled() ) { if ( factory.getStatistics().isStatisticsEnabled() ) {
factory.getStatisticsImplementor().closeSession(); factory.getStatisticsImplementor().closeSession();
} }
getSessionEventsManager().end(); getEventListenerManager().end();
try { try {
if ( !isTransactionCoordinatorShared ) { if ( !isTransactionCoordinatorShared ) {
@ -635,7 +637,7 @@ public final class SessionImpl extends AbstractSessionImpl implements EventSourc
persistenceContext.afterTransactionCompletion(); persistenceContext.afterTransactionCompletion();
actionQueue.afterTransactionCompletion( successful ); actionQueue.afterTransactionCompletion( successful );
getSessionEventsManager().transactionCompletion( successful ); getEventListenerManager().transactionCompletion( successful );
try { try {
interceptor.afterTransactionCompletion( hibernateTransaction ); interceptor.afterTransactionCompletion( hibernateTransaction );
@ -659,50 +661,44 @@ public final class SessionImpl extends AbstractSessionImpl implements EventSourc
return sql; return sql;
} }
private SessionEventsManagerImpl sessionEventsManager;
@Override @Override
public SessionEventsManagerImpl getSessionEventsManager() { public SessionEventListenerManagerImpl getEventListenerManager() {
if ( sessionEventsManager == null ) {
sessionEventsManager = new SessionEventsManagerImpl();
}
return sessionEventsManager; return sessionEventsManager;
} }
@Override @Override
public void addEventsListeners(SessionEventsListener... listeners) { public void addEventListeners(SessionEventListener... listeners) {
getSessionEventsManager().addListener( listeners ); getEventListenerManager().addListener( listeners );
} }
@Override @Override
public void startPrepareStatement() { public void startPrepareStatement() {
getSessionEventsManager().jdbcPrepareStatementStart(); getEventListenerManager().jdbcPrepareStatementStart();
} }
@Override @Override
public void endPrepareStatement() { public void endPrepareStatement() {
getSessionEventsManager().jdbcPrepareStatementEnd(); getEventListenerManager().jdbcPrepareStatementEnd();
} }
@Override @Override
public void startStatementExecution() { public void startStatementExecution() {
getSessionEventsManager().jdbcExecuteStatementStart(); getEventListenerManager().jdbcExecuteStatementStart();
} }
@Override @Override
public void endStatementExecution() { public void endStatementExecution() {
getSessionEventsManager().jdbcExecuteStatementEnd(); getEventListenerManager().jdbcExecuteStatementEnd();
} }
@Override @Override
public void startBatchExecution() { public void startBatchExecution() {
getSessionEventsManager().jdbcExecuteBatchStart(); getEventListenerManager().jdbcExecuteBatchStart();
} }
@Override @Override
public void endBatchExecution() { public void endBatchExecution() {
getSessionEventsManager().jdbcExecuteBatchEnd(); getEventListenerManager().jdbcExecuteBatchEnd();
} }
/** /**
@ -2442,7 +2438,7 @@ public final class SessionImpl extends AbstractSessionImpl implements EventSourc
} }
@Override @Override
public SharedSessionBuilder eventListeners(SessionEventsListener... listeners) { public SharedSessionBuilder eventListeners(SessionEventListener... listeners) {
super.eventListeners( listeners ); super.eventListeners( listeners );
return this; return this;
} }

View File

@ -48,7 +48,7 @@ import org.hibernate.Transaction;
import org.hibernate.UnresolvableObjectException; import org.hibernate.UnresolvableObjectException;
import org.hibernate.cache.spi.CacheKey; import org.hibernate.cache.spi.CacheKey;
import org.hibernate.collection.spi.PersistentCollection; import org.hibernate.collection.spi.PersistentCollection;
import org.hibernate.engine.internal.SessionEventsManagerImpl; import org.hibernate.engine.internal.SessionEventListenerManagerImpl;
import org.hibernate.engine.internal.StatefulPersistenceContext; import org.hibernate.engine.internal.StatefulPersistenceContext;
import org.hibernate.engine.internal.Versioning; import org.hibernate.engine.internal.Versioning;
import org.hibernate.engine.query.spi.HQLQueryPlan; import org.hibernate.engine.query.spi.HQLQueryPlan;
@ -59,7 +59,7 @@ import org.hibernate.engine.spi.LoadQueryInfluencers;
import org.hibernate.engine.spi.NonFlushedChanges; import org.hibernate.engine.spi.NonFlushedChanges;
import org.hibernate.engine.spi.PersistenceContext; import org.hibernate.engine.spi.PersistenceContext;
import org.hibernate.engine.spi.QueryParameters; import org.hibernate.engine.spi.QueryParameters;
import org.hibernate.engine.spi.SessionEventsManager; import org.hibernate.engine.spi.SessionEventListenerManager;
import org.hibernate.engine.transaction.internal.TransactionCoordinatorImpl; import org.hibernate.engine.transaction.internal.TransactionCoordinatorImpl;
import org.hibernate.engine.transaction.spi.TransactionCoordinator; import org.hibernate.engine.transaction.spi.TransactionCoordinator;
import org.hibernate.engine.transaction.spi.TransactionEnvironment; import org.hibernate.engine.transaction.spi.TransactionEnvironment;
@ -395,12 +395,12 @@ public class StatelessSessionImpl extends AbstractSessionImpl implements Statele
return sql; return sql;
} }
private SessionEventsManagerImpl sessionEventsManager; private SessionEventListenerManagerImpl sessionEventsManager;
@Override @Override
public SessionEventsManager getSessionEventsManager() { public SessionEventListenerManager getEventListenerManager() {
if ( sessionEventsManager == null ) { if ( sessionEventsManager == null ) {
sessionEventsManager = new SessionEventsManagerImpl(); sessionEventsManager = new SessionEventListenerManagerImpl();
} }
return sessionEventsManager; return sessionEventsManager;
} }

View File

@ -56,4 +56,4 @@ log4j.logger.org.hibernate.loader.plan2.build.internal.LoadPlanImpl=debug
log4j.logger.org.hibernate.loader.plan2.build.spi.LoadPlanTreePrinter=debug log4j.logger.org.hibernate.loader.plan2.build.spi.LoadPlanTreePrinter=debug
log4j.logger.org.hibernate.loader.plan2.exec.spi.EntityLoadQueryDetails=debug log4j.logger.org.hibernate.loader.plan2.exec.spi.EntityLoadQueryDetails=debug
log4j.logger.org.hibernate.engine.internal.LoggingSessionEventsListener=info log4j.logger.org.hibernate.engine.internal.StatisticalLoggingSessionEventListener=info