I want to use the following thrift transports on top of each other.
I can only set 1 transport factory in a server, but actually, I have to set the zlib factory and the framed factory. For instance:
new TServer.Args(new TServerSocket(port)).transportFactory(new TFramedTransport.Factory());
How can I set both transports on the server side in Java?
You could create a custom factory that creates the nested transports:
public class MyNestedFactory extends TTransportFactory {
@Override
public TTransport getTransport(TTransport base) {
return new TZlibTransport(new TFramedTransport(base));
}
}
You can then pass this factory to your server args:
new TServer.Args(new TServerSocket(port))
.transportFactory(new MyNestedFactory())