use of org.infinispan.marshall.core.EncoderRegistry in project infinispan by infinispan.
the class LifecycleManager method buildQuerySerializers.
private QuerySerializers buildQuerySerializers(ComponentRegistry cr, MediaType storageMediaType) {
EncoderRegistry encoderRegistry = cr.getGlobalComponentRegistry().getComponent(EncoderRegistry.class);
QuerySerializers querySerializers = new QuerySerializers();
DefaultQuerySerializer defaultQuerySerializer = new DefaultQuerySerializer(encoderRegistry);
querySerializers.addSerializer(MediaType.MATCH_ALL, defaultQuerySerializer);
if (encoderRegistry.isConversionSupported(storageMediaType, APPLICATION_JSON)) {
Transcoder jsonStorage = encoderRegistry.getTranscoder(APPLICATION_JSON, storageMediaType);
querySerializers.addSerializer(APPLICATION_JSON, new JsonQuerySerializer(storageMediaType, jsonStorage));
}
return querySerializers;
}
use of org.infinispan.marshall.core.EncoderRegistry in project infinispan by infinispan.
the class CacheResourceV2 method negotiateEntryMediaType.
private MediaType negotiateEntryMediaType(AdvancedCache<?, ?> cache, boolean forKey) {
MediaType storage = forKey ? cache.getKeyDataConversion().getStorageMediaType() : cache.getValueDataConversion().getStorageMediaType();
EncoderRegistry encoderRegistry = invocationHelper.getEncoderRegistry();
boolean encodingDefined = !MediaType.APPLICATION_UNKNOWN.equals(storage);
boolean jsonSupported = encodingDefined && encoderRegistry.isConversionSupported(storage, APPLICATION_JSON);
boolean textSupported = encodingDefined && encoderRegistry.isConversionSupported(storage, TEXT_PLAIN);
if (textSupported)
return TEXT_PLAIN;
if (jsonSupported)
return APPLICATION_JSON;
if (encodingDefined)
return storage.withEncoding("hex");
return APPLICATION_OCTET_STREAM.withEncoding("hex");
}
Aggregations