当前位置: 首页>>代码示例>>Java>>正文


Java EventListenerRegistry.appendListeners方法代码示例

本文整理汇总了Java中org.hibernate.event.service.spi.EventListenerRegistry.appendListeners方法的典型用法代码示例。如果您正苦于以下问题:Java EventListenerRegistry.appendListeners方法的具体用法?Java EventListenerRegistry.appendListeners怎么用?Java EventListenerRegistry.appendListeners使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.hibernate.event.service.spi.EventListenerRegistry的用法示例。


在下文中一共展示了EventListenerRegistry.appendListeners方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: registerListeners

import org.hibernate.event.service.spi.EventListenerRegistry; //导入方法依赖的package包/类
@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()]));
    }
}
 
开发者ID:jfillo,项目名称:spring-data-rest-webhook,代码行数:24,代码来源:EventListenerRegistryAdapter.java

示例2: integrate

import org.hibernate.event.service.spi.EventListenerRegistry; //导入方法依赖的package包/类
@Override
public void integrate(Metadata metadata, SessionFactoryImplementor sessionFactory, SessionFactoryServiceRegistry serviceRegistry) {
    EventListenerRegistry service = serviceRegistry.getService(org.hibernate.event.service.spi.EventListenerRegistry.class);

    StandardPBEStringEncryptor encrypt = new StandardPBEStringEncryptor();
    encrypt.setPassword("test_password");
    RenderedMessageEncryptEventListener encryptListener = new RenderedMessageEncryptEventListener();
    encryptListener.setStringEncryptor(encrypt);

    RenderedMessageDecryptEventListener decryptListener = new RenderedMessageDecryptEventListener();
    decryptListener.setStringEncryptor(encrypt);

    FullTextIndexEventListener fullTextListener = new FullTextIndexEventListener();

    service.appendListeners(EventType.PRE_UPDATE, encryptListener);
    service.prependListeners(EventType.POST_UPDATE, decryptListener);
    service.appendListeners(EventType.PRE_INSERT, encryptListener);
    service.prependListeners(EventType.POST_INSERT, decryptListener);
    service.appendListeners(EventType.POST_LOAD, decryptListener);
}
 
开发者ID:oehf,项目名称:ipf-flow-manager,代码行数:21,代码来源:CustomEventRegistration.java

示例3: integrate

import org.hibernate.event.service.spi.EventListenerRegistry; //导入方法依赖的package包/类
public void integrate(Configuration configuration, SessionFactoryImplementor sessionFactory,
        SessionFactoryServiceRegistry serviceRegistry) {
    System.out.println("Integrating......");

    //final AuditService auditService = serviceRegistry.getService(AuditService.class);
    final AuditService auditService = new AuditServiceImpl();
    auditService.init();
    if (!auditService.isInitialized()) {
        throw new InitializationException(
                "Audit4j hibernate integration can not be initialized..");
    }

    // Register listeners..
    final EventListenerRegistry listenerRegistry = serviceRegistry
            .getService(EventListenerRegistry.class);

    listenerRegistry.appendListeners(EventType.POST_INSERT,
            new AuditPostInsertEventListenerImpl(auditService));
    listenerRegistry.appendListeners(EventType.POST_UPDATE,
            new AuditPostUpdateEventListenerImpl(auditService));
    listenerRegistry.appendListeners(EventType.POST_DELETE,
            new AuditPostDeleteEventListenerImpl(auditService));
}
 
开发者ID:nipunthathsara,项目名称:Audit4j-Hibernate,代码行数:24,代码来源:Audit4jIntegrator.java

示例4: appendListeners

import org.hibernate.event.service.spi.EventListenerRegistry; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
protected <T> void appendListeners(final EventListenerRegistry listenerRegistry,
                                   final EventType<T> eventType, final Map<String, Object> listeners) {

    Object listener = listeners.get(eventType.eventName());
    if (listener != null) {
        if(shouldOverrideListeners(eventType, listener)) {
            // since ClosureEventTriggeringInterceptor extends DefaultSaveOrUpdateEventListener we want to override instead of append the listener here
            // to avoid there being 2 implementations which would impact performance too
            listenerRegistry.setListeners(eventType, (T) listener);
        }
        else {
            listenerRegistry.appendListeners(eventType, (T)listener);
        }
    }
}
 
开发者ID:grails,项目名称:gorm-hibernate5,代码行数:17,代码来源:EventListenerIntegrator.java

示例5: applyCallbackListeners

import org.hibernate.event.service.spi.EventListenerRegistry; //导入方法依赖的package包/类
@SuppressWarnings( {"UnusedDeclaration"})
public static void applyCallbackListeners(ValidatorFactory validatorFactory, ActivationContext activationContext) {
	final Set<ValidationMode> modes = activationContext.getValidationModes();
	if ( ! ( modes.contains( ValidationMode.CALLBACK ) || modes.contains( ValidationMode.AUTO ) ) ) {
		return;
	}

	// de-activate not-null tracking at the core level when Bean Validation is present unless the user explicitly
	// asks for it
	if ( activationContext.getConfiguration().getProperty( Environment.CHECK_NULLABILITY ) == null ) {
		activationContext.getSessionFactory().getSettings().setCheckNullability( false );
	}

	final BeanValidationEventListener listener = new BeanValidationEventListener(
			validatorFactory,
			activationContext.getConfiguration().getProperties()
	);

	final EventListenerRegistry listenerRegistry = activationContext.getServiceRegistry()
			.getService( EventListenerRegistry.class );

	listenerRegistry.addDuplicationStrategy( DuplicationStrategyImpl.INSTANCE );

	listenerRegistry.appendListeners( EventType.PRE_INSERT, listener );
	listenerRegistry.appendListeners( EventType.PRE_UPDATE, listener );
	listenerRegistry.appendListeners( EventType.PRE_DELETE, listener );

	listener.initialize( activationContext.getConfiguration() );
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:30,代码来源:TypeSafeActivator.java

示例6: integrate

import org.hibernate.event.service.spi.EventListenerRegistry; //导入方法依赖的package包/类
private void integrate(SessionFactoryServiceRegistry serviceRegistry, SessionFactoryImplementor sessionFactory) {
	if ( !sessionFactory.getSettings().isAutoEvictCollectionCache() ) {
		// feature is disabled
		return;
	}
	if ( !sessionFactory.getSettings().isSecondLevelCacheEnabled() ) {
		// Nothing to do, if caching is disabled
		return;
	}
	EventListenerRegistry eventListenerRegistry = serviceRegistry.getService( EventListenerRegistry.class );
	eventListenerRegistry.appendListeners( EventType.POST_INSERT, this );
	eventListenerRegistry.appendListeners( EventType.POST_DELETE, this );
	eventListenerRegistry.appendListeners( EventType.POST_UPDATE, this );
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:15,代码来源:CollectionCacheInvalidator.java

示例7: integrate

import org.hibernate.event.service.spi.EventListenerRegistry; //导入方法依赖的package包/类
@Override
public void integrate(Configuration configuration, SessionFactoryImplementor sessionFactory,
      SessionFactoryServiceRegistry serviceRegistry) {
   log.info("start CibetIntegrator");
   final boolean autoRegister = ConfigurationHelper.getBoolean(AUTO_REGISTER, configuration.getProperties(), true);
   if (autoRegister) {
      log.debug("Skipping Cibet Envers listener auto registration");
      return;
   }

   log.info("CibetIntegrator registers Cibet Envers listeners");

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

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

   if (enversConfiguration.getEntCfg().hasAuditedEntities()) {
      listenerRegistry.appendListeners(EventType.POST_DELETE, new CibetPostDeleteEventListener(enversConfiguration));
      listenerRegistry.appendListeners(EventType.POST_INSERT, new CibetPostInsertEventListener(enversConfiguration));
      listenerRegistry.appendListeners(EventType.POST_UPDATE, new CibetPostUpdateEventListener(enversConfiguration));
      listenerRegistry.appendListeners(EventType.POST_COLLECTION_RECREATE,
            new CibetPostCollectionRecreateEventListener(enversConfiguration));
      listenerRegistry.appendListeners(EventType.PRE_COLLECTION_REMOVE,
            new CibetPreCollectionRemoveEventListener(enversConfiguration));
      listenerRegistry.appendListeners(EventType.PRE_COLLECTION_UPDATE,
            new CibetPreCollectionUpdateEventListener(enversConfiguration));
   }
}
 
开发者ID:Wolfgang-Winter,项目名称:cibet,代码行数:31,代码来源:CibetIntegrator.java

示例8: integrate

import org.hibernate.event.service.spi.EventListenerRegistry; //导入方法依赖的package包/类
@Override
public void integrate( Metadata metadata, SessionFactoryImplementor sessionFactory, SessionFactoryServiceRegistry serviceRegistry )
{
    final EventListenerRegistry registry = serviceRegistry.getService( EventListenerRegistry.class );

    DeletedObjectPostDeleteEventListener listener = new DeletedObjectPostDeleteEventListener();
    registry.appendListeners( EventType.POST_DELETE, listener );
}
 
开发者ID:dhis2,项目名称:dhis2-core,代码行数:9,代码来源:DeletedObjectIntegrator.java

示例9: integrate

import org.hibernate.event.service.spi.EventListenerRegistry; //导入方法依赖的package包/类
@Override
public void integrate(Configuration configuration,
  SessionFactoryImplementor sessionFactory,
  SessionFactoryServiceRegistry serviceRegistry) {

  // Avoid custom behavior is autoregister is true
  try {
    if (!"true".equals(ConfigUtility.getConfigProperties()
        .getProperty("hibernate.listeners.envers.autoRegister"))) {

      super.integrate(configuration, sessionFactory, serviceRegistry);

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

      listenerRegistry
          .addDuplicationStrategy(EnversListenerDuplicationStrategy.INSTANCE);

      if (enversConfiguration.getEntCfg().hasAuditedEntities()) {
        listenerRegistry.appendListeners(EventType.POST_INSERT,
            new EmptyEnversPostInsertEventListenerImpl(enversConfiguration));
        listenerRegistry.appendListeners(EventType.POST_DELETE,
            new CustomEnversPostDeleteEventListenerImpl(enversConfiguration));
      }
    }
  } catch (Exception e) {
    throw new RuntimeException(e);
  }

}
 
开发者ID:WestCoastInformatics,项目名称:UMLS-Terminology-Server,代码行数:34,代码来源:TermServerEnversIntegrator.java

示例10: integrate

import org.hibernate.event.service.spi.EventListenerRegistry; //导入方法依赖的package包/类
@Override
public void integrate(
        Metadata metadata,
        SessionFactoryImplementor sessionFactory,
        SessionFactoryServiceRegistry serviceRegistry) {

    final EventListenerRegistry eventListenerRegistry =
            serviceRegistry.getService( EventListenerRegistry.class );

    eventListenerRegistry.appendListeners(EventType.PERSIST, RootAwareInsertEventListener.INSTANCE);
    eventListenerRegistry.appendListeners(EventType.FLUSH_ENTITY, RootAwareUpdateAndDeleteEventListener.INSTANCE);
}
 
开发者ID:vladmihalcea,项目名称:high-performance-java-persistence,代码行数:13,代码来源:OptimisticLockingChildUpdatesRootVersionTest.java

示例11: integrate

import org.hibernate.event.service.spi.EventListenerRegistry; //导入方法依赖的package包/类
@Override
public void integrate(
        Metadata metadata,
        SessionFactoryImplementor sessionFactory,
        SessionFactoryServiceRegistry serviceRegistry) {

    final EventListenerRegistry eventListenerRegistry =
            serviceRegistry.getService( EventListenerRegistry.class );

    eventListenerRegistry.appendListeners( EventType.PERSIST, RootAwareInsertEventListener.INSTANCE);
    eventListenerRegistry.appendListeners( EventType.FLUSH_ENTITY, RootAwareUpdateAndDeleteEventListener.INSTANCE);
}
 
开发者ID:vladmihalcea,项目名称:high-performance-java-persistence,代码行数:13,代码来源:OptimisticLockingBidirectionalChildUpdatesRootVersionTest.java

示例12: getUpdateSource

import org.hibernate.event.service.spi.EventListenerRegistry; //导入方法依赖的package包/类
@Override
public SynchronizedUpdateSource getUpdateSource(
		ExtendedSearchIntegrator searchIntegrator,
		Map<Class<?>, RehashedTypeMetadata> rehashedTypeMetadataPerIndexRoot,
		Map<Class<?>, List<Class<?>>> containedInIndexOf,
		Properties properties,
		EntityManagerFactory emf,
		TransactionManager transactionManager,
		Set<Class<?>> indexRelevantEntities) {
	HibernateEntityManagerFactory hibernateEntityManagerFactory =
			(HibernateEntityManagerFactory) emf;
	SessionFactoryImpl sessionFactory = (SessionFactoryImpl) hibernateEntityManagerFactory.getSessionFactory();
	ServiceRegistry serviceRegistry = sessionFactory.getServiceRegistry();
	EventListenerRegistry listenerRegistry = serviceRegistry.getService( EventListenerRegistry.class );

	HibernateUpdateSource updateSource = new HibernateUpdateSource();
	updateSource.initialize( searchIntegrator );

	listenerRegistry.addDuplicationStrategy( new DuplicationStrategyImpl( HibernateUpdateSource.class ) );

	listenerRegistry.appendListeners( EventType.POST_INSERT, updateSource );
	listenerRegistry.appendListeners( EventType.POST_UPDATE, updateSource );
	listenerRegistry.appendListeners( EventType.POST_DELETE, updateSource );
	listenerRegistry.appendListeners( EventType.POST_COLLECTION_RECREATE, updateSource );
	listenerRegistry.appendListeners( EventType.POST_COLLECTION_REMOVE, updateSource );
	listenerRegistry.appendListeners( EventType.POST_COLLECTION_UPDATE, updateSource );

	return updateSource;
}
 
开发者ID:Hotware,项目名称:Hibernate-Search-GenericJPA,代码行数:30,代码来源:HibernateSynchronizedUpdateSourceProvider.java


注:本文中的org.hibernate.event.service.spi.EventListenerRegistry.appendListeners方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。