private static AnalyzerReference luceneAnalyzerReferenceFromDefinition( org.hibernate.search.annotations.Analyzer analyzerAnn, ConfigContext configContext) { String definition = analyzerAnn == null ? "" : analyzerAnn.definition(); if (StringHelper.isEmpty(definition)) { return null; } return configContext.buildLazyLuceneAnalyzerReference(definition); }
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); } }