Meaningless Drivel is fun!*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Did anybody's program can work both locally and remotely at the same time? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Did anybody Watch "Did anybody New topic
Author

Did anybody's program can work both locally and remotely at the same time?

michael opto
Greenhorn

Joined: Jan 17, 2002
Posts: 29
Did anybody's program can work both locally and remotely at the same time? It seemed that I have a problem with the lock method. If I lock a record through a remote client, I still can book tickets through the local client. I am using RMI and the local client just uses a instance of the remote interface implementation.
Thanks in advance!
Sai Prasad
Ranch Hand

Joined: Feb 25, 2002
Posts: 560
You don't have to allow the user to change the mode once it is selected during the application startup. You were able to do it because you may be working with two different instances of Data. But this kind of test is unnecessary.
michael opto
Greenhorn

Joined: Jan 17, 2002
Posts: 29
Thanks Sai. But what I am thinking about is that if an administrator wants to change the database on the server, he can start a client as a local client. He just needs to lock the whole database so that other remotely connected clients can't modify the database. And the remote clients don't need to be disconnected. In this case, the remote clients and the local client are working at the same time.
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17249
    
    6

But what I am thinking about is that if an administrator wants to change the database on the server

You don't need to worry about this, it isn't a requirement.
Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
michael opto
Greenhorn

Joined: Jan 17, 2002
Posts: 29
Mark:
I guess my thought is quite reasonable. Server needs administrator. Please help me think about any solution. My problem is that when I have my Server running, if I start a local client, it seems that this local client is using a different DataServerImpl object from that used by the remote client. So the locks are different too. Is there anything to do with RMI here?
Another thing is: can you tell me why we need singleton?
Thanks.
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17249
    
    6

First local mode would access it's own database and db, no rmi, no server.
Whereas the server remote is on it's own serving other clients, not the one that is running local.
You need to seperate them in your mind. There will never be a time when the server is running with the db.db and at the same time a client local running to the same db.db file.
You do not need Singleton in this assignment.

Mark
michael opto
Greenhorn

Joined: Jan 17, 2002
Posts: 29
Mark:
Could you take a look at my design? My design is very simple. No lock manager, no Facade. It works. But I don't know if I miss anything. Maybe need more work on the Server class.
Thanks.
DB:
Data{
//implements the lock, unlock, and search methods here
}
Server side:
DataRemote extends Remote{
//defines all the public methods in Data and other own-designed methods
}
DataRemoteImpl implements DataRemote{
//RMI implementation
//forword mothods to Data
}
Server{
//get the instance of DataRemoteImpl and export it;
//rebind it to the rmiregistry
//need anything else here?
}
Client side:
Client{
//GUI
//invoke methods on DataServer returned by a Factory
}
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17249
    
    6

I really think you should look into the Facade class, it isn't very difficult to create. As a matter of fact you already have the methods written, it is just in your client code.
The reason I say this, is because say latter down the road they go with a different database scheme, but then that would mean you need to change the client code. But with the Facade, you just need to change it, and the client stays the same.
What about your design for Local mode?
Mark
michael opto
Greenhorn

Joined: Jan 17, 2002
Posts: 29
Let me specify a little about my design. All the real work is handled at the server side. The client has no idea what the database is. The client only knows the DataServer which knows the Data that deals with the database. Do you mean that I need to change the Data class? But how?
If the client is in local mode, the DataServer object at the client side is actually a DataServerImpl instance. Although it implements Remote, since Remote is just an interface without any method, I assume there is little overhead. But is it a neat design or a complicated one? What do you think?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Did anybody's program can work both locally and remotely at the same time?
 
Similar Threads
Accessing ejb's with local home and remote interfaces
EJB Question
Please help me feel confident with my design ...
An EJB can be local and remote at the same time
Extending an EJB