It's not a secret anymore!*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes RemoteInterface realization 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 "RemoteInterface realization" Watch "RemoteInterface realization" New topic
Author

RemoteInterface realization

Naveen Narayanan
Ranch Hand

Joined: Sep 11, 2007
Posts: 114

Hello all,
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?

Kind Regards,
Naveen.

SCJP 5.0, SCJD, SCWCD
K. Tsang
Bartender

Joined: Sep 13, 2007
Posts: 2247
    
    7

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?


K. Tsang JavaRanch SCJP5 SCJD/OCM-JD OCPJP7 OCPWCD5
Naveen Narayanan
Ranch Hand

Joined: Sep 11, 2007
Posts: 114

Thanks Tsang for throwing light on this ...
You definitely need a local interface and remote interface. Yet you also need a super interface that umbrella the 2.

This super interface was exactly missed by me
Is it really the local interface? Or just let the Data class implement it to satisfy the requirements?

Seems right , possibly l feel like playing with a RemoteInterface even in local-mode
Kind Regards,
Naveen Narayanan.
K. Tsang
Bartender

Joined: Sep 13, 2007
Posts: 2247
    
    7

Glad I helped.

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?
Naveen Narayanan
Ranch Hand

Joined: Sep 11, 2007
Posts: 114

Hello Tsang , Thanks for making me think ... sorry , I was running behind super-interface and was sorting out how it can umbrellas both.
What exceptions to catch on the client?

RemoteException when in Networked-Mode , IOException when Local-Mode
Are you working with the specific local/remote interface or the super interface?

Db handle will be based on Super-Interface that can be assigned by
Remote-Interface from client when in Networked-Mode
Local-Interface from client when in Standalone-Mode
What exceptions to declare in the super interface?

Probably it contains all exceptions viz Remote ... , DupKey …, Security …, RecNotFound …
What are Methods in Super Interface ?

Seems can have read , update as well ... Probably create/delete might not be required
Am I getting closer?

Kind Regards,
Naveen Narayanan.
K. Tsang
Bartender

Joined: Sep 13, 2007
Posts: 2247
    
    7

Super interface? Ah simple:


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?
Naveen Narayanan
Ranch Hand

Joined: Sep 11, 2007
Posts: 114

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)

Am I grasping it right?

Kind Regards,
Naveen Narayanan.
K. Tsang
Bartender

Joined: Sep 13, 2007
Posts: 2247
    
    7

You mention business service layer then you should be doing what you meant to do. If not, you will not where to change.
 
jQuery in Action, 2nd edition
 
subject: RemoteInterface realization
 
Similar Threads
Please comment on FBN design
FBN Design
Data Client
RMI blues
Error in my Adapter pattern implementation?