*/
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.getProviders(), providers.getSelectionStrategy(),
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 tyher sqme level???
}
factoryState.setAnalyzers( context.initLazyAnalyzers() );
factory.startDirectoryProviders();
}