Java 类org.hibernate.search.event.impl.FullTextIndexEventListener 实例源码

项目:ipf-flow-manager    文件:CustomEventRegistration.java   
@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);
}
项目:debop4j    文件:SearchTool.java   
/**
 * Hibernate-Search의 FullTextIndexEventListener를 SessionFactory에 등록합니다.
 *
 * @param sessionFactory the session factory
 * @param listener       the listener
 */
public static void registerFullTextIndexEventListener(SessionFactory sessionFactory, FullTextIndexEventListener listener) {
    assert sessionFactory != null;
    log.info("sessionFactory에 FullTestIndexEventListener를 등록합니다... listener=[{}]", listener);

    try {
        HibernateTool.registerEventListener(sessionFactory, listener,
                                            EventType.POST_UPDATE,
                                            EventType.POST_INSERT,
                                            EventType.POST_DELETE,
                                            EventType.FLUSH);
    } catch (Throwable t) {
        log.warn("listener를 등록하는데 실패했습니다. 단 이미 등록된 경우에는 무시해도 됩니다.", t);
    }
}