public static DirectoryProvider<?> createDirectoryProvider(
      String directoryProviderName, Properties indexProps, WorkerBuildContext context) {
    String className = indexProps.getProperty("directory_provider", "");
    String maybeShortCut = className.toLowerCase();

    DirectoryProvider<?> provider;
    // try and use the built-in shortcuts before loading the provider as a fully qualified class
    // name
    if (defaultProviderClasses.containsKey(maybeShortCut)) {
      String fullClassName = defaultProviderClasses.get(maybeShortCut);
      provider =
          ClassLoaderHelper.instanceFromName(
              DirectoryProvider.class,
              fullClassName,
              DirectoryProviderFactory.class,
              "directory provider");
    } else {
      provider =
          ClassLoaderHelper.instanceFromName(
              DirectoryProvider.class,
              className,
              DirectoryProviderFactory.class,
              "directory provider");
    }
    try {
      provider.initialize(directoryProviderName, indexProps, context);
    } catch (Exception e) {
      throw new SearchException(
          "Unable to initialize directory provider: " + directoryProviderName, e);
    }
    return provider;
  }
 private boolean isPresent(String className) {
   try {
     ClassLoaderHelper.classForName(className, serviceManager);
     return true;
   } catch (Exception e) {
     return false;
   }
 }
 /**
  * Initializes the default Lucene analyzer reference to use by reading the analyzer class from the
  * configuration and instantiating it.
  *
  * @param cfg The current configuration.
  * @return The default Lucene analyzer reference to use for tokenization.
  */
 @SuppressWarnings("unchecked")
 private AnalyzerReference initDefaultLuceneAnalyzerReference(SearchConfiguration cfg) {
   Class<? extends Analyzer> analyzerClass;
   String analyzerClassName = cfg.getProperty(Environment.ANALYZER_CLASS);
   if (analyzerClassName != null) {
     try {
       analyzerClass = ClassLoaderHelper.classForName(analyzerClassName, serviceManager);
     } catch (Exception e) {
       return buildLazyLuceneAnalyzerReference(analyzerClassName);
     }
   } else {
     analyzerClass = StandardAnalyzer.class;
   }
   Analyzer analyzer =
       ClassLoaderHelper.analyzerInstanceFromClass(analyzerClass, luceneMatchVersion);
   AnalyzerReference reference = new LuceneAnalyzerReference(analyzer);
   return reference;
 }
 public static BoostStrategy getDynamicBoost(final XAnnotatedElement element) {
   if (element == null) {
     return DefaultBoostStrategy.INSTANCE;
   }
   DynamicBoost boostAnnotation = element.getAnnotation(DynamicBoost.class);
   if (boostAnnotation == null) {
     return DefaultBoostStrategy.INSTANCE;
   }
   Class<? extends BoostStrategy> boostStrategyClass = boostAnnotation.impl();
   return ClassLoaderHelper.instanceFromClass(
       BoostStrategy.class, boostStrategyClass, "boost strategy");
 }
 private static AnalyzerReference luceneAnalyzerReferenceFromClass(
     ConfigContext configContext, Class<?> analyzerClass) {
   try {
     // For now only local analyzer can be created from a class
     // this should be easy to extend to remote analyzer using a common interface/super-class
     Analyzer analyzer =
         ClassLoaderHelper.analyzerInstanceFromClass(
             analyzerClass, configContext.getLuceneMatchVersion());
     AnalyzerReference reference = new LuceneAnalyzerReference(analyzer);
     return reference;
   } catch (ClassCastException e) {
     throw new SearchException(
         "Lucene analyzer does not extend "
             + Analyzer.class.getName()
             + ": "
             + analyzerClass.getName(),
         e);
   } catch (Exception e) {
     throw new SearchException(
         "Failed to instantiate lucene analyzer with type " + analyzerClass.getName(), e);
   }
 }