Could anybody please come-up with a suggestion?
During the RemoteInterface realization, I tried an option like this ...
Made two interfaces.
DBAccessLocal with Sun’s framework and DBAcessRemote with additional RemoteExceptions to handle RMI .
Data class implements both local & remote interfaces.
Hopefully I am not violating sun’s must requirements up-to here.
Probably I am a bit concerned at this area
Suppose I convert DBAccessLocal to DBAcessRemote in the local-connection-mode(Direct without Network) …
And used dataConn as the local-connection-mode-handle ,
Can I assume that, its not breaking sun’s must requirements?
One way to structure your services is forget the Sun's interface for a sec. Assume you still need to do create, read, update, delete, search functions, how would you set it up? You definitely need a local interface and remote interface. Yet you also need a super interface that umbrella the 2. Oh think as if you are the client. Eg book and search are 2 obvious methods in the super interface.
Once you got that set up, plug back the Sun interface and see where that goes. Is it really the local interface? Or just let the Data class implement it to satisfy the requirements?
Naveen Narayanan wrote:Seems right , possibly l feel like playing with a RemoteInterface even in local-mode
Well sort of from coding perspective especially for the client side. What exceptions to catch on the client? Are you working with the specific local/remote interface or the super interface? (hint the latter one). What exceptions to declare in the super interface?
Then you need to worry about Sun's provided interface. Then in the LocalService implementation class, you get an instance of Data class or its super class/interface and delegate to that Data class. In the RemoteService implementation class, delegate to LocalService.
In my Service interface, I only have 2 exceptions, RemoteException for server stuff and DatabaseException for local stuff. You may ask what about RecordNotFoundException etc? In my implementation class, if I catch those, I rethrow it as DatabaseException. This will make client code only worry 2 exceptions.
Oh in the super interface you declare methods that are more business needs, not necessarily the same methods as Sun's interface. If it is, why not just use Sun's interface as the super interface? Which of course doesn't work ... cos how to cater for RemoteException for RMI?
Champ buddy Tsang, I am tunneling more in …
Perhaps, stepping-down Sun interface to a database related one.
Possibly isolating its grip from Super, Local & Remote interfaces.
Business Service layer start to speak between client & server (Rather than Db Service layer)