use of org.infinispan.search.mapper.mapping.ProgrammaticSearchMappingProvider in project infinispan by infinispan.
the class LifecycleManager method createSearchMapping.
private SearchMapping createSearchMapping(LocalQueryStatistics queryStatistics, IndexingConfiguration indexingConfiguration, Map<String, Class<?>> indexedClasses, ComponentRegistry cr, AdvancedCache<?, ?> cache, KeyTransformationHandler keyTransformationHandler, ClassLoader aggregatedClassLoader) {
SearchMapping searchMapping = cr.getComponent(SearchMapping.class);
if (searchMapping != null && !searchMapping.isClose()) {
// a paranoid check against an unlikely failure
throw new IllegalStateException("SearchIntegrator already initialized!");
}
GlobalConfiguration globalConfiguration = cr.getGlobalComponentRegistry().getGlobalConfiguration();
// load ProgrammaticSearchMappingProviders from classpath
Collection<ProgrammaticSearchMappingProvider> mappingProviders = ServiceFinder.load(ProgrammaticSearchMappingProvider.class, aggregatedClassLoader);
SearchMappingCommonBuilding commonBuilding = new SearchMappingCommonBuilding(KeyTransformationHandlerIdentifierBridge.createReference(keyTransformationHandler), extractProperties(globalConfiguration, indexingConfiguration, aggregatedClassLoader), aggregatedClassLoader, mappingProviders);
Set<Class<?>> types = new HashSet<>(indexedClasses.values());
if (!types.isEmpty()) {
// use the common builder to create the mapping now
SearchMappingBuilder builder = commonBuilding.builder(SearchMappingBuilder.introspector(MethodHandles.lookup()));
builder.setEntityLoader(new EntityLoader<>(queryStatistics, cache, keyTransformationHandler));
builder.addEntityTypes(types);
searchMapping = builder.build();
cr.registerComponent(searchMapping, SearchMapping.class);
}
if (searchMapping == null) {
// register the common builder to create the mapping at a later time
cr.registerComponent(commonBuilding, SearchMappingCommonBuilding.class);
}
return searchMapping;
}
Aggregations