• 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

B&S: Why not use same class for Local and Netowk mode

 
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Ranches, need your help

From Requirements:
The operating mode is selected using the single command line argument that is permitted. Architecturally, this mode must use the database and GUI from the networked form, but must not use the network server code at all.



To make my code and life simple, I need an answer to a question:

LOCAL MODE:
:- Can I use the Data class which extends SUN's interface in local mode as it is.
How I am thinking of doing it: Import the Data class on client side and use it as regular local object. NOT accessing it through network mode(which requires registering the object on serverside and lookingup on client side).

NETWORK MODE:
Create instance of Data class on server-side, BUT this time it is registered with RMI-registry and on client side we can perform registry lookup and use remote object.

I am viewing the DATA class as designed for API of this applicaiton and can be used by the server and client both AND it becomes server code only when and instance is created on severside.

What do you say..

Many thanks,
Alain

[ December 27, 2008: Message edited by: Alain Dickson ]

[ December 27, 2008: Message edited by: Alain Dickson ]
[ December 27, 2008: Message edited by: Alain Dickson ]
 
Ranch Hand
Posts: 158
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You must be able to throw RemoteException from every method of Data. If the SUN interface allows you to do this (for example the methods throw IOException) then it should be possible. Your Data class should implement an interface which extends both java.rmi.Remote and the SUN interface, and it should also extend UnicastRemoteObject.

However, I'd say this is not a very nice choice, because it makes your Data class depend on the server's implementation. If you decide sometime later that RMI is not desirable anymore, you have to change the Data class. It's better to keeps concerns separated.

About your "must not use the network server code at all" concern, I'd say it's ok as long as you don't start the RMI registry in non-networked mode.
[ December 27, 2008: Message edited by: Alecsandru Cocarla ]
 
Ranch Hand
Posts: 95
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes you can...
but, would you want to bother your local module with network-related code?

Maybe you'd be better of with a local-class and then a remote-class that delegates calls to the local-class, decorating it with all sorts of network-related code.
 
Ranch Hand
Posts: 759
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In the local mode, my GUI application use the class that implements the interface.

In the networked mode, the class that implements the interface is encapsulated in my networking code.

That's how I done.

Good Luck !!!

Jeffry Kristianto Yanuar (Java Instructor)
SCJP 5.0, SCJA, SCJD (UrlyBird 1.3.2)

"Professional certification is the battle between formal education and informal education. So far, the formal one is winning"
 
Alain Dickson
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks! Alecsandru, Bod & Jeffry

Alain
reply
    Bookmark Topic Watch Topic
  • New Topic