HHH-3261 : fixed wrapping of exception from initialize/destory listeners

git-svn-id: https://svn.jboss.org/repos/hibernate/core/trunk@14648 1b8cb986-b30d-0410-93ca-fae66ebed9b2
This commit is contained in:
Steve Ebersole 2008-05-07 18:11:38 +00:00
parent 9ab9158656
commit 46af959c3f
1 changed files with 18 additions and 10 deletions

View File

@ -29,7 +29,6 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import org.hibernate.AssertionFailure;
import org.hibernate.MappingException;
import org.hibernate.HibernateException;
import org.hibernate.cfg.Configuration;
@ -162,21 +161,26 @@ public class EventListeners extends Cloneable implements Serializable {
private void processListeners(ListenerProcesser processer) {
Field[] fields = getClass().getDeclaredFields();
for ( int i = 0; i < fields.length; i++ ) {
final Object[] listeners;
try {
final Object field = fields[i].get( this );
if ( field instanceof Object[] ) {
final Object[] listeners = ( Object[] ) field;
Object fieldValue = fields[i].get(this);
if ( fieldValue instanceof Object[] ) {
listeners = ( Object[] ) fieldValue;
}
else {
continue;
}
}
catch ( Throwable t ) {
throw new HibernateException( "could not init listeners", t );
}
int length = listeners.length;
for ( int index = 0 ; index < length ; index++ ) {
processer.processListener( listeners[index ] );
}
}
}
catch ( Exception e ) {
throw new HibernateException( "could not process listeners", e );
}
}
}
/**
* Call {@link Initializable#initialize} on any listeners that implement the
@ -201,6 +205,10 @@ public class EventListeners extends Cloneable implements Serializable {
}
}
/**
* Call {@link Destructible#cleanup} on any listeners that implement the
* {@link Destructible} interface.
*/
public void destroyListeners() {
try {
processListeners(