• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Lock/Unlock on Client side or Server Side

 
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have two questions.
1) I get the unique remotedata object for each client from the server and on the client side, i use a factory that will wrap the RemoteData in to RemoteData Wrapper and Data into localdata wrapper. Is this okay to do it on the client side.
2) I have a method BookFlight in the wrapper on client side that inturn will call remotedata.lock,remotedata.read,remotedata.modify and remotedata.unlock.
or
should I have a method bookflight in remotedata and
from client side simply call remotedata.bookflight and the method bookflight in remote data will inturn call lock,read,modify and unlock.
Please let me know the advantages of both these approches. Are these approaches correct.
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes.
Actually the bookflight is on the "client side" and it calls the lock and unlock on the "remote side" you would want the client to do locking, since also in local mode there is no locking done. So it is the server side that you want to lock.
Did that make sense? I just finished writing it and got a confused look on my face.
Mark
 
Saraswathy Krishnamoorth
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So I should have bookFlight on ClientrSide and call bookFlight on RemoteData that will handle lock-read-modify-unlock. I need not make the client call lock and unlock. Is my understanding correct.
Please clarify.
 
Mark Spritzler
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No, not quite.
What you will have is you have the Data class and you have an interface that has all the public methods of the Data Class, so you have a Remtoe implementation of this interface. You then wrap the interface into a Facade class. The Facade class has the bookFlight method. It is the only class that has the bookFlight method.
So the client calls bookFlight on the Facade class, that class calls the lock, unlock, etc methods on the implementation of the data interface.
Mark
 
Saraswathy Krishnamoorth
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Mark, is this correct.
DataInterface(All public methods of Data) implements Remote.
Data implemens this DataInterface.
RemoteData(remoteImplementation) implements DataInterface. This RemoteData has Data and LockManager as instance variables.
On client side I have a DataAdapter interface which has Bookflight,search etc. methods.
LocalDataAdapter implements DataAdapter and it has Data as Member variable. So LocalDataAdapter's bookFlight method will call Data.read,data.modify.
RemoteDataAdapter implements DataAdapter and it has RemoteData as Member Variable. So RemoteDataAdapter's bookFlight method will call RemoteData.lock,read,modify,unlock.
DataAdapter acts as a Facade. Is this what u meant.
 
Saraswathy Krishnamoorth
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Mark. can u please tell me whether my understanding is correct.
 
Mark Spritzler
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Very close. I have the Data interface being implemented by RemoteDataAccess and Local DataAccess. My interface name is DataAccess, so the client gets a DataAccess class, creates the Facade passing this class, and away it goes.
I just have one less interface than what you wrote. But that doesn't mean that you are completely off base either. I have seen others with two interfaces.
The Facade is still in the db package. But it will be created and object is on the client, meaning it is not residing on the server.
Mark
 
Saraswathy Krishnamoorth
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks a lot Mark.
 
Saraswathy Krishnamoorth
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Mark, I have one more question. DataFacade has a DataInterface object and it has a bookFlight method. Then irrespective of whether it is Local or Network mode, bookFlight method will call lock and unlock. In case of Local Mode we need not call lock and unlock as there will be only one client. (Though Lock and Unlock will be empty in Data). Is it okay to call the empty Lock and unlock implementations in Data (but it is not necessary in Local Mode). That is the reason I had a LocalDataAdapter and RemoteDataAdapter. So in LocalDataAdapter's bookflight method, I just read and modify the record. In RemoteDataAdapter's bookFight method I lock,read,modify and unlock. What is your opinion about this.
[ April 02, 2003: Message edited by: Saraswathy Krishnamoorth ]
 
Mark Spritzler
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Exactly. In local mode it calls an unimplemented lock and unlock methods.
So if you have the DataAccessInterface, it has the lock and unlock methods, then in your two implementing classes. The one implementing class for DataAccessRemote will have code in the lock and unlock methods. But in the one implementing class for DataAccessLocal, the implementation will be blank. Basically it would look like this

Good Luck
Mark
 
Saraswathy Krishnamoorth
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you very much Mark.
 
Sasparilla and fresh horses for all my men! You will see to it, won't you tiny ad?
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic