Search in sources :

Example 1 with ProtoSchemaBuilder

use of org.infinispan.protostream.annotations.ProtoSchemaBuilder 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

IOException (java.io.IOException)1 SerializationContext (org.infinispan.protostream.SerializationContext)1 ProtoSchemaBuilder (org.infinispan.protostream.annotations.ProtoSchemaBuilder)1