Search in sources :

Example 11 with SerializationContext

use of org.infinispan.protostream.SerializationContext in project indy by Commonjava.

the class CacheProducer method registerProtoSchema.

public synchronized <K> void registerProtoSchema(Class<K> kClass, String packageName, String fileName) {
    SerializationContext ctx = ProtoStreamMarshaller.getSerializationContext(remoteCacheManager);
    // Use ProtoSchemaBuilder to define a Protobuf schema on the client
    ProtoSchemaBuilder protoSchemaBuilder = new ProtoSchemaBuilder();
    String protoFile;
    try {
        protoFile = protoSchemaBuilder.fileName(fileName).addClass(kClass).packageName(packageName).build(ctx);
    } catch (IOException e) {
        throw new RuntimeException(" Register proto schema error, schema: " + fileName, e);
    }
    // Retrieve metadata cache and register the new schema on the infinispan server too
    RemoteCache<String, String> metadataCache = remoteCacheManager.getCache(PROTOBUF_METADATA_CACHE_NAME);
    metadataCache.put(fileName, protoFile);
}
Also used : SerializationContext(org.infinispan.protostream.SerializationContext) ProtoSchemaBuilder(org.infinispan.protostream.annotations.ProtoSchemaBuilder) IOException(java.io.IOException)

Aggregations

SerializationContext (org.infinispan.protostream.SerializationContext)11 Test (org.junit.Test)6 ByteArrayOutputStream (java.io.ByteArrayOutputStream)5 RawProtoStreamReader (org.infinispan.protostream.RawProtoStreamReader)5 RawProtoStreamWriter (org.infinispan.protostream.RawProtoStreamWriter)5 InfinispanDocument (org.teiid.infinispan.api.InfinispanDocument)4 TeiidTableMarsheller (org.teiid.infinispan.api.TeiidTableMarsheller)4 G2 (org.teiid.translator.marshallers.G2)3 G2Marshaller (org.teiid.translator.marshallers.G2Marshaller)3 G3Marshaller (org.teiid.translator.marshallers.G3Marshaller)3 G4Marshaller (org.teiid.translator.marshallers.G4Marshaller)3 IOException (java.io.IOException)2 RemoteCacheManager (org.infinispan.client.hotrod.RemoteCacheManager)2 ConfigurationBuilder (org.infinispan.client.hotrod.configuration.ConfigurationBuilder)2 ProtoStreamMarshaller (org.infinispan.client.hotrod.marshall.ProtoStreamMarshaller)2 GenderMarshaller (org.infinispan.protostream.sampledomain.marshallers.GenderMarshaller)2 UserMarshaller (org.infinispan.protostream.sampledomain.marshallers.UserMarshaller)2 G1 (org.teiid.translator.marshallers.G1)2 G1Marshaller (org.teiid.translator.marshallers.G1Marshaller)2 KojiTagInfo (com.redhat.red.build.koji.model.xmlrpc.KojiTagInfo)1