wood burning stoves 2.0*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Network Mode, Alone Mode and Server mode Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Network Mode, Alone Mode and Server mode" Watch "Network Mode, Alone Mode and Server mode" New topic
Author

Network Mode, Alone Mode and Server mode

Jeffrey Williams
Greenhorn

Joined: Dec 15, 2009
Posts: 14
I have just about finished my implementation of the Bodgitt and Scarper application.

However I have a few questions with the different modes and how they are meant to work.

Obviously the Alone mode is simple the client application starting using the database file locally.

My question relates to the other two modes. Currently I have the server mode simple starting the server application only.

First question is this correct?

Second Network Mode. Here i start the server application first and then the client application in the same JVM. However, if you decide to exit either the Server application or the client application it cause the JVM to terminate closing both applications.

Is this OK?

This is troubling me as I can not see any way where you can connect more than one client to the same server running my app the way it is currently. There is no option to start the client application separately to connect to a server. I have read the instructions and it very clearly says

"The mode flag must be either "server", indicating the server program must run, "alone", indicating standalone mode, or left out entirely, in which case the network client and gui must run."

Have I misread something? Should the user be given the option of local file or network connection when running in alone mode? Is this a design question can I simply just document it in my choices.txt or will this result in failure?




Roberto Perillo
Bartender

Joined: Dec 28, 2007
Posts: 2258
    
    3

Howdy, Jeffrey. Welcome to JavaRanch!

My question relates to the other two modes. Currently I have the server mode simple starting the server application only.

First question is this correct?


Well, yes. In server mode, all your application has to do is start the server, so it is ready to receive connections.

Second Network Mode. Here i start the server application first and then the client application in the same JVM. However, if you decide to exit either the Server application or the client application it cause the JVM to terminate closing both applications.

Is this OK?


Hum... no. They have to be independent from each other, that is, if the server is started, it just receives connections from the clients and deals with the database. If it stops, then the clients connected to it will keep receiving RemoteExceptions, but shouldn't be stoped. If a client exits, then the server must continue running.

This is troubling me as I can not see any way where you can connect more than one client to the same server running my app the way it is currently.

...

Have I misread something? Should the user be given the option of local file or network connection when running in alone mode? Is this a design question can I simply just document it in my choices.txt or will this result in failure?


Champion, it should be pretty simple, actually. In standalone mode, everything is run locally. In server mode, only the server is started and can receive connections from clients. In client mode, a server must be up, so clients can connect to it and execute the operations offered by the server. The server's API will either look similiar to the interface provided by Sun (if you go for a thick client) or will have business methods (if you go for a thin client).

You don't have to give any options in the application when running it in any mode. The flag indicated in the console is how the application should run.
Jeffrey Williams
Greenhorn

Joined: Dec 15, 2009
Posts: 14
Thanks for the help Roberto. So just for clarification.

"Server" mode simply starts the Server GUI and my RMI server. Here closing Server GUI will terminate the JVM.

"Alone" mode we use the file locally there is no server and starts the Client GUI. Here closing Client GUI will terminate the JVM.

You mentioned a "Client mode" this is not mentioned anywhere in my instructions.

I have been reading through the Andrew Monkhouse book and source code and see that he simply has a "NETWORK_CLIENT" and when run in this mode he uses a remote connection. I do not see how this is stared first thou, as it appears my instructions are suggesting?

It is this statement "left out entirely, in which case the network client and gui must run" in the instructions that is confusing me!

As stated I start both the Server GUI and Client Gui in the same JVM. I have a shutdown hook registered when the server is closed or killed to ensure data consistency this hook is registered with the runtime. The clean up will only run if the system exits (System.exit(0)) killing the JVM. Starting both my Client GUI and server in the same JVM will kill both.

With all that said I think I am a bit of a fool, I just re-read that statement after copying it. "network client and gui must run" simply means the client application which is both the network client and the gui. I was reading it as network server and GUI must run. I think that could have been worded a little better. I am assuming this was the point you where trying to make? That makes my code a lot simpler and I can remove a bit of complexity I had built in.

Once again thanks for the help.
Roel De Nijs
Bartender

Joined: Jul 19, 2004
Posts: 5132
    
  12

Hi Jeffrey,

You have 3 different modes your application can run in:
  • java -jar runmejar alone: the standalone application, meaning database and gui run in the same JVM, the networking code must completely be by-passed (and thus not used)
  • java -jar runmejar server: the server application (network mode) is started. Runs a server gui (is not needed) and the rmi server (which will give access to the database)
  • java -jar runmejar: the client application (network mode) is started (in a seperate JVM than the server application) which retrieves a connection from the RMI server and is able to make changes to the database through this connection.


  • When you work in network mode, your server runs on computerA and your client runs on computerB (both in the same network) or could run on the same computer in 2 different JVMs. As network protocol you can choose between RMI or sockets (Denny's DVD has both solutions, which is not necessary for your assignment).

    Kind regards,
    Roel


    SCJA, SCJP (1.4 | 5.0 | 6.0), SCJD
    http://www.javaroe.be/
    Jaime Perez
    Greenhorn

    Joined: Feb 08, 2010
    Posts: 5
    Tnx Roel, this information was useful to me too, because I was thinking like Jeffrey (client and server applications). So, I need to restructure my thoughts to do a good proposal.
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: Network Mode, Alone Mode and Server mode
     
    Similar Threads
    Executable Jar File
    command line parameter
    suncertify.properties question
    commandline argument
    URLyBird 1.2.2 modes