本文整理汇总了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()]));
}
}
示例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);
}
示例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));
}
示例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);
}
}
}
示例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() );
}
示例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 );
}
示例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));
}
}
示例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 );
}
示例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