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


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Specifying local and network "mode"" Watch "Specifying local and network "mode"" New topic
Author

Specifying local and network "mode"

James Clarke
Ranch Hand

Joined: Oct 04, 2004
Posts: 148
Hi all,

Currently I have implemented the following for specifying the "mode" the application should run in:

If the user wants to run the server in network mode they start the server and specify the database file location and port. When the client is started the user is prompted for host and port to start the client.

If the user only wants to run the application in local mode they do not need to start the server, only the client need to be started and specify the database location. If the server is started seperately from the client then the two programs will need some way of "contacting" each other. It seemed easier to just have the client instantiate all the objects of the database to get the functionality that a "server" would provide.

Am I on the right track with the above approaches??

Thanks!

James
Alex Belisle Turcot
Ranch Hand

Joined: Apr 26, 2005
Posts: 516
I seems good to me, I'm unsure about your last sentence.

Originally posted by James Clarke:
It seemed easier to just have the client instantiate all the objects of the database to get the functionality that a "server" would provide.


I don't know if you meant that literally or not. The fact that you said it was easier led me to think you might have implemented it twice.

I think both client "alone" mode and "server" should be using the same piece of code accessing the database. The main difference being that the client would not use the "network" path, but direct local access.

Can you elaborate ?

Regards,
Alex
James Clarke
Ranch Hand

Joined: Oct 04, 2004
Posts: 148
Hi,

No I have not implemented it twice. What I meant was:

In network mode:
RoomSocketClient is called which then interacts with RoomDatabase remotely to insert/edit/delete data.

In Local mode:
The client directly interacts with a RoomDatabase object.

Are there alternate ways to implement this?

thanks,

James
Vinicius Florentino
Greenhorn

Joined: Feb 26, 2008
Posts: 16
Hi. I'm doing exacly like you. mode=server start the server. mode=alone starts the client using a localdatabase. if mode=empty start the client to connect with a started server.

I'm using RMI, and with 1 doubt: I need to do a server gui? If not, How can I unexport the object?
Alex Belisle Turcot
Ranch Hand

Joined: Apr 26, 2005
Posts: 516
Originally posted by James Clarke:
Hi,

No I have not implemented it twice. What I meant was:

In network mode:
RoomSocketClient is called which then interacts with RoomDatabase remotely to insert/edit/delete data.

In Local mode:
The client directly interacts with a RoomDatabase object.

Are there alternate ways to implement this?

thanks,

James


OK, that sounds very good to me! Can you tell me why you choose sockets ? Just helping you prepare for your essay exam
Alex Belisle Turcot
Ranch Hand

Joined: Apr 26, 2005
Posts: 516
Originally posted by Vinicius Florentino:
Hi. I'm doing exacly like you. mode=server start the server. mode=alone starts the client using a localdatabase. if mode=empty start the client to connect with a started server.

I'm using RMI, and with 1 doubt: I need to do a server gui? If not, How can I unexport the object?


I used a GUI myself and I chose not to handle crashes. But without a GUI, I think you are right, you need to handle it, since the only way to exit will be CTR-C/Terminate.

Search on the forum for "Shutdown hook":
http://www.coderanch.com/t/187216/java-developer-SCJD/certification/do-you-handle-Exit-network

As I didn't do that, I can't say much about it, but the idea is that you'll be able to execute some logic before the application exits.

bye,
Alex
James Clarke
Ranch Hand

Joined: Oct 04, 2004
Posts: 148
Hi Alex,

The main reason that I used sockets was to understand socket level programing, RMI is an abstracton of sockets so i reasoned that if i can program in sockets RMI would be easy to learn.

thanks,
J.C
Vinicius Florentino
Greenhorn

Joined: Feb 26, 2008
Posts: 16
Hi. Thank you Alex. I forgoted about the "Hook solution". I will use it in my code.
Now, when I start server: Opens a GUI with port and url to edit; alone: User choise database file; without argument: specifie server url and port.

And all that configuration is saved in suncertify.properties file.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Specifying local and network "mode"
 
Similar Threads
Locking
[B&S] Database location
Database location
start client and server
Don't understand mode flag