Search in sources :

Example 1 with APPLICATION_PROTOSTREAM

use of org.infinispan.commons.dataconversion.MediaType.APPLICATION_PROTOSTREAM 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)

Aggregations

Map (java.util.Map)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 AdvancedCache (org.infinispan.AdvancedCache)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 ComponentRegistry (org.infinispan.factories.ComponentRegistry)1 BasicComponentRegistry (org.infinispan.factories.impl.BasicComponentRegistry)1 Matcher (org.infinispan.objectfilter.Matcher)1 ReflectionMatcher (org.infinispan.objectfilter.impl.ReflectionMatcher)1 EntityNameResolver (org.infinispan.objectfilter.impl.syntax.parser.EntityNameResolver)1 ReflectionEntityNamesResolver (org.infinispan.objectfilter.impl.syntax.parser.ReflectionEntityNamesResolver)1 SerializationContext (org.infinispan.protostream.SerializationContext)1 QueryInterceptor (org.infinispan.query.backend.QueryInterceptor)1 ObjectReflectionMatcher (org.infinispan.query.dsl.embedded.impl.ObjectReflectionMatcher)1 SearchMapping (org.infinispan.search.mapper.mapping.SearchMapping)1