aspose file tools*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Local vs. Remote mode Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Local vs. Remote mode" Watch "Local vs. Remote mode" New topic
Author

Local vs. Remote mode

Pauli Wasserman
Greenhorn

Joined: Dec 03, 2001
Posts: 3
Hi!
This is my first post to this forum, but I have read it for a while, and it has been a nice source for hints and tips.
I wonder if my client when running in local mode really is "non-network". It works like this:
I use RMI. My server is a program that extends UnicastRemoteObject and implements a Remote interface. The server has a method called createSession that returns a session object which also is a UnicastRemoteObject. A remote client performs lookup on the server and invokes the createSession method to obtain its session object. From then on, the client performs database actions via this session object. That's how the remote client works.
I have created a console window for the server. That console has a button called "Start local client". When pressing that button, a method in the server program called startLocalClient is invoked. That method runs the createSession method that returns a session object of the same class as described above about the remote client. This session is passed to the clients constructor, so when starting the client this way, no lookup is performed. But the session object is still a UnicastRemoteObject...
I'm about to upload my assignment, but I'm getting a little nervous about this...
Please excuse my bad english.
Trevor Dunn
Ranch Hand

Joined: Jun 13, 2001
Posts: 84
I am not exactly sure how your local mode works, but it seems like you need to have a sever running in order to run in non-networked mode and the client queries the server for its mode. Well if that is true then your client is not a non-networked client and that does not meet the specs.
Even if my understanding is wrong the fact that your session object that extends UnicastRemoteObject is used in non-networked mode breaks the spec because it still a remote object. And if I remember correctly a UnicastRemoteObject when created uses an anonymous port which is a remote operation. Your non-networked mode should have no UnicastRemoteObjects or any thing to do with remote invocation whatsoever

Trevor
Pauli Wasserman
Greenhorn

Joined: Dec 03, 2001
Posts: 3
Hi Trevor!
Yes it's true a server has to be running in order to start a client, be it remote or local. But when starting in local mode, it's the server that starts the client. No lookup is performed.
But if I understand you correctly: Even if I write a "LocalSession" class that doesn't extend UnicastRemoteObject, I break the spec by having the server running, because it is registered in the rmi registry, even if the client is referenced in the server, and thereby it is no networking between the client and server?
Pauli
Trevor Dunn
Ranch Hand

Joined: Jun 13, 2001
Posts: 84
Yes I would think that you are breaking the requirements in the spec. The spec says Non-Networked mode. This means no network code should be executed. In your case you need the server to run before the non-networked client. So essentially you are still dependent on the server. Do not get the terms Local Mode and Non-Networked mode confused. While most people use them interchangeably they can mean different things. In your case the client is running locally on your machine but it is not Non-Networked due to your reliance on the server. Non-Network should mean exactly what is says, no servers, no ports etc.
Anyway that is just my thoughts, I would like to hear from some one else on this also.
Trevor
But if I understand you correctly: Even if I write a "LocalSession" class that doesn't extend UnicastRemoteObject, I break the spec by having the server running, because it is registered in the rmi registry, even if the client is referenced in the server, and thereby it is no networking between the client and server?
Pauli[/B]

Peter den Haan
author
Ranch Hand

Joined: Apr 20, 2000
Posts: 3252
Unfortunately I don't have a copy of the instructions at hand to reread them, but I interpreted the networking requirement in the strictest sense: not only are you not allowed to use networking in local mode, you are not allowed to open any sockets even if you don't make use of them. I think (but am not 100% sure) you can't instantiate a UnicastRemoteObject without opening sockets.
- Peter
Pauli Wasserman
Greenhorn

Joined: Dec 03, 2001
Posts: 3
Hi!
Thanks for your replies. You are right about this. What the spec really says is that the client should be able to run as a stand-alone program without any server.
/Pauli
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Local vs. Remote mode