HHH-10674 - SessionFactoryObserver could use a sessionFactoryAboutToClose method
This commit is contained in:
parent
11fc090557
commit
6cb8ef26ac
|
@ -19,7 +19,24 @@ public interface SessionFactoryObserver extends Serializable {
|
||||||
*
|
*
|
||||||
* @param factory The factory initialized.
|
* @param factory The factory initialized.
|
||||||
*/
|
*/
|
||||||
public void sessionFactoryCreated(SessionFactory factory);
|
void sessionFactoryCreated(SessionFactory factory);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Callback to indicate that the given factory is about close. The passed factory reference should be usable
|
||||||
|
* since it is only about to close.
|
||||||
|
* <p/>
|
||||||
|
* NOTE : defined as default to allow for existing SessionFactoryObserver impls to work
|
||||||
|
* in 5.2. Starting in 6.0 the default will be removed and SessionFactoryObserver impls
|
||||||
|
* will be required to implement this new method.
|
||||||
|
*
|
||||||
|
* @param factory The factory about to be closed.
|
||||||
|
*
|
||||||
|
* @since 5.2
|
||||||
|
*/
|
||||||
|
default void sessionFactoryClosing(SessionFactory factory) {
|
||||||
|
// todo : 6.0 remove
|
||||||
|
// do nothing by default for 5.x compatibility
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Callback to indicate that the given factory has been closed. Care should be taken
|
* Callback to indicate that the given factory has been closed. Care should be taken
|
||||||
|
@ -27,5 +44,5 @@ public interface SessionFactoryObserver extends Serializable {
|
||||||
*
|
*
|
||||||
* @param factory The factory closed.
|
* @param factory The factory closed.
|
||||||
*/
|
*/
|
||||||
public void sessionFactoryClosed(SessionFactory factory);
|
void sessionFactoryClosed(SessionFactory factory);
|
||||||
}
|
}
|
||||||
|
|
|
@ -721,6 +721,7 @@ public final class SessionFactoryImpl implements SessionFactoryImplementor {
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG.closing();
|
LOG.closing();
|
||||||
|
observer.sessionFactoryClosing( this );
|
||||||
|
|
||||||
isClosed = true;
|
isClosed = true;
|
||||||
|
|
||||||
|
|
|
@ -36,6 +36,19 @@ public class SessionFactoryObserverChain implements SessionFactoryObserver {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void sessionFactoryClosing(SessionFactory factory) {
|
||||||
|
if ( observers == null ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//notify in reverse order of create notification
|
||||||
|
int size = observers.size();
|
||||||
|
for (int index = size - 1 ; index >= 0 ; index--) {
|
||||||
|
observers.get( index ).sessionFactoryClosing( factory );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sessionFactoryClosed(SessionFactory factory) {
|
public void sessionFactoryClosed(SessionFactory factory) {
|
||||||
if ( observers == null ) {
|
if ( observers == null ) {
|
||||||
|
|
Loading…
Reference in New Issue