All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.infinispan.search.mapper.impl.InfinispanMappingInitiator Maven / Gradle / Ivy

The newest version!
package org.infinispan.search.mapper.impl;

import java.util.Collection;

import org.hibernate.search.engine.mapper.mapping.building.spi.MappingBuildContext;
import org.hibernate.search.engine.mapper.mapping.building.spi.MappingConfigurationCollector;
import org.hibernate.search.mapper.pojo.mapping.building.spi.PojoMapperDelegate;
import org.hibernate.search.mapper.pojo.mapping.building.spi.PojoTypeMetadataContributor;
import org.hibernate.search.mapper.pojo.mapping.spi.AbstractPojoMappingInitiator;
import org.hibernate.search.mapper.pojo.model.spi.PojoBootstrapIntrospector;
import org.infinispan.query.concurrent.FailureCounter;
import org.infinispan.query.impl.IndexerConfig;
import org.infinispan.query.impl.EntityLoaderFactory;
import org.infinispan.search.mapper.mapping.EntityConverter;
import org.infinispan.search.mapper.mapping.MappingConfigurationContext;
import org.infinispan.search.mapper.mapping.ProgrammaticSearchMappingProvider;
import org.infinispan.search.mapper.mapping.impl.InfinispanMapperDelegate;
import org.infinispan.search.mapper.mapping.impl.InfinispanMappingPartialBuildState;
import org.infinispan.util.concurrent.BlockingManager;

public class InfinispanMappingInitiator extends AbstractPojoMappingInitiator
   implements MappingConfigurationContext {

   private final InfinispanTypeConfigurationContributor typeConfigurationContributor;
   private final Collection mappingProviders;
   private final BlockingManager blockingManager;
   private final FailureCounter failureCounter;
   private final IndexerConfig indexerConfig;

   private EntityLoaderFactory entityLoader;
   private EntityConverter entityConverter;

   public InfinispanMappingInitiator(PojoBootstrapIntrospector introspector,
                                     Collection mappingProviders,
                                     BlockingManager blockingManager, FailureCounter failureCounter,
                                     IndexerConfig indexerConfig) {
      super(introspector, InfinispanSearchMapperHints.INSTANCE);
      typeConfigurationContributor = new InfinispanTypeConfigurationContributor(introspector);
      this.indexerConfig = indexerConfig;
      addConfigurationContributor(typeConfigurationContributor);
      this.mappingProviders = mappingProviders;
      this.blockingManager = blockingManager;
      this.failureCounter = failureCounter;
   }

   public void addEntityType(Class type, String entityName) {
      typeConfigurationContributor.addEntityType(type, entityName);
   }

   public void setEntityLoader(EntityLoaderFactory entityLoader) {
      this.entityLoader = entityLoader;
   }

   public void setEntityConverter(EntityConverter entityConverter) {
      this.entityConverter = entityConverter;
   }

   @Override
   public void configure(MappingBuildContext buildContext,
                         MappingConfigurationCollector configurationCollector) {
      super.configure(buildContext, configurationCollector);

      for (ProgrammaticSearchMappingProvider mappingProvider : mappingProviders) {
         mappingProvider.configure(this);
      }
   }

   @Override
   protected PojoMapperDelegate createMapperDelegate() {
      return new InfinispanMapperDelegate(entityLoader, entityConverter, blockingManager, failureCounter, indexerConfig);
   }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy