Search in sources :

Example 1 with ProtostreamTranscoder

use of org.infinispan.encoding.ProtostreamTranscoder in project infinispan by infinispan.

the class EncoderRegistryFactory method construct.

@Override
public Object construct(String componentName) {
    ClassLoader classLoader = globalConfiguration.classLoader();
    EncoderRegistryImpl encoderRegistry = new EncoderRegistryImpl();
    ClassAllowList classAllowList = embeddedCacheManager.getClassAllowList();
    encoderRegistry.registerEncoder(IdentityEncoder.INSTANCE);
    encoderRegistry.registerEncoder(UTF8Encoder.INSTANCE);
    encoderRegistry.registerEncoder(new JavaSerializationEncoder(classAllowList));
    encoderRegistry.registerEncoder(new GlobalMarshallerEncoder(globalMarshaller.wired()));
    // Default and binary transcoder use the user marshaller to convert data to/from a byte array
    encoderRegistry.registerTranscoder(new DefaultTranscoder(userMarshaller));
    encoderRegistry.registerTranscoder(new BinaryTranscoder(userMarshaller));
    // Core transcoders are always available
    encoderRegistry.registerTranscoder(new ProtostreamTranscoder(ctxRegistry, classLoader));
    encoderRegistry.registerTranscoder(new JavaSerializationTranscoder(classAllowList));
    // Wraps the GlobalMarshaller so that it can be used as a transcoder
    // Keeps application/x-infinispan-marshalling available for backwards compatibility
    encoderRegistry.registerTranscoder(new TranscoderMarshallerAdapter(globalMarshaller.wired()));
    // Make the user marshaller's media type available as well
    // As custom marshaller modules like Kryo and Protostuff do not define their own transcoder
    encoderRegistry.registerTranscoder(new TranscoderMarshallerAdapter(userMarshaller));
    encoderRegistry.registerWrapper(ByteArrayWrapper.INSTANCE);
    encoderRegistry.registerWrapper(IdentityWrapper.INSTANCE);
    return encoderRegistry;
}
Also used : EncoderRegistryImpl(org.infinispan.marshall.core.EncoderRegistryImpl) DefaultTranscoder(org.infinispan.commons.dataconversion.DefaultTranscoder) TranscoderMarshallerAdapter(org.infinispan.commons.dataconversion.TranscoderMarshallerAdapter) ClassAllowList(org.infinispan.commons.configuration.ClassAllowList) BinaryTranscoder(org.infinispan.commons.dataconversion.BinaryTranscoder) JavaSerializationTranscoder(org.infinispan.encoding.impl.JavaSerializationTranscoder) ProtostreamTranscoder(org.infinispan.encoding.ProtostreamTranscoder) GlobalMarshallerEncoder(org.infinispan.commons.dataconversion.GlobalMarshallerEncoder) JavaSerializationEncoder(org.infinispan.commons.dataconversion.JavaSerializationEncoder)

Example 2 with ProtostreamTranscoder

use of org.infinispan.encoding.ProtostreamTranscoder in project infinispan by infinispan.

the class ProtostreamJsonTranscoderTest method setUp.

@BeforeClass(alwaysRun = true)
public void setUp() {
    dataSrc = "{\"_type\":\"Person\", \"name\":\"joe\", \"address\":{\"_type\":\"Address\", \"street\":\"\", \"city\":\"London\", \"zip\":\"0\"}}";
    SerializationContext serCtx = ProtobufUtil.newSerializationContext();
    serCtx.registerProtoFiles(FileDescriptorSource.fromString("person_definition.proto", PROTO_DEFINITIONS));
    SerializationContextRegistry registry = Mockito.mock(SerializationContextRegistry.class);
    Mockito.when(registry.getUserCtx()).thenReturn(serCtx);
    transcoder = new ProtostreamTranscoder(registry, ProtostreamTranscoder.class.getClassLoader());
    supportedMediaTypes = transcoder.getSupportedMediaTypes();
}
Also used : SerializationContext(org.infinispan.protostream.SerializationContext) SerializationContextRegistry(org.infinispan.marshall.protostream.impl.SerializationContextRegistry) ProtostreamTranscoder(org.infinispan.encoding.ProtostreamTranscoder) BeforeClass(org.testng.annotations.BeforeClass)

Example 3 with ProtostreamTranscoder

use of org.infinispan.encoding.ProtostreamTranscoder in project infinispan by infinispan.

the class ProtostreamTranscoderTest method setUp.

@BeforeClass(alwaysRun = true)
public void setUp() {
    dataSrc = " !\"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~";
    SerializationContextRegistry registry = Mockito.mock(SerializationContextRegistry.class);
    Mockito.when(registry.getUserCtx()).thenReturn(ctx);
    transcoder = new ProtostreamTranscoder(registry, ProtostreamTranscoderTest.class.getClassLoader());
    supportedMediaTypes = transcoder.getSupportedMediaTypes();
}
Also used : SerializationContextRegistry(org.infinispan.marshall.protostream.impl.SerializationContextRegistry) ProtostreamTranscoder(org.infinispan.encoding.ProtostreamTranscoder) BeforeClass(org.testng.annotations.BeforeClass)

Aggregations

ProtostreamTranscoder (org.infinispan.encoding.ProtostreamTranscoder)3 SerializationContextRegistry (org.infinispan.marshall.protostream.impl.SerializationContextRegistry)2 BeforeClass (org.testng.annotations.BeforeClass)2 ClassAllowList (org.infinispan.commons.configuration.ClassAllowList)1 BinaryTranscoder (org.infinispan.commons.dataconversion.BinaryTranscoder)1 DefaultTranscoder (org.infinispan.commons.dataconversion.DefaultTranscoder)1 GlobalMarshallerEncoder (org.infinispan.commons.dataconversion.GlobalMarshallerEncoder)1 JavaSerializationEncoder (org.infinispan.commons.dataconversion.JavaSerializationEncoder)1 TranscoderMarshallerAdapter (org.infinispan.commons.dataconversion.TranscoderMarshallerAdapter)1 JavaSerializationTranscoder (org.infinispan.encoding.impl.JavaSerializationTranscoder)1 EncoderRegistryImpl (org.infinispan.marshall.core.EncoderRegistryImpl)1 SerializationContext (org.infinispan.protostream.SerializationContext)1