Package org.hibernate.search.engine

Examples of org.hibernate.search.engine.SearchFactoryImplementor


  public void index(Object entity) {
    if ( entity == null ) throw new IllegalArgumentException( "Entity to index should not be null" );
    ;
    Class clazz = Hibernate.getClass( entity );
    //TODO cache that at the FTSession level
    SearchFactoryImplementor searchFactoryImplementor = getSearchFactoryImplementor();
    //not strictly necessary but a small optimization
    DocumentBuilder<Object> builder = searchFactoryImplementor.getDocumentBuilders().get( clazz );
    if ( builder == null ) {
      throw new IllegalArgumentException( "Entity to index not an @Indexed entity: " + entity.getClass().getName() );
    }
    Serializable id = session.getIdentifier( entity );
    Work work = new Work( entity, id, WorkType.INDEX );
    searchFactoryImplementor.getWorker().performWork( work, transactionContext );

    //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 <T> void purgeAll(Class<T> entityType) {
    purge( entityType, null );
  }

  public void flushToIndexes() {
    SearchFactoryImplementor searchFactoryImplementor = getSearchFactoryImplementor();
    searchFactoryImplementor.getWorker().flushWorks( transactionContext );
  }
View Full Code Here

      throw new IllegalArgumentException( "Entity to index should not be null" );
    }

    Class<?> clazz = HibernateHelper.getClass( entity );
    //TODO cache that at the FTSession level
    SearchFactoryImplementor searchFactoryImplementor = getSearchFactoryImplementor();
    //not strictly necessary but a small optimization
    if ( searchFactoryImplementor.getDocumentBuilderIndexedEntity( clazz ) == null ) {
      String msg = "Entity to index is not an @Indexed entity: " + entity.getClass().getName();
      throw new IllegalArgumentException( msg );
    }
    Serializable id = session.getIdentifier( entity );
    Work<T> work = new Work<T>( entity, id, WorkType.INDEX );
    searchFactoryImplementor.getWorker().performWork( work, transactionContext );

    //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

  ErrorHandler errorHandler;
  PolymorphicIndexHierarchy indexHierarchy;
  Map<DirectoryProvider, LuceneIndexingParameters> dirProviderIndexingParams;

  public SearchFactoryImplementor buildSearchFactory() {
    SearchFactoryImplementor searchFactoryImplementor;
    if ( rootFactory == null ) {
      if ( classes.size() > 0 ) {
        throw new SearchException( "Cannot add a class if the original SearchFactory is not passed" );
      }
      searchFactoryImplementor = buildNewSearchFactory();
View Full Code Here

  public <T> void purgeAll(Class<T> entityType) {
    purge( entityType, null );
  }

  public void flushToIndexes() {
    SearchFactoryImplementor searchFactoryImplementor = getSearchFactoryImplementor();
    searchFactoryImplementor.getWorker().flushWorks( transactionContext );
  }
View Full Code Here

  public <T> void purge(Class<T> entityType, Serializable id) {
    if ( entityType == null ) {
      return;
    }

    SearchFactoryImplementor searchFactoryImplementor = getSearchFactoryImplementor();
    Set<Class<?>> targetedClasses = searchFactoryImplementor.getIndexedTypesPolymorphic( new Class[] {entityType} );
    if ( targetedClasses.isEmpty() ) {
      String msg = entityType.getName() + " is not an indexed entity or a subclass of an indexed entity";
      throw new IllegalArgumentException( msg );
    }

    Work<T> work;
    for ( Class clazz : targetedClasses ) {
      if ( id == null ) {
        work = new Work<T>( clazz, id, WorkType.PURGE_ALL );
        searchFactoryImplementor.getWorker().performWork( work, transactionContext );
      }
      else {
        work = new Work<T>( clazz, id, WorkType.PURGE );
        searchFactoryImplementor.getWorker().performWork( work, transactionContext );
      }
    }
  }
View Full Code Here

      throw new IllegalArgumentException( "Entity to index should not be null" );
    }

    Class<?> clazz = Hibernate.getClass( entity );
    //TODO cache that at the FTSession level
    SearchFactoryImplementor searchFactoryImplementor = getSearchFactoryImplementor();
    //not strictly necessary but a small optimization
    if ( searchFactoryImplementor.getDocumentBuilderIndexedEntity( clazz ) == null ) {
      String msg = "Entity to index is not an @Indexed entity: " + entity.getClass().getName();
      throw new IllegalArgumentException( msg );
    }
    Serializable id = session.getIdentifier( entity );
    Work<T> work = new Work<T>( entity, id, WorkType.INDEX );
    searchFactoryImplementor.getWorker().performWork( work, transactionContext );

    //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

    //FIXME casting sucks because we do not control what get session from
    Session session = getSession();
    Runnable processor = null;

    try {
      SearchFactoryImplementor factory = ContextHelper.getSearchFactory( session );
      processor = factory.getBackendQueueProcessorFactory().getProcessor( queue );
    }
    finally {
      cleanSessionIfNeeded(session);
    }
    return processor;
View Full Code Here

      // step 1: create hibernate search searchFactory
      SearchConfiguration cfg = new SearchableCacheConfiguration(classes, properties);
      // set classes in the cfg

      SearchFactoryImplementor searchFactory = new SearchFactoryImpl(cfg);


      // Okay, create the core listener
      SearchableCoreListener coreListener = new SearchableCoreListener(searchFactory);
      c.addCacheListener(coreListener);
View Full Code Here

TOP

Related Classes of org.hibernate.search.engine.SearchFactoryImplementor

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.