Package org.hibernate.search.store

Examples of org.hibernate.search.store.DirectoryProviderFactory


    catch (Exception e) {
      throw new HibernateException( "Failed to instantiate lucene analyzer with type " + analyzerClassName );
    }

    Iterator iter = cfg.getClassMappings();
    DirectoryProviderFactory factory = new DirectoryProviderFactory();
    while ( iter.hasNext() ) {
      PersistentClass clazz = (PersistentClass) iter.next();
      Class<?> mappedClass = clazz.getMappedClass();
      if ( mappedClass != null ) {
        XClass mappedXClass = reflectionManager.toXClass( mappedClass );
        if ( mappedXClass != null && mappedXClass.isAnnotationPresent( Indexed.class ) ) {
          DirectoryProvider provider = factory.createDirectoryProvider( mappedXClass, cfg );
          if ( !lockableDirectoryProviders.containsKey( provider ) ) {
            lockableDirectoryProviders.put( provider, new ReentrantLock() );
          }
          final DocumentBuilder<Object> documentBuilder = new DocumentBuilder<Object>(
              mappedXClass, analyzer, provider, reflectionManager
View Full Code Here


   */

  private void initDocumentBuilders(SearchConfiguration cfg, ReflectionManager reflectionManager, BuildContext buildContext) {
    ConfigContext context = new ConfigContext( cfg );
    Iterator<Class<?>> iter = cfg.getClassMappings();
    DirectoryProviderFactory factory = new DirectoryProviderFactory();

    initProgrammaticAnalyzers( context, reflectionManager );
    initProgrammaticallyDefinedFilterDef( reflectionManager );
    final PolymorphicIndexHierarchy indexingHierarchy = factoryState.getIndexHierarchy();
    final Map<Class<?>, DocumentBuilderIndexedEntity<?>> documentBuildersIndexedEntities = factoryState.getDocumentBuildersIndexedEntities();
    final Map<Class<?>, DocumentBuilderContainedEntity<?>> documentBuildersContainedEntities = factoryState.getDocumentBuildersContainedEntities();
    while ( iter.hasNext() ) {
      Class<?> mappedClass = iter.next();
      if ( mappedClass == null ) {
        continue;
      }
      @SuppressWarnings("unchecked")
      XClass mappedXClass = reflectionManager.toXClass( mappedClass );
      if ( mappedXClass == null ) {
        continue;
      }

      if ( mappedXClass.isAnnotationPresent( Indexed.class ) ) {

        if ( mappedXClass.isAbstract() ) {
          log.warn( "Abstract classes can never insert index documents. Remove @Indexed." );
          continue;
        }

        DirectoryProviderFactory.DirectoryProviders providers = factory.createDirectoryProviders(
            mappedXClass, cfg, buildContext, reflectionManager
        );
        //FIXME DocumentBuilderIndexedEntity needs to be built by a helper method receiving Class<T> to infer T properly
        //XClass unfortunately is not (yet) genericized: TODO?
        final DocumentBuilderIndexedEntity<?> documentBuilder =
            new DocumentBuilderIndexedEntity(
                mappedXClass,
                context,
                providers,
                reflectionManager
            );

        indexingHierarchy.addIndexedClass( mappedClass );
        documentBuildersIndexedEntities.put( mappedClass, documentBuilder );
      }
      else {
        //FIXME DocumentBuilderIndexedEntity needs to be built by a helper method receiving Class<T> to infer T properly
        //XClass unfortunately is not (yet) genericized: TODO?
        final DocumentBuilderContainedEntity<?> documentBuilder = new DocumentBuilderContainedEntity(
            mappedXClass, context, reflectionManager
        );
        //TODO enhance that, I don't like to expose EntityState
        if ( documentBuilder.getEntityState() != EntityState.NON_INDEXABLE ) {
          documentBuildersContainedEntities.put( mappedClass, documentBuilder );
        }
      }
      bindFilterDefs( mappedXClass );
      //TODO should analyzer def for classes at their same level???
    }
    factoryState.setAnalyzers( context.initLazyAnalyzers() );
    factory.startDirectoryProviders();
  }
View Full Code Here

   * This algorithm seems to be safe for incremental search factories.
   */

  private void initDocumentBuilders(SearchConfiguration cfg, ReflectionManager reflectionManager, BuildContext buildContext) {
    ConfigContext context = new ConfigContext( cfg );
    DirectoryProviderFactory factory = new DirectoryProviderFactory();

    initProgrammaticAnalyzers( context, reflectionManager );
    initProgrammaticallyDefinedFilterDef( reflectionManager );
    final PolymorphicIndexHierarchy indexingHierarchy = factoryState.getIndexHierarchy();
    final Map<Class<?>, DocumentBuilderIndexedEntity<?>> documentBuildersIndexedEntities = factoryState.getDocumentBuildersIndexedEntities();
    final Map<Class<?>, DocumentBuilderContainedEntity<?>> documentBuildersContainedEntities = factoryState.getDocumentBuildersContainedEntities();
    final Set<XClass> optimizationBlackListedTypes = new HashSet<XClass>();
    final Map<XClass, Class> classMappings = initializeClassMappings( cfg, reflectionManager );
    for ( Map.Entry<XClass, Class> mapping : classMappings.entrySet() ) {

      XClass mappedXClass = mapping.getKey();
      Class mappedClass = mapping.getValue();
     
      if ( mappedXClass.isAnnotationPresent( Indexed.class ) ) {

        if ( mappedXClass.isAbstract() ) {
          log.warn( "Abstract classes can never insert index documents. Remove @Indexed." );
          continue;
        }

        DirectoryProviderFactory.DirectoryProviders providers = factory.createDirectoryProviders(
            mappedXClass, cfg, buildContext, reflectionManager
        );
        //FIXME DocumentBuilderIndexedEntity needs to be built by a helper method receiving Class<T> to infer T properly
        //XClass unfortunately is not (yet) genericized: TODO?
        final DocumentBuilderIndexedEntity<?> documentBuilder =
            new DocumentBuilderIndexedEntity(
                mappedXClass,
                context,
                providers,
                reflectionManager,
                optimizationBlackListedTypes
            );

        indexingHierarchy.addIndexedClass( mappedClass );
        documentBuildersIndexedEntities.put( mappedClass, documentBuilder );
      }
      else {
        //FIXME DocumentBuilderIndexedEntity needs to be built by a helper method receiving Class<T> to infer T properly
        //XClass unfortunately is not (yet) genericized: TODO?
        final DocumentBuilderContainedEntity<?> documentBuilder = new DocumentBuilderContainedEntity(
            mappedXClass, context, reflectionManager, optimizationBlackListedTypes
        );
        //TODO enhance that, I don't like to expose EntityState
        if ( documentBuilder.getEntityState() != EntityState.NON_INDEXABLE ) {
          documentBuildersContainedEntities.put( mappedClass, documentBuilder );
        }
      }
      bindFilterDefs( mappedXClass );
      //TODO should analyzer def for classes at their same level???
    }
    disableBlackListedTypesOptimization( classMappings, optimizationBlackListedTypes, documentBuildersIndexedEntities, documentBuildersContainedEntities );
    factoryState.setAnalyzers( context.initLazyAnalyzers() );
    factory.startDirectoryProviders();
  }
View Full Code Here

  }

  private void initDocumentBuilders(SearchConfiguration cfg, ReflectionManager reflectionManager) {
    InitContext context = new InitContext( cfg );
    Iterator<Class<?>> iter = cfg.getClassMappings();
    DirectoryProviderFactory factory = new DirectoryProviderFactory();

    while ( iter.hasNext() ) {
      Class mappedClass = iter.next();
      if (mappedClass != null) {
        XClass mappedXClass = reflectionManager.toXClass(mappedClass);
        if ( mappedXClass != null) {
          if ( mappedXClass.isAnnotationPresent( Indexed.class ) ) {
            DirectoryProviderFactory.DirectoryProviders providers = factory.createDirectoryProviders( mappedXClass, cfg, this, reflectionManager );

            final DocumentBuilder<Object> documentBuilder = new DocumentBuilder<Object>(
                mappedXClass, context, providers.getProviders(), providers.getSelectionStrategy(),
                reflectionManager
            );

            documentBuilders.put( mappedClass, documentBuilder );
          }
          bindFilterDefs(mappedXClass);
          //TODO should analyzer def for classes at tyher sqme level???
        }
      }
    }
    analyzers = context.initLazyAnalyzers();
    factory.startDirectoryProviders();
  }
View Full Code Here

   */

  private void initDocumentBuilders(SearchConfiguration cfg, ReflectionManager reflectionManager, BuildContext buildContext) {
    ConfigContext context = new ConfigContext( cfg );
    Iterator<Class<?>> iter = cfg.getClassMappings();
    DirectoryProviderFactory factory = new DirectoryProviderFactory();

    initProgrammaticAnalyzers( context, reflectionManager );
    initProgrammaticallyDefinedFilterDef( reflectionManager );

    while ( iter.hasNext() ) {
      Class<?> mappedClass = iter.next();
      if ( mappedClass == null ) {
        continue;
      }
      @SuppressWarnings("unchecked")
      XClass mappedXClass = reflectionManager.toXClass( mappedClass );
      if ( mappedXClass == null ) {
        continue;
      }

      if ( mappedXClass.isAnnotationPresent( Indexed.class ) ) {

        if ( mappedXClass.isAbstract() ) {
          log.warn( "Abstract classes can never insert index documents. Remove @Indexed." );
          continue;
        }

        DirectoryProviderFactory.DirectoryProviders providers = factory.createDirectoryProviders(
            mappedXClass, cfg, buildContext, reflectionManager
        );
        //FIXME DocumentBuilderIndexedEntity needs to be built by a helper method receiving Class<T> to infer T properly
        //XClass unfortunately is not (yet) genericized: TODO?
        final DocumentBuilderIndexedEntity<?> documentBuilder = new DocumentBuilderIndexedEntity(
            mappedXClass, context, providers.getProviders(), providers.getSelectionStrategy(),
            reflectionManager
        );

        indexHierarchy.addIndexedClass( mappedClass );
        documentBuildersIndexedEntities.put( mappedClass, documentBuilder );
      }
      else {
        //FIXME DocumentBuilderIndexedEntity needs to be built by a helper method receiving Class<T> to infer T properly
        //XClass unfortunately is not (yet) genericized: TODO?
        final DocumentBuilderContainedEntity<?> documentBuilder = new DocumentBuilderContainedEntity(
            mappedXClass, context, reflectionManager
        );
        //TODO enhance that, I don't like to expose EntityState
        if ( documentBuilder.getEntityState() != EntityState.NON_INDEXABLE ) {
          documentBuildersContainedEntities.put( mappedClass, documentBuilder );
        }
      }
      bindFilterDefs( mappedXClass );
      //TODO should analyzer def for classes at tyher sqme level???
    }
    analyzers = context.initLazyAnalyzers();
    factory.startDirectoryProviders();
  }
View Full Code Here

  }

  private void initDocumentBuilders(SearchConfiguration cfg, ReflectionManager reflectionManager) {
    InitContext context = new InitContext( cfg );
    Iterator<Class<?>> iter = cfg.getClassMappings();
    DirectoryProviderFactory factory = new DirectoryProviderFactory();

    while ( iter.hasNext() ) {
      Class mappedClass = iter.next();
      if ( mappedClass == null ) {
        continue;
      }
      @SuppressWarnings( "unchecked" )
      XClass mappedXClass = reflectionManager.toXClass( mappedClass );
      if ( mappedXClass == null ) {
        continue;
      }

      if ( mappedXClass.isAnnotationPresent( Indexed.class ) ) {

        if ( mappedXClass.isAbstract() ) {
          log.warn( "Abstract classes can never insert index documents. Remove @Indexed." );
          continue;
        }

        DirectoryProviderFactory.DirectoryProviders providers = factory.createDirectoryProviders(
            mappedXClass, cfg, this, reflectionManager
        );
        //FIXME DocumentBuilderIndexedEntity needs to be built by a helper method receiving Class<T> to infer T properly
        //XClass unfortunately is not (yet) genericized: TODO?
        final DocumentBuilderIndexedEntity<?> documentBuilder = new DocumentBuilderIndexedEntity(
            mappedXClass, context, providers.getProviders(), providers.getSelectionStrategy(),
            reflectionManager
        );

        indexHierarchy.addIndexedClass( mappedClass );
        documentBuildersIndexedEntities.put( mappedClass, documentBuilder );
      }
      else {
        //FIXME DocumentBuilderIndexedEntity needs to be built by a helper method receiving Class<T> to infer T properly
        //XClass unfortunately is not (yet) genericized: TODO?
        final DocumentBuilderContainedEntity<?> documentBuilder = new DocumentBuilderContainedEntity(
            mappedXClass, context, reflectionManager
        );
        //TODO enhance that, I don't like to expose EntityState
        if ( documentBuilder.getEntityState() != EntityState.NON_INDEXABLE ) {
          documentBuildersContainedEntities.put( mappedClass, documentBuilder );
        }
      }
      bindFilterDefs( mappedXClass );
      //TODO should analyzer def for classes at tyher sqme level???
    }
    analyzers = context.initLazyAnalyzers();
    factory.startDirectoryProviders();
  }
View Full Code Here

TOP

Related Classes of org.hibernate.search.store.DirectoryProviderFactory

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.