Package org.hibernate.search.spi

Examples of org.hibernate.search.spi.SearchFactoryIntegrator


    */
   @Override
   public void cacheStarting(ComponentRegistry cr, Configuration cfg, String cacheName) {
      if (cfg.indexing().enabled()) {
         log.registeringQueryInterceptor();
         SearchFactoryIntegrator searchFactory = getSearchFactory(cfg.indexing().properties(), cr);
         createQueryInterceptorIfNeeded(cr, cfg, searchFactory);
      }
   }
View Full Code Here


   }

   private void registerQueryMBeans(AdvancedCache cache,
         ComponentRegistry cr, String cacheName) {
      Configuration cfg = cache.getCacheConfiguration();
      SearchFactoryIntegrator sf = getSearchFactory(
            cfg.indexing().properties(), cr);

      // Resolve MBean server instance
      GlobalConfiguration globalCfg =
            cr.getGlobalComponentRegistry().getGlobalConfiguration();
View Full Code Here

      return interceptorChain.containsInterceptorType(QueryInterceptor.class, true);
   }

   private SearchFactoryIntegrator getSearchFactory(Properties indexingProperties, ComponentRegistry cr) {
      Object component = cr.getComponent(SearchFactoryIntegrator.class);
      SearchFactoryIntegrator searchFactory = null;
      if (component instanceof SearchFactoryIntegrator) { //could be the placeholder Object REMOVED_REGISTRY_COMPONENT
         searchFactory = (SearchFactoryIntegrator) component;
      }
      //defend against multiple initialization:
      if (searchFactory==null) {
View Full Code Here

      }
   }

   @Override
   public void cacheStopped(ComponentRegistry cr, String cacheName) {
      SearchFactoryIntegrator searchFactoryIntegrator = searchFactoriesToShutdown.remove(cacheName);
      if (searchFactoryIntegrator != null) {
         searchFactoryIntegrator.close();
      }

      Configuration cfg = cr.getComponent(Configuration.class);
      removeQueryInterceptorFromConfiguration(cfg);
   }
View Full Code Here

      String jpqlString = accept(new JPAQueryGenerator());
      if (log.isTraceEnabled()) {
         log.tracef("JPQL string : %s", jpqlString);
      }

      SearchFactoryIntegrator searchFactory = (SearchFactoryIntegrator) searchManager.getSearchFactory();
      LuceneProcessingChain processingChain = new LuceneProcessingChain.Builder(searchFactory, entityNamesResolver).buildProcessingChainForClassBasedEntities();
      QueryParser queryParser = new QueryParser();
      LuceneQueryParsingResult parsingResult = queryParser.parseQuery(jpqlString, processingChain);

      Sort sort = null;
View Full Code Here

   * Counts the number of nodes in the cluster on this node
   * @param node the FullTextSessionBuilder representing the current node
   * @return the number of nodes as seen by the current node
   */
  public static int clusterSize(FullTextSessionBuilder node, Class<?> entityType) {
    SearchFactoryIntegrator searchFactory = (SearchFactoryIntegrator) node.getSearchFactory();
    EntityIndexBinding indexBinding = searchFactory.getIndexBinding( entityType );
    DirectoryBasedIndexManager indexManager = (DirectoryBasedIndexManager) indexBinding.getIndexManagers()[0];
    InfinispanDirectoryProvider directoryProvider = (InfinispanDirectoryProvider) indexManager.getDirectoryProvider();
    EmbeddedCacheManager cacheManager = directoryProvider.getCacheManager();
    List<Address> members = cacheManager.getMembers();
    return members.size();
View Full Code Here

   * @param node
   *            the FullTextSessionBuilder representing the current node
   * @return
   */
  protected int clusterSize(FullTextSessionBuilder node, Class<?> entityType) {
    SearchFactoryIntegrator searchFactory = (SearchFactoryIntegrator) node.getSearchFactory();
    EntityIndexBinding indexBinding = searchFactory.getIndexBinding( Toaster.class );
    DirectoryBasedIndexManager indexManager = (DirectoryBasedIndexManager) indexBinding.getIndexManagers()[0];
    InfinispanDirectoryProvider directoryProvider = (InfinispanDirectoryProvider) indexManager.getDirectoryProvider();
    EmbeddedCacheManager cacheManager = directoryProvider.getCacheManager();
    List<Address> members = cacheManager.getMembers();
    return members.size();
View Full Code Here

    sf.close();
  }

  @Test
  public void testAddingClassFullModel() throws Exception {
    SearchFactoryIntegrator sf = new SearchFactoryBuilder().configuration( new SearchConfigurationForTest() ).buildSearchFactory();
    final SearchFactoryBuilder builder = new SearchFactoryBuilder();
    sf = builder.currentFactory( sf )
        .addClass( A.class )
        .buildSearchFactory();

    TransactionContextForTest tc = new TransactionContextForTest();

    doIndexWork( new A( 1, "Emmanuel" ), 1, sf, tc );

    tc.end();

    QueryParser parser = new QueryParser(
        TestConstants.getTargetLuceneVersion(),
        "name",
        TestConstants.standardAnalyzer
    );
    Query luceneQuery = parser.parse( "Emmanuel" );

    IndexReader indexReader = sf.getIndexReaderAccessor().open( A.class );
    IndexSearcher searcher = new IndexSearcher( indexReader );
    TopDocs hits = searcher.search( luceneQuery, 1000 );
    assertEquals( 1, hits.totalHits );

    sf.getIndexReaderAccessor().close( indexReader );

    sf = builder.currentFactory( sf )
        .addClass( B.class )
        .buildSearchFactory();

    tc = new TransactionContextForTest();

    doIndexWork( new B( 1, "Noel" ), 1, sf, tc );

    tc.end();

    luceneQuery = parser.parse( "Noel" );

    indexReader = sf.getIndexReaderAccessor().open( B.class );
    searcher = new IndexSearcher( indexReader );
    hits = searcher.search( luceneQuery, 1000 );
    assertEquals( 1, hits.totalHits );

    sf.getIndexReaderAccessor().close( indexReader );

    sf.close();
  }
View Full Code Here

    sf.close();
  }

  @Test
  public void testAddingClassSimpleAPI() throws Exception {
    SearchFactoryIntegrator sf = new SearchFactoryBuilder().configuration( new SearchConfigurationForTest() ).buildSearchFactory();

    sf.addClasses( A.class );

    TransactionContextForTest tc = new TransactionContextForTest();

    doIndexWork( new A( 1, "Emmanuel" ), 1, sf, tc );

    tc.end();

    QueryParser parser = new QueryParser(
        TestConstants.getTargetLuceneVersion(),
        "name",
        TestConstants.standardAnalyzer
    );
    Query luceneQuery = parser.parse( "Emmanuel" );

    IndexReader indexReader = sf.getIndexReaderAccessor().open( A.class );
    IndexSearcher searcher = new IndexSearcher( indexReader );
    TopDocs hits = searcher.search( luceneQuery, 1000 );
    assertEquals( 1, hits.totalHits );

    sf.getIndexReaderAccessor().close( indexReader );

    sf.addClasses( B.class, C.class );

    tc = new TransactionContextForTest();

    doIndexWork( new B( 1, "Noel" ), 1, sf, tc );
    doIndexWork( new C( 1, "Vincent" ), 1, sf, tc );

    tc.end();

    luceneQuery = parser.parse( "Noel" );

    indexReader = sf.getIndexReaderAccessor().open( B.class );
    searcher = new IndexSearcher( indexReader );
    hits = searcher.search( luceneQuery, 1000 );
    assertEquals( 1, hits.totalHits );
    sf.getIndexReaderAccessor().close( indexReader );

    luceneQuery = parser.parse( "Vincent" );

    indexReader = sf.getIndexReaderAccessor().open( C.class );
    searcher = new IndexSearcher( indexReader );
    hits = searcher.search( luceneQuery, 1000 );
    assertEquals( 1, hits.totalHits );

    sf.getIndexReaderAccessor().close( indexReader );

    sf.close();
  }
View Full Code Here

  private void assertCorrectDirectoryType(SessionFactory factory, String className) {
    Session session = factory.openSession();

    FullTextSession fullTextSession = Search.getFullTextSession( session );
    SearchFactoryIntegrator searchFactoryIntegrator = (SearchFactoryIntegrator) fullTextSession.getSearchFactory();
    EntityIndexBinding snowIndexBinder = searchFactoryIntegrator.getIndexBinding( SnowStorm.class );
    IndexManager[] indexManagers = snowIndexBinder.getIndexManagers();
    assertTrue( "Wrong number of directory providers", indexManagers.length == 1 );

    DirectoryBasedIndexManager indexManager = (DirectoryBasedIndexManager) indexManagers[0];
    Directory directory = indexManager.getDirectoryProvider().getDirectory();
View Full Code Here

TOP

Related Classes of org.hibernate.search.spi.SearchFactoryIntegrator

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.