/**
  * Registers proto files and marshallers.
  *
  * @param ctx the serialization context
  * @throws org.infinispan.protostream.DescriptorParserException if a proto definition file fails
  *     to parse correctly
  * @throws IOException if proto file registration fails
  */
 public static void registerMarshallers(SerializationContext ctx) throws IOException {
   ctx.registerProtoFiles(FileDescriptorSource.fromResources(PROTOBUF_RES));
   ctx.registerMarshaller(new UserMarshaller());
   ctx.registerMarshaller(new GenderMarshaller());
   ctx.registerMarshaller(new AddressMarshaller());
   ctx.registerMarshaller(new AccountMarshaller());
   ctx.registerMarshaller(new TransactionMarshaller());
 }
  @BeforeClass
  protected void registerProtobufSchema() throws Exception {
    // initialize client-side serialization context
    String authorSchemaFile =
        "/* @Indexed */\n"
            + "message Author {\n"
            + "   required int32 id = 1;\n"
            + "   /* @IndexedField */\n"
            + "   required string name = 2;\n"
            + "}";
    SerializationContext serializationContext =
        ProtoStreamMarshaller.getSerializationContext(remoteCacheManager);
    serializationContext.registerProtoFiles(
        FileDescriptorSource.fromString("author.proto", authorSchemaFile));
    serializationContext.registerMarshaller(
        new MessageMarshaller<Author>() {
          @Override
          public Author readFrom(ProtoStreamReader reader) throws IOException {
            int id = reader.readInt("id");
            String name = reader.readString("name");
            Author author = new Author();
            author.setId(id);
            author.setName(name);
            return author;
          }

          @Override
          public void writeTo(ProtoStreamWriter writer, Author author) throws IOException {
            writer.writeInt("id", author.getId());
            writer.writeString("name", author.getName());
          }

          @Override
          public Class<? extends Author> getJavaClass() {
            return Author.class;
          }

          @Override
          public String getTypeName() {
            return "Author";
          }
        });

    ProtoSchemaBuilder protoSchemaBuilder = new ProtoSchemaBuilder();
    String memoSchemaFile =
        protoSchemaBuilder.fileName("memo.proto").addClass(Memo.class).build(serializationContext);

    // initialize server-side serialization context
    RemoteCache<String, String> metadataCache =
        remoteCacheManager.getCache(ProtobufMetadataManagerConstants.PROTOBUF_METADATA_CACHE_NAME);
    metadataCache.put("author.proto", authorSchemaFile);
    metadataCache.put("memo.proto", memoSchemaFile);
    assertFalse(metadataCache.containsKey(ProtobufMetadataManagerConstants.ERRORS_KEY_SUFFIX));
  }
 @Override
 public QueryBuilder<Query> from(Class entityType) {
   String typeName = serializationContext.getMarshaller(entityType).getTypeName();
   return new RemoteQueryBuilder(this, cache, serializationContext, typeName);
 }
 @Override
 public String getTypeNameById(Integer typeId) {
   return delegate.getTypeNameById(typeId);
 }
 @Override
 public <T> BaseMarshaller<T> getMarshaller(Class<T> clazz) {
   return delegate.getMarshaller(clazz);
 }
 @Override
 public <T> BaseMarshaller<T> getMarshaller(String descriptorFullName) {
   return delegate.getMarshaller(descriptorFullName);
 }
 @Override
 public boolean canMarshall(String descriptorFullName) {
   return delegate.canMarshall(descriptorFullName);
 }
 @Override
 public boolean canMarshall(Class clazz) {
   return delegate.canMarshall(clazz);
 }
 @Override
 public EnumDescriptor getEnumDescriptor(String fullName) {
   return delegate.getEnumDescriptor(fullName);
 }
 @Override
 public Descriptor getMessageDescriptor(String fullName) {
   return delegate.getMessageDescriptor(fullName);
 }
 @Override
 public <T> void registerMarshaller(BaseMarshaller<T> marshaller) {
   delegate.registerMarshaller(marshaller);
 }
 @Override
 public Map<String, FileDescriptor> getFileDescriptors() {
   return delegate.getFileDescriptors();
 }
 @Override
 public Configuration getConfiguration() {
   return delegate.getConfiguration();
 }
 @Override
 public Integer getTypeIdByName(String descriptorFullName) {
   return delegate.getTypeIdByName(descriptorFullName);
 }