Example usage for org.hibernate.event.service.spi EventListenerGroup prependListener

List of usage examples for org.hibernate.event.service.spi EventListenerGroup prependListener

Introduction

In this page you can find the example usage for org.hibernate.event.service.spi EventListenerGroup prependListener.

Prototype

public void prependListener(T listener);

Source Link

Usage

From source file:org.openeos.hibernate.internal.observers.ListenerObserver.java

License:Apache License

@SuppressWarnings({ "rawtypes", "unchecked" })
@Override/*from www.  ja  v a  2s. com*/
public void sessionFactoryCreated(SessionFactory factory) {
    LOG.debug("Session factory created... registering listeners in service registry");
    ServiceRegistry serviceRegistry = ((SessionFactoryImplementor) factory).getServiceRegistry();
    for (Entry<EventType, Object> entry : mapPreListeners.entrySet()) {
        EventListenerGroup group = serviceRegistry.getService(EventListenerRegistry.class)
                .getEventListenerGroup(entry.getKey());
        group.prependListener(entry.getValue());
    }
    for (Entry<EventType, Object> entry : mapPostListeners.entrySet()) {
        EventListenerGroup group = serviceRegistry.getService(EventListenerRegistry.class)
                .getEventListenerGroup(entry.getKey());
        group.appendListener(entry.getValue());
    }

}