File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Distributed Java and the fly likes rmi question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Distributed Java
Bookmark "rmi question" Watch "rmi question" New topic
Author

rmi question

zb cong
Ranch Hand

Joined: Jan 14, 2002
Posts: 416
hello
i am now studying rmi programing,in order to simulate distributed environment within one computer,i create two DIRECTORY-server and client,the remote interface and the implementation of the remote interface are put in the server directory,the stub class is put in the server too(because i use "rmic -v1.2",i have not skeleton class),i put the client program in the client directory,the follow question confused me:
1 where can i put the policy file?i found that i need two copies of the same policy
file,one for server,the other one for the client,is that right?
2 i put the stub file in the server,then in client side command,i specify "codebase" to
point to the stub,the program works well,when i open the client directory,there is
not stub class file there,but my book tell me the client will download the stub from
the specified path when it run,where the stub is downloaded?

thanks for any helps!
Michael Ernest
High Plains Drifter
Sheriff

Joined: Oct 25, 2000
Posts: 7292


1 where can i put the policy file?i found that i need two copies of the same policy file,one for server,the other one for the client,is that right?

The policy can be wherever you want it. It's simply a list of restrictions used by the security manager; you can use one policy file for both client and server side, but you should get used to writing a separate policy for each piece.

2 i put the stub file in the server,then in client side command,i specify "codebase" to point to the stub,the program works well,when i open the client directory,there is not stub class file there,but my book tell me the client will download the stub from the specified path when it run,where the stub is downloaded?

It depends on the where the registry tells the client to go. When the registry binds to an instance of the server object, it also assigns the codebase value. If rmiregistry cannot "see" the stub on its own classpath, it will assign the object a codebase specified by the server program.
When the client successfully calls Naming.lookup, it receives a serialized copy of the server object. In order to de-serialize it, it needs to load the stub class, which it tries to find using this codebase value. The client has no need to save a copy of the class file locally -- it just needs to load it into the VM so it can deserialize.


Make visible what, without you, might perhaps never have been seen.
- Robert Bresson
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: rmi question