Package org.hibernate.service.event.spi

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


      return;
    }

    final Object listener = instantiateListener( listenerClass );

    EventListenerRegistry listenerRegistry = serviceRegistry.getService( EventListenerRegistry.class );

    listenerRegistry.addDuplicationStrategy( new DuplicationStrategyImpl( listenerClass ) );

    listenerRegistry.getEventListenerGroup( EventType.POST_INSERT ).appendListener( (PostInsertEventListener) listener );
    listenerRegistry.getEventListenerGroup( EventType.POST_UPDATE ).appendListener( (PostUpdateEventListener) listener );
    listenerRegistry.getEventListenerGroup( EventType.POST_DELETE ).appendListener( (PostDeleteEventListener) listener );
    listenerRegistry.getEventListenerGroup( EventType.POST_COLLECTION_RECREATE ).appendListener( (PostCollectionRecreateEventListener) listener );
    listenerRegistry.getEventListenerGroup( EventType.POST_COLLECTION_REMOVE ).appendListener( (PostCollectionRemoveEventListener) listener );
    listenerRegistry.getEventListenerGroup( EventType.POST_COLLECTION_UPDATE ).appendListener( (PostCollectionUpdateEventListener) listener );
  }
View Full Code Here


    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

    } 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

TOP

Related Classes of org.hibernate.service.event.spi.EventListenerRegistry

Copyright © 2018 www.massapicom. 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.