public static SerializationContext newSerializationContext(Configuration configuration) { SerializationContextImpl serializationContext = new SerializationContextImpl(configuration); try { serializationContext.registerProtoFiles(FileDescriptorSource.fromResources(WRAPPING_DEFINITIONS_RES)); } catch (IOException | DescriptorParserException e) { throw new RuntimeException("Failed to initialize serialization context", e); } serializationContext.registerMarshaller(new WrappedMessage.Marshaller()); return serializationContext; }
@Override public void init(SerializationContext serializationContext) throws IOException { serializationContext.registerProtoFiles(FileDescriptorSource.fromResources(ServerCtxInitializer.class.getClassLoader(), "/sample_bank_account/bank.proto")); serializationContext.registerMarshaller(new UserMarshaller()); serializationContext.registerMarshaller(new GenderMarshaller()); } }
public CustomProtoStreamMarshaller() throws IOException { SerializationContext serCtx = getSerializationContext(); serCtx.registerProtoFiles(FileDescriptorSource.fromResources(CustomProtoStreamMarshaller.class.getClassLoader(), "/sample_bank_account/bank.proto")); serCtx.registerMarshaller(new UserMarshaller()); serCtx.registerMarshaller(new GenderMarshaller()); } }
public static void registerMarshallers(SerializationContext ctx) throws IOException, DescriptorParserException { 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 LimitsMarshaller()); ctx.registerMarshaller(new TransactionMarshaller()); } }