aspose file tools*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes local server 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 "local server" Watch "local server" New topic
Author

local server

Carol Tsao
Greenhorn

Joined: Aug 06, 2002
Posts: 7
After I read the requirement, I found the startup got two mode: remote and local. If it is in local mode, do I need to implement a local server? Because it sounds strange to me.
Thank you
Mag Hoehme
Ranch Hand

Joined: Apr 07, 2002
Posts: 194
Hi Carol,
there are a number of ways to tackle this task.
First of all: the instructions say "no sockets must be opened" - that means, you don't have any server at all (not even a local one).
There issue of opening sockets or not is regularly discussed in this forum.


Mag
Carol Tsao
Greenhorn

Joined: Aug 06, 2002
Posts: 7
I chose to use RMI. If it is local model, do I need to run the RMI registry in localhost? If I don't use RMI for local model, it is meaningless to use a server. Is my understanding right?
friso dejonge
Ranch Hand

Joined: Jul 11, 2002
Posts: 162
I chose to use RMI. If it is local model, do I need to run the RMI registry in localhost? If I don't use RMI for local model, it is meaningless to use a server. Is my understanding right?

True, you only need the server if you are working in server mode.
If you use local mode, just call the data, datainfo and fieldinfo classes directly. It is true that in that case you need two databases and they are getting out of synch (one for local and one for remote), but that is the nature of the implementation. The requirement only asks to implement both so they can see you problem solving ability. (and to see use of design patterns)
In your case, for this problem, take a look at the factory pattern. One interface and two classes implementing this interface. One of the classes calls remote data methods via the server.
The other class calls local data class.
Since both of the classes implement the interface you can always call either of them through the interface methods. Please read the factory design pattern in a good book or search for it on this site.
hope this helps,
friso


swimming certificate (A & B), shoelaces diploma, and some useless java ones.
Carol Tsao
Greenhorn

Joined: Aug 06, 2002
Posts: 7
Thanks, Friso
I got it.
Andrea Gazzarini
Ranch Hand

Joined: Sep 09, 2002
Posts: 125
Hello Carol,
The instructions.html says : "The client and the server run in the same JVM"... It means there isn't a server (no networking, no "localhost", no server), but only a local database. The entire application run by typing one "java MyAppClient" command.


Regards,<br />Andrea<br /> <br /><a href="http://www.linkedin.com/in/andreagazzarini" target="_blank" rel="nofollow">Andrea Gazzarini</a><br />Skype ID : gazzax72<br />Google Talk ID : a.gazzarini@gmail.com<br /><a href="http://www.andreagazzarini.blogspot.com" target="_blank" rel="nofollow">My Blog</a>
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17249
    
    6

"Gazzax"-
Welcome to the JavaRanch! Please adjust your displayed name to meet the
JavaRanch Naming Policy.
You can change it
here.
Thanks! and welcome to the JavaRanch!
Mark
This is your second notice.


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Mag Hoehme
Ranch Hand

Joined: Apr 07, 2002
Posts: 194
Originally posted by Carol Tsao:
I chose to use RMI. If it is local model, do I need to run the RMI registry in localhost? If I don't use RMI for local model, it is meaningless to use a server. Is my understanding right?


So in local mode you have to cirumvent RMI somehow.
I try to do this by not having my server extending UnicastRemoteObject, but doing the exporting explicitly (in remote mode only). In local mode I'm creating the object with a new operator.
Thomas Fly
Ranch Hand

Joined: Sep 09, 2002
Posts: 164
To implement RMI, you must have an interface that extends java.rmi.Remote (e.g., remoteDatabase), and then you must implement that interface (remoteDatabaseImpl).
All remoteDatabaseImpl has to do (at least if you're not yet worried about locking) is pass on the calls to Data; in other words, it follows the Adapter design pattern.
It may not be the best approach ultimately, but for the moment, I have an "Object db" that's either of type Data or type remoteDatabaseImpl, depending upon what mode is being used (I've made it dynamically switchable, using radioButtonMenuItem's, and have the RMI server running on a laptop on my LAN, just for fun).
Either way, db.criteriaFind searches the database.


Fly by Night Consultants<br /> <blockquote><font size="1" face="Verdana, Arial">quote:</font><hr><i>I climbed on the back of a giant albatross<br />which flew through a crack in the cloud<br />to a place where happiness reigned...<br />all year 'round<br />the music played ever so loudly!</i><p><a href="http://thomasfly.com/songs/Traffic/Hole_in_my_Shoe_qt.htm" target="_blank" rel="nofollow">Hole in My Shoe</a><hr></blockquote>
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: local server
 
Similar Threads
Client/Server Design
database connection local and network
Local mode == one client?
Help With Interface
execution arguments