akd5446
akd5446

Reputation: 109

Java RMI and remote file access

I'm just starting to learn Java's RMI, and believe I understand the process, client sends method requests and params, server does computation and sends return result back.

However does the server perform everything within the method locally?

Specifically, if a file is read in the method, am I correct in thinking this is performed by the server?

If this is the case is there any way for the method to specifically access resources from the client (such as the client's System.out?)

Upvotes: 1

Views: 1580

Answers (3)

jtahlborn
jtahlborn

Reputation: 53694

You can use rmiio to easily stream data over rmi. that said i highly doubt you would want to do that with System.out.

Upvotes: 1

cleonf
cleonf

Reputation: 31

If I understand your question, I say yes, your'e correct. By definition the (remote)method runs on the server side. The client just holds a fake object (proxy or stub) that makes the connection to the server, passes the arguments and gets the return value for you.

Think about the client and server running in different machines, there's no way to server knows anything about the client's resources, unless the client acts itself as a server.

Regards

Upvotes: 1

biziclop
biziclop

Reputation: 49744

  1. If by locally, you mean on the server (virtual) machine, the answer is yes.
  2. Yes.
  3. No, only values explicitly passed as arguments to the remote method are accessible. And you can only pass objects which are Serializable, and streams typically aren't.

Having said that, a client can also act as a server, exporting its own remote objects, which can be passed to the (other) server, which can then use that remote object to call the client back.

Upvotes: 2

Related Questions