if ( ! propertyName.startsWith( AvailableSettings.EVENT_LISTENER_PREFIX ) ) {
continue;
}
final String eventTypeName = propertyName.substring( AvailableSettings.EVENT_LISTENER_PREFIX.length() + 1 );
final EventType eventType = EventType.resolveEventTypeByName( eventTypeName );
final EventListenerGroup eventListenerGroup = eventListenerRegistry.getEventListenerGroup( eventType );
eventListenerGroup.clear();
for ( String listenerImpl : ( (String) entry.getValue() ).split( " ," ) ) {
eventListenerGroup.appendListener( instantiate( listenerImpl, serviceRegistry ) );
}
}
// todo : we may need to account for callback handlers previously set (shared across EMFs)
final EntityCallbackHandler callbackHandler = new EntityCallbackHandler();
Iterator classes = configuration.getClassMappings();
ReflectionManager reflectionManager = configuration.getReflectionManager();
while ( classes.hasNext() ) {
PersistentClass clazz = (PersistentClass) classes.next();
if ( clazz.getClassName() == null ) {
//we can have non java class persisted by hibernate
continue;
}
try {
callbackHandler.add( reflectionManager.classForName( clazz.getClassName(), this.getClass() ), reflectionManager );
}
catch (ClassNotFoundException e) {
throw new MappingException( "entity class not found: " + clazz.getNodeName(), e );
}
}
for ( EventType eventType : EventType.values() ) {
final EventListenerGroup eventListenerGroup = eventListenerRegistry.getEventListenerGroup( eventType );
for ( Object listener : eventListenerGroup.listeners() ) {
if ( CallbackHandlerConsumer.class.isInstance( listener ) ) {
( (CallbackHandlerConsumer) listener ).setCallbackHandler( callbackHandler );
}
}
}