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);
}
Aggregations