• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

LocalAdapter and Remote Adapter

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have been reading this forum a lot recently because I am trying to finalize my assignment. I found that many people talk about creating a local adapter and a remote adapter class, and they both in turns call DB/DBMain class to access data file.

I understand the local adapther and remote adapter design is trying to separate the network mode and non network mode.

But my design is different.

I have only one adapter, which calls Data class to work with data file. THis adapter throws RemoteException just to be compatible with RMI Code in Network Mode.

So in network mode, GUi calls this only adapter through RMI network code.
In local mode, GUI calls this only adapter directly.

Anything is wrong with this design?

According to the requirement, I should not use the network code when the codes work in non network mode. It does not say that I can't use the same model class - adapter for both modes.

Am I wrong?
 
Ranch Hand
Posts: 1033
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm a big proponent of the use of two nested adapters. My project provided a DBAccess interface that is to be used to access the database. To meet this requirement I built Data class that implements this interface and is used by the server and the standalone client.

I use a DataAdapter interface that adds the RemoteException to all the methods in DBAccess. This allows me to use Data across RMI, but this is no longer LSP substitutable for Data. At this point my network access would need to use a different interface than my local access.

To get around this I defined a DataProxy class that implements the DBAccess interface and is an Adapter in the GoF object meaning of that word. This second Adapter creates a Proxy, which GoF defines as an Adapter that has an identical interface to its Adaptee.

All this lets me use a Factory Method to pick either a Data or DataProxy instance based on the mode and allows both the networked client and the standalone client to use the same DBAccess interface.
 
Tommy Wan
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In my design, I have the DB as the interface provided by SUN. Data is the class implementing DB interface to do all data read/write/lock/unlock/delete/create operation.
I create DBAdapter to call Data class to implement only the methods needed by GUI, like book a hotel/return a hotel(extra)/search. This DBApdater adds RemoteException to all methods So I can use it across RMI.

In my GUIController class, it will determine to get a local instance or get an instance through RMI based on the network mode.Either case, the instance will be an instance of DBAdapter.

Could you tell me wether I am voilating the requirement to separate the network mode or not?
 
peter wooster
Ranch Hand
Posts: 1033
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Tommy Wan:
In my design, I have the DB as the interface provided by SUN. Data is the class implementing DB interface to do all data read/write/lock/unlock/delete/create operation.
I create DBAdapter to call Data class to implement only the methods needed by GUI, like book a hotel/return a hotel(extra)/search. This DBApdater adds RemoteException to all methods So I can use it across RMI.

In my GUIController class, it will determine to get a local instance or get an instance through RMI based on the network mode.Either case, the instance will be an instance of DBAdapter.

Could you tell me wether I am voilating the requirement to separate the network mode or not?



You are using the "thin client" model. I don't agree that this actually meets the project requirements, but people have passed using it, so it's OK if you can justify it in your choices document.

The requirement to not use any networking applies to the use of actual RMI or socket methods. I don't believe that declaring that a method throws RemoteException would be considered a violation.
 
Tommy Wan
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Peter,

Thanks for clarification.
 
Tommy Wan
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Peter,


You are using the "thin client" model. I don't agree that this actually meets the project requirements, but people have passed using it, so it's OK if you can justify it in your choices document.



what do you mean this doesn't actually meets the project requirements?

I finally finished testing and fixing my lock logic. This adapter stuff is the last one I need to confirm.

Could anybody else kind enough to offer some insights here?
I really appreciate it.
 
author and jackaroo
Posts: 12200
280
Mac IntelliJ IDE Firefox Browser Oracle C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Tommy,

what do you mean this doesn't actually meets the project requirements?



Actually, Peter stated that he doesnt agree that this actually meets the project requirements (emphasis is mine). That is, it is Peter's personal opinion.

I happen to agree with Peter's opinion (and again, this is a personal opinion ). If you are interested, you can read the really long topic "Should lock methods be callable by the client" which discusses the reasons for and against thin client solutions. The final conclusion (if you can call it a conclusion) was that either choice could be OK - you just have to justify it in your choices document.

Regards, Andrew
 
Or we might never have existed at all. Freaky. So we should cherish everything. Even this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic