You should not have the execute () method on Command sent to the remote server, this is bad in many ways, especially in Java. Command should represent the action the receiver should take. In this case, you need to call the method for some object.
The Command template is intended to represent actions taken or taken, and not to implement these actions. Think more about the set of instructions that you must follow.
What you are describing is basically an RPC invocation mechanism with an add-in. Do not reinvent this wheel. Considers the existing RPC mechanisms, there are many to choose from in the Java world. Then you need to decide whether the RPC is synchronous or asynchronous.
A REST- based API API is something that is popular and lasts longer than an API than any native language-specific mechanism, such as RMI.
Jarrod roberson
source share