Java 类org.hibernate.event.spi.PostDeleteEventListener 实例源码

项目:lams    文件:EntityDeleteAction.java   
private void postDelete() {
    final EventListenerGroup<PostDeleteEventListener> listenerGroup = listenerGroup( EventType.POST_DELETE );
    if ( listenerGroup.isEmpty() ) {
        return;
    }
    final PostDeleteEvent event = new PostDeleteEvent(
            getInstance(),
            getId(),
            state,
            getPersister(),
            eventSource()
    );
    for ( PostDeleteEventListener listener : listenerGroup.listeners() ) {
        listener.onPostDelete( event );
    }
}
项目:spring-data-rest-webhook    文件:EventListenerRegistryAdapter.java   
@PostConstruct
public void registerListeners() {
    // TODO: This method of getting a reference to the SessionFactory (and thereforce the ServiceRegistry) is Deprecated. Find out the right Hibernate 5.2 way to do this.
    EventListenerRegistry registry = entityManagerFactory.getSessionFactory().getServiceRegistry().getService(EventListenerRegistry.class);
    if (preInsertEventListeners != null) {
        registry.appendListeners(EventType.PRE_INSERT, preInsertEventListeners.toArray(new PreInsertEventListener[preInsertEventListeners.size()]));
    }
    if (postInsertEventListeners != null) {
        registry.appendListeners(EventType.POST_INSERT, postInsertEventListeners.toArray(new PostInsertEventListener[postInsertEventListeners.size()]));
    }
    if (preUpdateEventListeners != null) {
        registry.appendListeners(EventType.PRE_UPDATE, preUpdateEventListeners.toArray(new PreUpdateEventListener[preUpdateEventListeners.size()]));
    }
    if (postUpdateEventListeners != null) {
        registry.appendListeners(EventType.POST_UPDATE, postUpdateEventListeners.toArray(new PostUpdateEventListener[postUpdateEventListeners.size()]));
    }
    if (preDeleteEventListeners != null) {
        registry.appendListeners(EventType.PRE_DELETE, preDeleteEventListeners.toArray(new PreDeleteEventListener[preDeleteEventListeners.size()]));
    }
    if (postDeleteEventListeners != null) {
        registry.appendListeners(EventType.POST_DELETE, postDeleteEventListeners.toArray(new PostDeleteEventListener[postDeleteEventListeners.size()]));
    }
}
项目:lams    文件:EntityDeleteAction.java   
private void postCommitDelete(boolean success) {
    final EventListenerGroup<PostDeleteEventListener> listenerGroup = listenerGroup( EventType.POST_COMMIT_DELETE );
    if ( listenerGroup.isEmpty() ) {
        return;
    }
    final PostDeleteEvent event = new PostDeleteEvent(
            getInstance(),
            getId(),
            state,
            getPersister(),
            eventSource()
    );
    for ( PostDeleteEventListener listener : listenerGroup.listeners() ) {
        if ( PostCommitDeleteEventListener.class.isInstance( listener ) ) {
            if ( success ) {
                listener.onPostDelete( event );
            }
            else {
                ((PostCommitDeleteEventListener) listener).onPostDeleteCommitFailed( event );
            }
        }
        else {
            //default to the legacy implementation that always fires the event
            listener.onPostDelete( event );
        }
    }
}
项目:lams    文件:EntityDeleteAction.java   
@Override
protected boolean hasPostCommitEventListeners() {
    final EventListenerGroup<PostDeleteEventListener> group = listenerGroup( EventType.POST_COMMIT_DELETE );
    for ( PostDeleteEventListener listener : group.listeners() ) {
        if ( listener.requiresPostCommitHanding( getPersister() ) ) {
            return true;
        }
    }

    return false;
}
项目:jersey2-toolkit    文件:HibernateSessionFactoryFactoryTest.java   
@Override
protected void configure() {
    bind(TestEventListener.class)
            .to(PostDeleteEventListener.class)
            .to(PreDeleteEventListener.class)
            .to(PreInsertEventListener.class)
            .to(PostInsertEventListener.class)
            .to(PreUpdateEventListener.class)
            .to(PostUpdateEventListener.class)
            .to(PostCommitInsertEventListener.class)
            .to(PostCommitUpdateEventListener.class)
            .to(PostCommitDeleteEventListener.class)
            .in(PerThread.class);
}
项目:jersey2-toolkit    文件:HibernateSessionFactoryFactoryTest.java   
/**
 * Test the application event injectors.
 */
@Test
public void testEventInjection() {

    // Create a fake application.
    SessionFactory factoryFactory = locator
            .getService(SessionFactory.class);
    Assert.assertNotNull(factoryFactory);


    ServiceRegistry serviceRegistry = ((SessionFactoryImpl) factoryFactory)
            .getServiceRegistry();
    EventListenerRegistry eventRegistry = serviceRegistry
            .getService(EventListenerRegistry.class);

    EventListenerGroup<PreInsertEventListener> priGroup = eventRegistry
            .getEventListenerGroup(EventType.PRE_INSERT);
    assertContainsListener(priGroup);

    EventListenerGroup<PostInsertEventListener> poiGroup = eventRegistry
            .getEventListenerGroup(EventType.POST_INSERT);
    assertContainsListener(poiGroup);

    EventListenerGroup<PreUpdateEventListener> pruGroup = eventRegistry
            .getEventListenerGroup(EventType.PRE_UPDATE);
    assertContainsListener(pruGroup);

    EventListenerGroup<PostUpdateEventListener> pouGroup = eventRegistry
            .getEventListenerGroup(EventType.POST_UPDATE);
    assertContainsListener(pouGroup);

    EventListenerGroup<PreDeleteEventListener> prdGroup = eventRegistry
            .getEventListenerGroup(EventType.PRE_DELETE);
    assertContainsListener(prdGroup);

    EventListenerGroup<PostDeleteEventListener> podGroup = eventRegistry
            .getEventListenerGroup(EventType.POST_DELETE);
    assertContainsListener(podGroup);

    EventListenerGroup<PostInsertEventListener> pciGroup = eventRegistry
            .getEventListenerGroup(EventType.POST_COMMIT_INSERT);
    assertContainsListener(pciGroup);

    EventListenerGroup<PostUpdateEventListener> pcuGroup = eventRegistry
            .getEventListenerGroup(EventType.POST_COMMIT_UPDATE);
    assertContainsListener(pcuGroup);

    EventListenerGroup<PostDeleteEventListener> pcdGroup = eventRegistry
            .getEventListenerGroup(EventType.POST_COMMIT_DELETE);
    assertContainsListener(pcdGroup);
}