aspose file tools*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Request for feedback on design Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Request for feedback on design" Watch "Request for feedback on design" New topic
Author

Request for feedback on design

Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Ranchers,
I'd like to get some feedback regarding the design I'm thinking of proceeding with. This is a general view. Is anything missing or completely wack?
Client
-----------------------------------------------
UI talks to Facade
Facade has business methods, i.e. getFlights(), etc
- Facade gets a DataSource connection when asked to work in remote mode
- Facade gets a vanilla DataSource when asked to work local
- business methods only know how to talk to a DataSource

Server
-----------------------------------------------
DataSourceFactory bound to RMI
- creates DataSource connections with a Data and a LockManager
- returns DataSource connections to Facade
LockManager tracks DataSource connections and calls Data lock methods

DB
-----------------------------------------------
DataSource has all public methods of Data
- throws RemoteExceptions and DatabaseExceptions
- implemented by Data
RemoteDataSource extends DataSource and Remote
- implemented by DataSource connection
DataSource connection delegates to Data

Thanks in advance for your feedback
Gosling Gong
Ranch Hand

Joined: Jun 20, 2002
Posts: 51
you make Data implements DataSource and have lock implementation in Data, that means, you will have lock/unlock logic even in local mode?
another question is what I have asked here couple of days ago, if doing so, then, you didn't have data client that has all public methods of Data in your client package. I am not sure if it is ok.
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Thanks for your reply.
Actually, I do have locking in Data -- a subclass of Data to be exact. Omitted that (and a couple other details from original post) for brevity.
When local, the simple locking in Data is the only locking that's used. There is no client tracking. When remote, the Lock Manager tracks clients and then calls into same locking methods used when local.
I *think* that by having the DataAccess Connection object be a Remote, its stub takes care of the requirement for having all public Data methods on the client.
Suresh Babu Seeram
Greenhorn

Joined: Feb 04, 2002
Posts: 27
Hi,

Can you explain how to achieve above with sample code. I could not understand that..


regards,<br />Suresh<br />Sr.Systems Engineer)<p>--Sun Certified Programmer for Java 2 Platform <br />--JLPT(Level-4) Certified Professional
Eduard Jodas
Ranch Hand

Joined: May 14, 2002
Posts: 80

I *think* that by having the DataAccess Connection object be a Remote, its stub takes care of the requirement for having all public Data methods on the client

That way your local data access object can not implement the same interface as your remote data access object. Thus it seems to me that your client has more difficulties dealing with local/remote operating modes.
What if sometime in the future you want to change your implementation to use sockets instead of RMI? I know that's unlikely to happen, but it shows your design might not be flexible enough.
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Suresh - the Lock Manager has methods un/lock(Object, int). Object is the caller. It gets stored in a HashMap with the int record number. Lock Manager then calls lock(int) in Data.
Eduard - the same interface (DataSource) is used whether the client is going remote or local. There is still some complexity, but the facade covers over all that. Facade either gets a local data source, or gets a remote data source from the server.
Amit Kr Kumar
Ranch Hand

Joined: Feb 08, 2002
Posts: 100
Hi Erick
What is there in your Lock method at Data or its subclass ???
Amit
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Amit,
The lockable subclass of Data has the basic lock(int) and unlock(int) methods. Modify and delete ops in the subclass check for a lock on the specified record number, and then use the functionality in super (the plain Data implementation).
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Request for feedback on design