As an answer strictly according to your question, I support the cleitus proposal.
You can also use a token interface (without a method), say DistantCall , with several several sub-interfaces that have the exact signatures you want.
- The common interface will mark all of them if you want to write a common code for them.
- The number of specific interfaces can be reduced with a common cleitus signature.
Examples of reusable interfaces:
public interface DistantCall { } public interface TUDistantCall<T,U> extends DistantCall { T execute(U... us); } public interface UDistantCall<U> extends DistantCall { void execute(U... us); } public interface TDistantCall<T> extends DistantCall { T execute(); } public interface TUVDistantCall<T, U, V> extends DistantCall { T execute(U u, V... vs); } ....
UPDATED in response to OP comment
I did not think of any instance in the call. I thought your calling code knew that it was calling, and you just need to collect some remote calls in a common interface for some kind of common code (for example, to check all remote calls for performance reasons). In your question, I did not notice that the calling code is generic :-(
If so, I suggest you have only one interface, only one signature. A few of them will only bring more complexity, for nothing.
However, you need to ask yourself a few broader questions:
How do you ensure the correct connection between the calling and called subscribers?
This may be a consequence of this question or another question ...
KLE 26 Oct '09 at 8:38 2009-10-26 08:38
source share