• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Question about Connection Object

 
Holmes Wong
Ranch Hand
Posts: 163
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, ranchers:
I have trouble to understand Connection Object some people talked about in earlier posts. I have designed the following to track client ID to do lock/unlock, but please clear any thing that does not make sense and modify my design to make things clearer for me. Thanks.
In order to track Client ID, we have to create one connection object for one client. So, I need to bind my ConnectionFactory (extends UnicastRemoteObject) to RMI. I have LocalDataAccess for local mode and RemoteDataAccess (extends UnicastRemoteObject and implements DataInterface) for remote mode. DataAccessFactory will use getConnection method in ConnectionFactory to get a connection for remote clients, and it also handles local client
accesses.
LockManager will be defined in a separate class in server package (since only remote accesses need them), record number and reference to RemoteDataAccess.
reference will be passed to lock/unlock methods.
I have many doubts about this design, please clarify it for me:
(1) My design with two factories make sense?
(2)Where is the best place to put lock manager? In server package, or in Data class?
[ June 12, 2002: Message edited by: Holmes Wong ]
 
Sai Prasad
Ranch Hand
Posts: 560
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
(1) Since DataAccessFactory take care of both local/remote accesses, is it a good idead to bind
this object? I only need lock/unlock for remote accesses, how to avoid this while creatind one access for one client?
You call DataAccessFactory only when the user selects remote mode. For local mode, you create an instance of the Data class at the client level.
You need to bind the DataAccessFactory to the RMI Registry.
(2)Where is the best place to put lock manager? In server package, or in Data class?
A seperate class in the server package.
 
Holmes Wong
Ranch Hand
Posts: 163
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, Sai for quick reply:
I just edited my post. I use two factories to do it. The DataAccessFactory calls getAccess method to get local/remote accesses through LocalDataAcess object or ConnectionFactory (which instead calls its getConnection method to get a RemoteDataAccess object). Does that make sense?
Bothe ConnectionFactory and RemoteDataAccess (Connection Object) will extend UnicastRemoteObject. And the server will bind ConnectionFactory instead of remote data access to create one connection per client access. Right?
If the above design is correct, I think it makes more sense. Any suggestions?
 
Sai Prasad
Ranch Hand
Posts: 560
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
holmes,
You got it right. I would add one more thing. In the requirement, a client side class is supposed to have all the public methods defined in the Data class. To satisfy it, create a DataProxy class which contains the local or remote Data instance. This DataProxy class is instantiated by the DataAccessFactory class which also supplies the Data instance to the proxy. The client deals only with the proxy instance. The DataProxy implements the interface which contains all the public methods in the Data class.
 
Holmes Wong
Ranch Hand
Posts: 163
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, Sai:
I have a LocalDataAccess class (which implements DataInterface and have all public methods in Data class) on the client-side. Is this the ProxyClass are you talking about? And why does Proxylass on the client-side need a remote instance? I am not familiar with proxy pattern, but I know it is just a class with the same methods as the original class. Please elaborate more on this. Thanks.
Originally posted by Sai Prasad:
holmes,
You got it right. I would add one more thing. In the requirement, a client side class is supposed to have all the public methods defined in the Data class. To satisfy it, create a DataProxy class which contains the local or remote Data instance. This DataProxy class is instantiated by the DataAccessFactory class which also supplies the Data instance to the proxy. The client deals only with the proxy instance. The DataProxy implements the interface which contains all the public methods in the Data class.
 
Sai Prasad
Ranch Hand
Posts: 560
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes. Your LocalDataAccess class is the proxy that I was referring to. Your client side Factory create/find the Data instance assign this instance to the Proxy. Proxy has only pass through methods to communicate with local or remote Data instance.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic