Examples of EventListenerRegistry


Examples of org.hibernate.event.service.spi.EventListenerRegistry

      throw new IllegalStateException("already injected");
    }

    SessionFactoryImpl sessionFactoryImpl = (SessionFactoryImpl) sessionFactory;

    EventListenerRegistry registry = sessionFactoryImpl.getServiceRegistry()
        .getService(EventListenerRegistry.class);

    _listener = doCreateListener(sessionFactoryImpl, batchedEventProcessor);

    if (_listener instanceof PostInsertEventListener) {
      if (registerPostCommitListeneres) {
        registry.appendListeners(EventType.POST_COMMIT_INSERT, (PostInsertEventListener) _listener);
      } else {
        registry.appendListeners(EventType.POST_INSERT, (PostInsertEventListener) _listener);
      }
    }

    if (_listener instanceof PostUpdateEventListener) {
      if (registerPostCommitListeneres) {
        registry.appendListeners(EventType.POST_COMMIT_UPDATE, (PostUpdateEventListener) _listener);
      } else {
        registry.appendListeners(EventType.POST_UPDATE, (PostUpdateEventListener) _listener);
      }
    }

    if (_listener instanceof PostDeleteEventListener) {
      if (registerPostCommitListeneres) {
        registry.appendListeners(EventType.POST_COMMIT_DELETE, (PostDeleteEventListener) _listener);
      } else {
        registry.appendListeners(EventType.POST_DELETE, (PostDeleteEventListener) _listener);
      }
    }

    // collections
    if (!registerPostCommitListeneres) {
      if (_listener instanceof PostCollectionRecreateEventListener) {
        registry.appendListeners(EventType.POST_COLLECTION_RECREATE,
            (PostCollectionRecreateEventListener) _listener);
      }

      if (_listener instanceof PostCollectionRemoveEventListener) {
        registry.appendListeners(EventType.POST_COLLECTION_REMOVE,
            (PostCollectionRemoveEventListener) _listener);
      }

      if (_listener instanceof PostCollectionUpdateEventListener) {
        registry.appendListeners(EventType.POST_COLLECTION_UPDATE,
            (PostCollectionUpdateEventListener) _listener);
      }
    }
  }
View Full Code Here

Examples of org.hibernate.event.service.spi.EventListenerRegistry

      return;
    }

    SessionFactoryImpl sessionFactoryImpl = (SessionFactoryImpl) sessionFactory;

    EventListenerRegistry registry = sessionFactoryImpl.getServiceRegistry()
        .getService(EventListenerRegistry.class);

    if (registerPostCommitListeneres) {
      removeListeners(registry, _listener, POST_COMMIT_INSERT, POST_COMMIT_UPDATE, POST_COMMIT_DELETE);
    } else {
View Full Code Here

Examples of org.hibernate.event.service.spi.EventListenerRegistry

  private void attachBatchListenersIfRequired(SessionFactoryServiceRegistry serviceRegistry) {
    GridDialect gridDialect = serviceRegistry.getService( GridDialect.class );
    BatchOperationsDelegator batchDelegator = asBatchDelegatorOrNull( gridDialect );

    if ( batchDelegator != null ) {
      EventListenerRegistry eventListenerRegistry = serviceRegistry.getService( EventListenerRegistry.class );
      addListeners( eventListenerRegistry, batchDelegator );
    }
  }
View Full Code Here

Examples of org.hibernate.event.service.spi.EventListenerRegistry

    } else {
      sessionImpl = (SessionImplementor) session;
    }

    // todo : I wonder if there is a better means to do this via "named lookup" based on the session factory name/uuid
    final EventListenerRegistry listenerRegistry = sessionImpl
        .getFactory()
        .getServiceRegistry()
        .getService( EventListenerRegistry.class );

    for ( PostInsertEventListener listener : listenerRegistry.getEventListenerGroup( EventType.POST_INSERT ).listeners() ) {
      if ( listener instanceof EnversListener ) {
        // todo : slightly different from original code in that I am not checking the other listener groups...
        return new AuditReaderImpl(
            ( (EnversListener) listener ).getAuditConfiguration(),
            session,
View Full Code Here

Examples of org.hibernate.event.service.spi.EventListenerRegistry

    if ( !autoRegister ) {
      LOG.debug( "Skipping Envers listener auto registration" );
      return;
    }

    EventListenerRegistry listenerRegistry = serviceRegistry.getService( EventListenerRegistry.class );
    listenerRegistry.addDuplicationStrategy( EnversListenerDuplicationStrategy.INSTANCE );

    final AuditConfiguration enversConfiguration = AuditConfiguration.getFor( configuration );

        if (enversConfiguration.getEntCfg().hasAuditedEntities()) {
        listenerRegistry.appendListeners( EventType.POST_DELETE, new EnversPostDeleteEventListenerImpl( enversConfiguration ) );
        listenerRegistry.appendListeners( EventType.POST_INSERT, new EnversPostInsertEventListenerImpl( enversConfiguration ) );
        listenerRegistry.appendListeners( EventType.POST_UPDATE, new EnversPostUpdateEventListenerImpl( enversConfiguration ) );
        listenerRegistry.appendListeners( EventType.POST_COLLECTION_RECREATE, new EnversPostCollectionRecreateEventListenerImpl( enversConfiguration ) );
        listenerRegistry.appendListeners( EventType.PRE_COLLECTION_REMOVE, new EnversPreCollectionRemoveEventListenerImpl( enversConfiguration ) );
        listenerRegistry.appendListeners( EventType.PRE_COLLECTION_UPDATE, new EnversPreCollectionUpdateEventListenerImpl( enversConfiguration ) );
        }
  }
View Full Code Here

Examples of org.hibernate.event.service.spi.EventListenerRegistry

    }

    @PostConstruct
    private void registerHibernateListeners() {
        SessionFactoryImpl impl = (SessionFactoryImpl) sessionFactory;
        EventListenerRegistry registry = impl.getServiceRegistry().getService(EventListenerRegistry.class);

        registry.appendListeners(EventType.POST_INSERT, this);
        registry.appendListeners(EventType.POST_UPDATE, this);
        registry.appendListeners(EventType.POST_DELETE, this);

        hibernateListenersRegistered = true;
    }
View Full Code Here

Examples of org.hibernate.event.service.spi.EventListenerRegistry

    if ( !autoRegister ) {
      LOG.debug( "Skipping Envers listener auto registration" );
      return;
    }

    final EventListenerRegistry listenerRegistry = serviceRegistry.getService( EventListenerRegistry.class );
    listenerRegistry.addDuplicationStrategy( EnversListenerDuplicationStrategy.INSTANCE );

    final AuditConfiguration enversConfiguration = AuditConfiguration.getFor(
        configuration,
        serviceRegistry.getService(
            ClassLoaderService.class
        )
    );

    if ( enversConfiguration.getEntCfg().hasAuditedEntities() ) {
      listenerRegistry.appendListeners(
          EventType.POST_DELETE, new EnversPostDeleteEventListenerImpl(
          enversConfiguration
      )
      );
      listenerRegistry.appendListeners(
          EventType.POST_INSERT, new EnversPostInsertEventListenerImpl(
          enversConfiguration
      )
      );
      listenerRegistry.appendListeners(
          EventType.POST_UPDATE, new EnversPostUpdateEventListenerImpl(
          enversConfiguration
      )
      );
      listenerRegistry.appendListeners(
          EventType.POST_COLLECTION_RECREATE,
          new EnversPostCollectionRecreateEventListenerImpl( enversConfiguration )
      );
      listenerRegistry.appendListeners(
          EventType.PRE_COLLECTION_REMOVE,
          new EnversPreCollectionRemoveEventListenerImpl( enversConfiguration )
      );
      listenerRegistry.appendListeners(
          EventType.PRE_COLLECTION_UPDATE,
          new EnversPreCollectionUpdateEventListenerImpl( enversConfiguration )
      );
    }
  }
View Full Code Here

Examples of org.hibernate.event.service.spi.EventListenerRegistry

public class EnversIntegratorImpl extends EnversIntegrator {

    @Override
    public void integrate(Configuration configuration, SessionFactoryImplementor sessionFactory, SessionFactoryServiceRegistry serviceRegistry) {
        super.integrate(configuration, sessionFactory, serviceRegistry);
        EventListenerRegistry listenerRegistry = serviceRegistry.getService( EventListenerRegistry.class );
        listenerRegistry.addDuplicationStrategy( EnversListenerDuplicationStrategy.INSTANCE );
        final AuditConfiguration enversConfiguration = AuditConfiguration.getFor( configuration, serviceRegistry.getService( ClassLoaderService.class ) );
        if (enversConfiguration.getEntCfg().hasAuditedEntities()) {
            listenerRegistry.appendListeners( EventType.POST_DELETE, new EnversOnlyPostDeleteEventListenerImpl( enversConfiguration ) );
        }
    }
View Full Code Here

Examples of org.hibernate.event.service.spi.EventListenerRegistry

*/
public class DuplicationStrategyTest {

  @Test
  public void testMultipleRegistrationOfEventListenerKeepsOriginalListener() {
    EventListenerRegistry eventListenerRegistry = new EventListenerRegistryImpl();

    EventListenerGroup<PostInsertEventListener> eventEventListenerGroup = eventListenerRegistry.getEventListenerGroup(
        EventType.POST_INSERT
    );
    assertTrue( "We should start of with no listeners", eventEventListenerGroup.count() == 0 );

    FullTextIndexEventListener firstFullTextIndexEventListener = new FullTextIndexEventListener();

    eventListenerRegistry.setListeners( EventType.POST_INSERT, firstFullTextIndexEventListener );
    eventListenerRegistry.addDuplicationStrategy(
        new HibernateSearchIntegrator.DuplicationStrategyImpl(
            FullTextIndexEventListener.class
        )
    );
    eventListenerRegistry.appendListeners( EventType.POST_INSERT, new FullTextIndexEventListener() );

    assertTrue(
        "We should only be one listener, but we have " + eventEventListenerGroup.count(),
        eventEventListenerGroup.count() == 1
    );
View Full Code Here

Examples of org.hibernate.event.service.spi.EventListenerRegistry

    final ServiceRegistry serviceRegistry = ServiceRegistryTools.build( registryBuilder );
    SessionFactoryImpl sessionFactoryImpl = (SessionFactoryImpl) hibConfiguration.buildSessionFactory(
        serviceRegistry
    );
    ServiceRegistryImplementor serviceRegistryImplementor = sessionFactoryImpl.getServiceRegistry();
    EventListenerRegistry registry = serviceRegistryImplementor.getService( EventListenerRegistry.class );

    for ( LoadEventListener listener : additionalLoadEventListeners ) {
      registry.getEventListenerGroup( EventType.LOAD ).appendListener( listener );
    }

    sessionFactory = sessionFactoryImpl;
    return this;
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.