use of org.infinispan.query.impl.EntityLoader in project infinispan by infinispan.
the class LifecycleManager method cacheStarting.
/**
* Registers the interceptor in the ___protobuf_metadata cache before it gets started. Also creates query components
* for user caches.
*/
@Override
public void cacheStarting(ComponentRegistry cr, Configuration cfg, String cacheName) {
BasicComponentRegistry gcr = cr.getGlobalComponentRegistry().getComponent(BasicComponentRegistry.class);
LocalQueryStatistics queryStatistics = cr.getComponent(LocalQueryStatistics.class);
if (PROTOBUF_METADATA_CACHE_NAME.equals(cacheName)) {
// a protobuf metadata cache is starting, need to register the interceptor
ProtobufMetadataManagerImpl protobufMetadataManager = (ProtobufMetadataManagerImpl) gcr.getComponent(ProtobufMetadataManager.class).running();
protobufMetadataManager.addProtobufMetadataManagerInterceptor(cr.getComponent(BasicComponentRegistry.class));
}
InternalCacheRegistry icr = gcr.getComponent(InternalCacheRegistry.class).running();
if (!icr.isInternalCache(cacheName)) {
// a stop dependency must be added for each non-internal cache
ProtobufMetadataManagerImpl protobufMetadataManager = (ProtobufMetadataManagerImpl) gcr.getComponent(ProtobufMetadataManager.class).running();
protobufMetadataManager.addCacheDependency(cacheName);
// a remote query manager must be added for each non-internal cache
SerializationContext serCtx = protobufMetadataManager.getSerializationContext();
RemoteQueryManager remoteQueryManager = buildQueryManager(cfg, serCtx, cr);
cr.registerComponent(remoteQueryManager, RemoteQueryManager.class);
SearchMappingCommonBuilding commonBuilding = cr.getComponent(SearchMappingCommonBuilding.class);
SearchMapping searchMapping = cr.getComponent(SearchMapping.class);
if (commonBuilding != null && searchMapping == null) {
AdvancedCache<?, ?> cache = cr.getComponent(Cache.class).getAdvancedCache().withStorageMediaType().withWrapping(ByteArrayWrapper.class, ProtobufWrapper.class);
KeyTransformationHandler keyTransformationHandler = ComponentRegistryUtils.getKeyTransformationHandler(cache);
EntityLoader<?> entityLoader = new EntityLoader<>(queryStatistics, cache, keyTransformationHandler);
searchMapping = new LazySearchMapping(commonBuilding, entityLoader, serCtx, cache, protobufMetadataManager);
cr.registerComponent(searchMapping, SearchMapping.class);
BasicComponentRegistry bcr = cr.getComponent(BasicComponentRegistry.class);
bcr.replaceComponent(IndexStatistics.class.getName(), new LocalIndexStatistics(), true);
bcr.rewire();
}
}
}
Aggregations