• 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

Server Design Issue

 
Ranch Hand
Posts: 146
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear All,
In my remote DB i do the following :
RemoteDataAccess(String file)
throws IO,RemoteException{
// DataAccess instantiate Data class in its constructor
db=new DataAccess(file);
// LockMgr extends Data and calls super(file) which will call the Data(file);
lockMgr=new LockMgr(file);
}
Here I use db for Database access in the remote implementation, I use the lockMgr object for recordLocking is it OK.
Its seems to be two instance of Data class is created here Please help to over come this problem
regards,
-rameshkumar
 
Ranch Hand
Posts: 560
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ramesh,
Association is the norm compared to inheritance. Is LockManager a special version of Data? Is LockManager a kind of Data? I don't think so. You need to associate the LockManager to the Data instance and remove the inheritance. This will clear up your issues a lot.
 
Ramesh kumaar
Ranch Hand
Posts: 146
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Prasad,

Thanks. Please go through this and give me ur valuable feedback.
I like to explain my design so that u can help me more. I have my criteriaFind() in the Data class itself, Incase of locking i have a LockMgr class which is a subclass of Data.
I have a DataInterface which has all the public methods of Data class, DataAccess.java this class implements DataInterface, this is used to access the database locally. This class INSTANTIALTES Data class here i dont have the lockMgr instance at all.
I have a RemoteDataInterface which extends DataInterface and Remote Interface. which is used for remotedata access.
The above interface is implemented in my RemoteDataAccess. In this class i have the instance of both DataAccess(database access), LockMgr(for performing lock and unlock) which iam not sure.
I have an idea of changing the LockMgr name as RemoteData.java and use it in my RemoteDataAccess and ignore DataAccess there.
Please guide me to proceed further.
thanks & regards,
rameshkumar
 
Sai Prasad
Ranch Hand
Posts: 560
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ramesh,
1) No need for the LockManager to extend Data. You need to define only lock,unlock,modify and delete methods in the LockManager. It is responsible to make sure only one client can manipuate a record at any given moment. It doesn't know about files and data structures. Think about encapsulation and clear seperation of responsibilities.
2) You don't need to define the LockManager as the member of RemoteDataAccess class. You have two options. You can either make the LockManager singleton to handle the locking for all the database files. Or you can write a Factory class to return you a Singleton LockManager related to a database file. You will use the LockManager from the RemoteDataAccess object for the methods mentioned above.
3) You can leave the lock/unlock methods empty in the DataAccess class and use it for both local and remote invocations.
Apart from the classes you have mentioned, you need a Facade, proxy and a DataFactory in the client side. Take a look at this flow:
Controller -> DataFacade -> DataProxy(returned by DataFactory) ->_Stub ( For remote access )
Controller -> DataFacade -> DataProxy(returned by the DataFactory) -> Data (For local access )
Hope that helps.
 
Ramesh kumaar
Ranch Hand
Posts: 146
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Prasad,
Thanks for ur immediate response, As u said i now i have implemented singelton, In the clientside I have controller, factory, facade classes. But i dont know how to implement factory in the server side iam not able to understand the need of it.
I have an idea of changing the LockMgr's name as RemoteData which will have the same functionalities as earlier(lock and unlock), I will use this class as Data referance for RemoteDataAccess. Please comment on this change so that i will finalize the server design.
thanks & regards,
rameshkumar.km
 
Sai Prasad
Ranch Hand
Posts: 560
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You implement the Factory on the server side to return you the correct Data instance by giving the filename. In the future this application may contain more files and so more instances of Data representing the different db files.
I wouldn't rename the LockManager.
 
reply
    Bookmark Topic Watch Topic
  • New Topic