Search in sources :

Example 1 with ReflectionEntityNamesResolver

use of org.infinispan.objectfilter.impl.syntax.parser.ReflectionEntityNamesResolver in project infinispan by infinispan.

the class ObjectRemoteQueryManager method createEntityNamesResolver.

private EntityNameResolver<Class<?>> createEntityNamesResolver(MediaType mediaType) {
    if (mediaType.match(APPLICATION_PROTOSTREAM)) {
        return new ProtobufEntityNameResolver(serCtx);
    } else {
        ClassLoader classLoader = cr.getGlobalComponentRegistry().getComponent(ClassLoader.class);
        ReflectionEntityNamesResolver reflectionEntityNamesResolver = new ReflectionEntityNamesResolver(classLoader);
        if (searchMapping != null) {
            // If indexing is enabled then use the declared set of indexed classes for lookup but fallback to global classloader.
            QueryInterceptor queryInterceptor = cr.getComponent(QueryInterceptor.class);
            Map<String, Class<?>> indexedEntities = queryInterceptor.indexedEntities();
            return name -> {
                Class<?> c = indexedEntities.get(name);
                if (c == null) {
                    c = reflectionEntityNamesResolver.resolve(name);
                }
                return c;
            };
        }
        return reflectionEntityNamesResolver;
    }
}
Also used : ReflectionEntityNamesResolver(org.infinispan.objectfilter.impl.syntax.parser.ReflectionEntityNamesResolver) QueryInterceptor(org.infinispan.query.backend.QueryInterceptor) SearchMapping(org.infinispan.search.mapper.mapping.SearchMapping) APPLICATION_PROTOSTREAM(org.infinispan.commons.dataconversion.MediaType.APPLICATION_PROTOSTREAM) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) ReflectionMatcher(org.infinispan.objectfilter.impl.ReflectionMatcher) ComponentRegistry(org.infinispan.factories.ComponentRegistry) EntityNameResolver(org.infinispan.objectfilter.impl.syntax.parser.EntityNameResolver) BasicComponentRegistry(org.infinispan.factories.impl.BasicComponentRegistry) MediaType(org.infinispan.commons.dataconversion.MediaType) AdvancedCache(org.infinispan.AdvancedCache) Matcher(org.infinispan.objectfilter.Matcher) APPLICATION_OBJECT(org.infinispan.commons.dataconversion.MediaType.APPLICATION_OBJECT) Map(java.util.Map) ReflectionEntityNamesResolver(org.infinispan.objectfilter.impl.syntax.parser.ReflectionEntityNamesResolver) ObjectReflectionMatcher(org.infinispan.query.dsl.embedded.impl.ObjectReflectionMatcher) SerializationContext(org.infinispan.protostream.SerializationContext) QueryInterceptor(org.infinispan.query.backend.QueryInterceptor)

Example 2 with ReflectionEntityNamesResolver

use of org.infinispan.objectfilter.impl.syntax.parser.ReflectionEntityNamesResolver in project infinispan-quarkus by infinispan.

the class Target_SearchQueryMaker method cacheStarting.

@Substitute
public void cacheStarting(ComponentRegistry cr, Configuration cfg, String cacheName) {
    if (cfg.indexing().enabled()) {
        Util.unsupportedOperationException("Indexing", "Cache " + cacheName + " has it enabled!");
    }
    InternalCacheRegistry icr = cr.getGlobalComponentRegistry().getComponent(InternalCacheRegistry.class);
    if (!icr.isInternalCache(cacheName) || icr.internalCacheHasFlag(cacheName, InternalCacheRegistry.Flag.QUERYABLE)) {
        AdvancedCache<?, ?> cache = cr.getComponent(Cache.class).getAdvancedCache();
        cr.registerComponent(ObjectReflectionMatcher.create(new ReflectionEntityNamesResolver(getClass().getClassLoader()), null), ObjectReflectionMatcher.class);
        cr.registerComponent(new QueryEngine<>(cache, false), QueryEngine.class);
    }
}
Also used : ReflectionEntityNamesResolver(org.infinispan.objectfilter.impl.syntax.parser.ReflectionEntityNamesResolver) InternalCacheRegistry(org.infinispan.registry.InternalCacheRegistry) Cache(org.infinispan.Cache) AdvancedCache(org.infinispan.AdvancedCache) Substitute(com.oracle.svm.core.annotate.Substitute)

Example 3 with ReflectionEntityNamesResolver

use of org.infinispan.objectfilter.impl.syntax.parser.ReflectionEntityNamesResolver in project infinispan by infinispan.

the class LifecycleManager method cacheStarting.

/**
 * Registers the Search interceptor in the cache before it gets started
 */
@Override
public void cacheStarting(ComponentRegistry cr, Configuration cfg, String cacheName) {
    InternalCacheRegistry icr = cr.getGlobalComponentRegistry().getComponent(InternalCacheRegistry.class);
    LocalQueryStatistics queryStatistics = cr.getComponent(LocalQueryStatistics.class);
    if (!icr.isInternalCache(cacheName) || icr.internalCacheHasFlag(cacheName, Flag.QUERYABLE)) {
        AdvancedCache<?, ?> cache = cr.getComponent(Cache.class).getAdvancedCache();
        SecurityActions.addCacheDependency(cache.getCacheManager(), cacheName, QueryCache.QUERY_CACHE_NAME);
        ClassLoader aggregatedClassLoader = makeAggregatedClassLoader(cr.getGlobalComponentRegistry().getGlobalConfiguration().classLoader());
        boolean isIndexed = cfg.indexing().enabled();
        SearchMapping searchMapping = null;
        if (isIndexed) {
            Map<String, Class<?>> indexedClasses = makeIndexedClassesMap(cache);
            KeyTransformationHandler keyTransformationHandler = new KeyTransformationHandler(aggregatedClassLoader);
            cr.registerComponent(keyTransformationHandler, KeyTransformationHandler.class);
            for (Map.Entry<Class<?>, Class<?>> kt : cfg.indexing().keyTransformers().entrySet()) {
                keyTransformationHandler.registerTransformer(kt.getKey(), (Class<? extends Transformer>) kt.getValue());
            }
            searchMapping = createSearchMapping(queryStatistics, cfg.indexing(), indexedClasses, cr, cache, keyTransformationHandler, aggregatedClassLoader);
            createQueryInterceptorIfNeeded(cr, cfg, cache, indexedClasses);
            Indexer massIndexer = new DistributedExecutorMassIndexer(cache);
            cr.registerComponent(massIndexer, Indexer.class);
            if (searchMapping != null) {
                BasicComponentRegistry bcr = cr.getComponent(BasicComponentRegistry.class);
                bcr.replaceComponent(IndexStatistics.class.getName(), new LocalIndexStatistics(), true);
                bcr.rewire();
            }
        }
        cr.registerComponent(ObjectReflectionMatcher.create(new ReflectionEntityNamesResolver(aggregatedClassLoader), searchMapping), ObjectReflectionMatcher.class);
        cr.registerComponent(new QueryEngine<>(cache, isIndexed), QueryEngine.class);
    }
}
Also used : ReflectionEntityNamesResolver(org.infinispan.objectfilter.impl.syntax.parser.ReflectionEntityNamesResolver) SearchMapping(org.infinispan.search.mapper.mapping.SearchMapping) LocalIndexStatistics(org.infinispan.query.stats.impl.LocalIndexStatistics) InternalCacheRegistry(org.infinispan.registry.InternalCacheRegistry) DistributedExecutorMassIndexer(org.infinispan.query.impl.massindex.DistributedExecutorMassIndexer) LocalIndexStatistics(org.infinispan.query.stats.impl.LocalIndexStatistics) IndexStatistics(org.infinispan.query.core.stats.IndexStatistics) BasicComponentRegistry(org.infinispan.factories.impl.BasicComponentRegistry) DistributedExecutorMassIndexer(org.infinispan.query.impl.massindex.DistributedExecutorMassIndexer) Indexer(org.infinispan.query.Indexer) KeyTransformationHandler(org.infinispan.query.backend.KeyTransformationHandler) AggregatedClassLoader(org.infinispan.commons.util.AggregatedClassLoader) LocalQueryStatistics(org.infinispan.query.core.stats.impl.LocalQueryStatistics) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) ConcurrentMap(java.util.concurrent.ConcurrentMap) Cache(org.infinispan.Cache) QueryCache(org.infinispan.query.core.impl.QueryCache) AdvancedCache(org.infinispan.AdvancedCache)

Aggregations

AdvancedCache (org.infinispan.AdvancedCache)3 ReflectionEntityNamesResolver (org.infinispan.objectfilter.impl.syntax.parser.ReflectionEntityNamesResolver)3 Map (java.util.Map)2 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)2 Cache (org.infinispan.Cache)2 BasicComponentRegistry (org.infinispan.factories.impl.BasicComponentRegistry)2 InternalCacheRegistry (org.infinispan.registry.InternalCacheRegistry)2 SearchMapping (org.infinispan.search.mapper.mapping.SearchMapping)2 Substitute (com.oracle.svm.core.annotate.Substitute)1 HashMap (java.util.HashMap)1 ConcurrentMap (java.util.concurrent.ConcurrentMap)1 MediaType (org.infinispan.commons.dataconversion.MediaType)1 APPLICATION_OBJECT (org.infinispan.commons.dataconversion.MediaType.APPLICATION_OBJECT)1 APPLICATION_PROTOSTREAM (org.infinispan.commons.dataconversion.MediaType.APPLICATION_PROTOSTREAM)1 AggregatedClassLoader (org.infinispan.commons.util.AggregatedClassLoader)1 ComponentRegistry (org.infinispan.factories.ComponentRegistry)1 Matcher (org.infinispan.objectfilter.Matcher)1 ReflectionMatcher (org.infinispan.objectfilter.impl.ReflectionMatcher)1 EntityNameResolver (org.infinispan.objectfilter.impl.syntax.parser.EntityNameResolver)1 SerializationContext (org.infinispan.protostream.SerializationContext)1