Package org.hibernate.event

Examples of org.hibernate.event.EventListeners$ListenerProcesser


  private Ejb3Configuration configuration;
  private boolean isSecurity;

  public EventListenerConfigurator(Ejb3Configuration configuration) {
    this.configuration = configuration;
    EventListeners listenerConfig = configuration.getEventListeners();

    //Action event
    //EJB3-specific ops listeners
    listenerConfig.setFlushEventListeners( new FlushEventListener[]{EJB3FlushEventListener.INSTANCE} );
    //EJB3-specific ops listeners
    listenerConfig.setAutoFlushEventListeners( new AutoFlushEventListener[]{EJB3AutoFlushEventListener.INSTANCE} );
    listenerConfig.setDeleteEventListeners( new DeleteEventListener[]{new EJB3DeleteEventListener()} );
    listenerConfig.setFlushEntityEventListeners(
        new FlushEntityEventListener[]{new EJB3FlushEntityEventListener()}
    );
    listenerConfig.setMergeEventListeners( new MergeEventListener[]{new EJB3MergeEventListener()} );
    listenerConfig.setPersistEventListeners( new PersistEventListener[]{new EJB3PersistEventListener()} );
    listenerConfig.setPersistOnFlushEventListeners(
        new PersistEventListener[]{new EJB3PersistOnFlushEventListener()}
    );
    listenerConfig.setSaveEventListeners( new SaveOrUpdateEventListener[]{new EJB3SaveEventListener()} );
    listenerConfig.setSaveOrUpdateEventListeners(
        new SaveOrUpdateEventListener[]{new EJB3SaveOrUpdateEventListener()}
    );

    //Pre events
    listenerConfig.setPreInsertEventListeners(
        new PreInsertEventListener[]{
            new JACCPreInsertEventListener(),
        }
    );
    listenerConfig.setPreUpdateEventListeners(
        new PreUpdateEventListener[]{
            new JACCPreUpdateEventListener(),
        }
    );
    listenerConfig.setPreDeleteEventListeners(
        new PreDeleteEventListener[]{
            new JACCPreDeleteEventListener()
        }
    );
    listenerConfig.setPreLoadEventListeners(
        new PreLoadEventListener[]{
            new JACCPreLoadEventListener()
        }
    );

    //post events
    listenerConfig.setPostDeleteEventListeners(
        new PostDeleteEventListener[]{new EJB3PostDeleteEventListener()}
    );
    listenerConfig.setPostInsertEventListeners(
        new PostInsertEventListener[]{new EJB3PostInsertEventListener()}
    );
    listenerConfig.setPostLoadEventListeners(
        new PostLoadEventListener[]{new EJB3PostLoadEventListener()}
    );
    listenerConfig.setPostUpdateEventListeners(
        new PostUpdateEventListener[]{new EJB3PostUpdateEventListener()}
    );
  }
View Full Code Here


          throw new MappingException("entity class not found: " + clazz.getNodeName(), e);
        }
      }
    }

    EventListeners listenerConfig = configuration.getEventListeners();

    BeanInfo beanInfo = null;
    try {
      beanInfo = Introspector.getBeanInfo( listenerConfig.getClass(), Object.class );
      PropertyDescriptor[] pds = beanInfo.getPropertyDescriptors();
      try {
        for ( int i = 0, max = pds.length; i < max ; i++ ) {
          final Object listeners = pds[i].getReadMethod().invoke( listenerConfig, READER_METHOD_ARGS );
          if ( listeners == null ) {
View Full Code Here

*/
@SuppressWarnings("deprecation")
public class EventListenerRegisterTest extends TestCase {
 
  public void testRegisterOnEmptyListeners_CfgDisabled() {
    EventListeners evListeners = new EventListeners();
    EventListenerRegister.enableHibernateSearch( evListeners, makeConfiguration( false ) );
    EventListenerRegister.enableHibernateSearch( evListeners, makeConfiguration( false ) );
    assertPresence( false, evListeners );
  }
View Full Code Here

    EventListenerRegister.enableHibernateSearch( evListeners, makeConfiguration( false ) );
    assertPresence( false, evListeners );
  }
 
  public void testRegisterOnEmptyListeners_CfgEnabled() {
    EventListeners evListeners = new EventListeners();
    //tests registering multiple times is idempotent:
    EventListenerRegister.enableHibernateSearch( evListeners, makeConfiguration( true ) );
    EventListenerRegister.enableHibernateSearch( evListeners, makeConfiguration( true ) );
    assertPresence( true, evListeners );
  }
View Full Code Here

    EventListenerRegister.enableHibernateSearch( evListeners, makeConfiguration( true ) );
    assertPresence( true, evListeners );
  }
 
  public void testRegisterOnEmptyListeners_CfgAuto() {
    EventListeners evListeners = new EventListeners();
    EventListenerRegister.enableHibernateSearch( evListeners, new Properties() );
    EventListenerRegister.enableHibernateSearch( evListeners, new Properties() );
    assertPresence( true, evListeners );
  }
View Full Code Here

  public void testOnAlreadyRegisteredDeprecated() {
    helperOnAlreadyRegistered( new FullTextIndexCollectionEventListener() );
  }
 
  public void testOnPopulatedEventListeners() {
    EventListeners evListeners = makeSomeEventListeners();
    EventListenerRegister.enableHibernateSearch( evListeners, new Properties() );
    EventListenerRegister.enableHibernateSearch( evListeners, new Properties() );
    assertPresence( true, evListeners );
  }
View Full Code Here

  private void helperOnAlreadyRegistered(FullTextIndexEventListener listenerFullText) {
   
    AnotherListener listenerA = new AnotherListener();
    AnotherListener listenerB = new AnotherListener();
   
    EventListeners evListeners = new EventListeners();
    evListeners.setPostInsertEventListeners(
        new PostInsertEventListener[]{ listenerA, listenerB, listenerFullText }  );
    evListeners.setPostUpdateEventListeners(
        new PostUpdateEventListener[]{ listenerA, listenerB, listenerFullText } );
    evListeners.setPostDeleteEventListeners(
        new PostDeleteEventListener[]{ listenerA, listenerB, listenerFullText } );
    evListeners.setPostCollectionRecreateEventListeners(
        new PostCollectionRecreateEventListener[]{ listenerA, listenerB, listenerFullText } );
    evListeners.setPostCollectionRemoveEventListeners(
        new PostCollectionRemoveEventListener[]{ listenerA, listenerB, listenerFullText } );
    evListeners.setPostCollectionUpdateEventListeners(
        new PostCollectionUpdateEventListener[]{ listenerA, listenerB, listenerFullText } );
   
    EventListenerRegister.enableHibernateSearch( evListeners, makeConfiguration( false ) );
    EventListenerRegister.enableHibernateSearch( evListeners, makeConfiguration( false ) );
    EventListenerRegister.enableHibernateSearch( evListeners, makeConfiguration( false ) );
View Full Code Here

   
    AnotherListener listenerA = new AnotherListener();
    AnotherListener listenerB = new AnotherListener();
    AnotherListener listenerC = new AnotherListener();
   
    EventListeners evListeners = new EventListeners();
    evListeners.setPostInsertEventListeners(
        new PostInsertEventListener[]{ listenerA, listenerB, listenerC }  );
    evListeners.setPostUpdateEventListeners(
        new PostUpdateEventListener[]{ listenerA, listenerB, listenerC } );
    evListeners.setPostDeleteEventListeners(
        new PostDeleteEventListener[]{ listenerA, listenerB, listenerC } );
    evListeners.setPostCollectionRecreateEventListeners(
        new PostCollectionRecreateEventListener[]{ listenerA, listenerB, listenerC } );
    evListeners.setPostCollectionRemoveEventListeners(
        new PostCollectionRemoveEventListener[]{ listenerA, listenerB, listenerC } );
    evListeners.setPostCollectionUpdateEventListeners(
        new PostCollectionUpdateEventListener[]{ listenerA, listenerB, listenerC } );
   
    return evListeners;
  }
View Full Code Here


  public void testListeners() throws Exception {
    EntityManagerFactory emf = Persistence.createEntityManagerFactory( "manager1", new HashMap() );
    EntityManager em = emf.createEntityManager();
    EventListeners eventListeners = ( (SessionImplementor) em.getDelegate() ).getListeners();
    assertEquals(
        "Explicit pre-insert event through hibernate.ejb.event.pre-insert does not work",
        eventListeners.getPreInsertEventListeners().length,
        eventListeners.getPreUpdateEventListeners().length + 1 );

    em.close();
    emf.close();
  }
View Full Code Here


  public void testListeners() throws Exception {
    EntityManagerFactory emf = Persistence.createEntityManagerFactory( "manager1", new HashMap() );
    EntityManager em = emf.createEntityManager();
    EventListeners eventListeners = ( (SessionImplementor) em.getDelegate() ).getListeners();
    assertEquals(
        "Explicit pre-insert event through hibernate.ejb.event.pre-insert does not work",
        eventListeners.getPreInsertEventListeners().length,
        eventListeners.getPreUpdateEventListeners().length + 1 );

    em.close();
    emf.close();
  }
View Full Code Here

TOP

Related Classes of org.hibernate.event.EventListeners$ListenerProcesser

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.