What are the advantages and disadvantages of RMI?
Explain the advantages and disadvantages of RMI. - It is possible to create zero-install client for the users. - At the time of changing the database, only the server objects are to be recompiled but not the server interface and the client remain the same. Disadvantages of RMI: - Less efficient than Socket objects.
Java Remote Method Invocation (RMI) allows you to write distributed objects using Java. This paper describes the benefits of RMI, and how you can connect it to existing and legacy systems as well as to components written in Java. RMI provides a simple and direct model for distributed computation with Java objects.
The Java Remote Method Invocation (RMI) system allows an object running in one Java virtual machine to invoke methods on an object running in another Java virtual machine. RMI provides for remote communication between programs written in the Java programming language.
A security vulnerability in the Remote Method Invocation component of the Java Runtime Environment allows unauthenticated network attacks which can result in unauthorized operating system takeover including arbitrary code execution.
The advantages and disadvantages are similar to those of any RPC-like (Remote Procedure Call) System. There is a superficial appearance of simplicity, because it objects which are in fact remote can be treated as though they were local.
This would seem like a great benefit to simplicity of programming, but there are hidden costs. Distributed systems have issues of latency and potential for partial failure which the programmer has to be aware of. An invocation of a remote method is subject to potential failure from security, latency problems, network failure, etc. Papering over these sorts of problems can be a disaster for reliability.
From my experience:
Pros:
You can implement two interfaces like that:
Common task interface:
public interface Task<T extends Serializable> extends Serializable {
T execute();
}
Rmi interface:
public interface RmiTask extends Remote {
<T extends Serializable> T executeTask(Task<T> task) throws RemoteException;
}
RmiTask
implementation on server side:
public class RmiTaskExecutor implements RmiTask {
public <T extends Serializable> T executeTask(Task<T> task) {
return task.execute();
}
}
Example client Task
implementation:
public class IsFileTask implements Task<Boolean> {
final String path;
public IsFileTask(String path) {
this.path = path;
}
public Boolean execute() {
return new File(path).isFile();
}
}
Cons:
method()
on PassedObject
, but marvellous client could override this method and execute whatever he wants there...Callable
s and run them with defined timeouts).If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With