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()
        }
    );

    //Add the default Hibernate Core PreLoadEventListener
    //TODO shouldn't we read the value from getPreLoadEventListeners and add JACC?
    //probably a better thing to do as it allows cfg.xml config but this is a big change and need more thoughts
    listenerConfig.setPreLoadEventListeners(
        new PreLoadEventListener[] {
            new DefaultPreLoadEventListener(),
            new JACCPreLoadEventListener()
        }
    );

    //post events
    listenerConfig.setPostDeleteEventListeners(
        new PostDeleteEventListener[] { new EJB3PostDeleteEventListener() }
    );
    listenerConfig.setPostInsertEventListeners(
        new PostInsertEventListener[] { new EJB3PostInsertEventListener() }
    );
    //Add the default Hibernate Core PostLoadEventListener
    //TODO shouldn't we read the value from getPostLoadEventListeners
    //probably a better thing to do as it allows cfg.xml config but this is a big change and need more thoughts
    listenerConfig.setPostLoadEventListeners(
        new PostLoadEventListener[] { new EJB3PostLoadEventListener(), new DefaultPostLoadEventListener() }
    );
    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


  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

    xmlHelper = new XMLHelper();
    interceptor = EmptyInterceptor.INSTANCE;
    properties = Environment.getProperties();
    entityResolver = XMLHelper.DEFAULT_DTD_RESOLVER;
    eventListeners = new EventListeners();

    sqlFunctions = new HashMap<String, SQLFunction>();

    entityTuplizerFactory = new EntityTuplizerFactory();
//    componentTuplizerFactory = new ComponentTuplizerFactory();
View Full Code Here

      log.debug( "Unable to execute {}, ignoring event listener registration.", SEARCH_STARTUP_METHOD );
    }
  }

  private EventListeners getInitializedEventListeners() {
    EventListeners result = (EventListeners) eventListeners.shallowCopy();
    result.initializeListeners( this );
    return result;
  }
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.