*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Server Design Issue 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 "Server Design Issue" Watch "Server Design Issue" New topic
Author

Server Design Issue

Ramesh kumaar
Ranch Hand

Joined: Mar 19, 2002
Posts: 146
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
Sai Prasad
Ranch Hand

Joined: Feb 25, 2002
Posts: 560
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

Joined: Mar 19, 2002
Posts: 146
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

Joined: Feb 25, 2002
Posts: 560
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

Joined: Mar 19, 2002
Posts: 146
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

Joined: Feb 25, 2002
Posts: 560
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Server Design Issue
 
Similar Threads
DataAccess class for remote/local
FBN GUI
Singleton or static
FBN Architecture Query
Final design