Using version specific stub

88 Views Asked by At

My project is based on client and server communication in which at different locations, different version of server may be present. Client, based on nearest server's version number uses specific stub file to communicate with it.

Now, while writing the code, at every place where i'm using the stub, i've to check which version of server is present. This seems very inefficient because there are many places in the code, where i've to check stub version.

The constraint is that exactly one server is present around the client. And once client has started, the server to which it is going to communicate will not change. For communication we are using Jax RPC.

Any suggestions for better design?

1

There are 1 best solutions below

0
On BEST ANSWER

Could dependency injection help here? Isolate all the logic specific to each server version into separate classes and use a tool such as Google Guice to organize all your specific server version classes into their own modules (i.e. one module per server version). Then, only one check would be required at the beginning to see which module to load.