Package org.hibernate.search.event

Examples of org.hibernate.search.event.FullTextIndexEventListener


  }

 
  public static SearchFactoryImplementor getSearchFactoryBySFI(SessionImplementor session) {
    PostInsertEventListener[] listeners = session.getListeners().getPostInsertEventListeners();
    FullTextIndexEventListener listener = null;
    //FIXME this sucks since we mandate the event listener use
    for ( PostInsertEventListener candidate : listeners ) {
      if ( candidate instanceof FullTextIndexEventListener ) {
        listener = (FullTextIndexEventListener) candidate;
        break;
      }
    }
    if ( listener == null ) throw new HibernateException(
        "Hibernate Search Event listeners not configured, please check the reference documentation and the " +
            "application's hibernate.cfg.xml" );
    return listener.getSearchFactoryImplementor();
  }
View Full Code Here


  }

 
  public static SearchFactoryImplementor getSearchFactoryBySFI(SessionImplementor session) {
    PostInsertEventListener[] listeners = session.getListeners().getPostInsertEventListeners();
    FullTextIndexEventListener listener = null;
    //FIXME this sucks since we mandante the event listener use
    for ( PostInsertEventListener candidate : listeners ) {
      if ( candidate instanceof FullTextIndexEventListener ) {
        listener = (FullTextIndexEventListener) candidate;
        break;
      }
    }
    if ( listener == null ) throw new HibernateException(
        "Hibernate Search Event listeners not configured, please check the reference documentation and the " +
            "application's hibernate.cfg.xml" );
    return listener.getSearchFactoryImplementor();
  }
View Full Code Here

*/
public abstract class ContextHelper {

  public static FullTextIndexEventListener getLuceneEventListener(SessionImplementor session) {
    PostInsertEventListener[] listeners = session.getListeners().getPostInsertEventListeners();
    FullTextIndexEventListener listener = null;
    //FIXME this sucks since we mandante the event listener use
    for ( PostInsertEventListener candidate : listeners ) {
      if ( candidate instanceof FullTextIndexEventListener ) {
        listener = (FullTextIndexEventListener) candidate;
        break;
View Full Code Here

    //implement an interator which keep the id/class for each hit and get the object on demand
    //cause I can't keep the searcher and hence the hit opened. I dont have any hook to know when the
    //user stop using it
    //scrollable is better in this area

    FullTextIndexEventListener listener = ContextHelper.getLuceneEventListener( session );
    //find the directories
    Searcher searcher = buildSearcher( listener );
    try {
      org.apache.lucene.search.Query query = filterQueryByClasses( luceneQuery );
      Hits hits = searcher.search( query );
View Full Code Here

    }
  }

    public ScrollableResults scroll() throws HibernateException {
    //keep the searcher open until the resultset is closed
    FullTextIndexEventListener listener = ContextHelper.getLuceneEventListener( session );;
    //find the directories
    Searcher searcher = buildSearcher( listener );
    Hits hits;
    try {
      org.apache.lucene.search.Query query = filterQueryByClasses( luceneQuery );
View Full Code Here

    //TODO think about this scrollmode
    return scroll();
  }

  public List list() throws HibernateException {
    FullTextIndexEventListener listener = ContextHelper.getLuceneEventListener( session );;
    //find the directories
    Searcher searcher = buildSearcher( listener );
    Hits hits;
    try {
      org.apache.lucene.search.Query query = filterQueryByClasses( luceneQuery );
View Full Code Here

  protected void configure(org.hibernate.cfg.Configuration cfg) {
    File sub = getBaseIndexDir();
    cfg.setProperty( "hibernate.search.default.indexBase", sub.getAbsolutePath() );
    cfg.setProperty( "hibernate.search.Clock.directory_provider", FSDirectoryProvider.class.getName() );
    cfg.setProperty( Environment.ANALYZER_CLASS, StopAnalyzer.class.getName() );
    FullTextIndexEventListener del = new FullTextIndexEventListener();
    cfg.getEventListeners().setPostDeleteEventListeners( new PostDeleteEventListener[]{del} );
    cfg.getEventListeners().setPostUpdateEventListeners( new PostUpdateEventListener[]{del} );
    cfg.getEventListeners().setPostInsertEventListeners( new PostInsertEventListener[]{del} );
  }
View Full Code Here

   * @param entity must not be null
   */
  public void index(Object entity) {
    if (entity == null) return;
    Class clazz = entity.getClass();
    FullTextIndexEventListener listener = ContextHelper.getLuceneEventListener( session );
    DocumentBuilder<Object> builder = listener.getDocumentBuilders().get( clazz );
    if ( builder != null ) {
      Serializable id = session.getIdentifier( entity );
      Document doc = builder.getDocument( entity, id );
      UpdateWork work = new UpdateWork( id, entity.getClass(), doc );
      processWork( work, listener.getDocumentBuilders(), listener.getLockableDirectoryProviders() );
    }
    //TODO
    //need to add elements in a queue kept at the Session level
    //the queue will be processed by a Lucene(Auto)FlushEventListener
    //note that we could keep this queue somewhere in the event listener in the mean time but that requires
View Full Code Here

  }

 
  public static SearchFactoryImplementor getSearchFactoryBySFI(SessionImplementor session) {
    PostInsertEventListener[] listeners = session.getListeners().getPostInsertEventListeners();
    FullTextIndexEventListener listener = null;
    //FIXME this sucks since we mandante the event listener use
    for ( PostInsertEventListener candidate : listeners ) {
      if ( candidate instanceof FullTextIndexEventListener ) {
        listener = (FullTextIndexEventListener) candidate;
        break;
      }
    }
    if ( listener == null ) throw new HibernateException(
        "Hibernate Search Event listeners not configured, please check the reference documentation and the " +
            "application's hibernate.cfg.xml" );
    return listener.getSearchFactoryImplementor();
  }
View Full Code Here

    return getSearchFactoryBySFI( (SessionImplementor) session );
  }

  public static SearchFactoryImplementor getSearchFactoryBySFI(SessionImplementor session) {
    PostInsertEventListener[] listeners = session.getListeners().getPostInsertEventListeners();
    FullTextIndexEventListener listener = null;
    //FIXME this sucks since we mandate the event listener use
    for ( PostInsertEventListener candidate : listeners ) {
      if ( candidate instanceof FullTextIndexEventListener ) {
        listener = (FullTextIndexEventListener) candidate;
        break;
      }
    }
    if ( listener == null ) {
      throw new HibernateException(
          "Hibernate Search Event listeners not configured, please check the reference documentation and the " +
              "application's hibernate.cfg.xml"
      );
    }
    return listener.getSearchFactoryImplementor();
  }
View Full Code Here

TOP

Related Classes of org.hibernate.search.event.FullTextIndexEventListener

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.