Win a copy of Rust Web Development this week in the Other Languages forum!
  • 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:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

[The Book vs URLyBird 1.1.2] SCJD Exam with j2se - Factory pattern vs Facade pattern

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

This is my first post here so, Hello everyone!

In The Book "SCJD Exam with j2se" (by Andrew Monkhouse ), in RMI section, factory pattern is utilized to obtain new instance of DVDDatabase class.
I was analyzing this idea and I have got a question that I am not able to answer myself:
Why do we need to multiple instances of this class? Can't it be done with only single instance? Every client would be supplied with the same reference of DVDDatabase (singleton?) and requests would be processed by "file access" class object according to locking mechanism implemented in "file access" class?

I remember that in book example client ID is provided by reference to DVDDatabase, and in my case client ID is provided as a number requested when locking/unlocking methods (so called: cookie).

So in my opinion when i have got a cookie value I do not need to utilize a factory pattern?

Best regards,

[ October 31, 2008: Message edited by: tnts2008 ]

[ October 31, 2008: Message edited by: tnts2008 ]

[ November 03, 2008: Message edited by: tnts2008 ]

[ November 03, 2008: Message edited by: tnts2008 ]
[ November 03, 2008: Message edited by: tnts2008 ]
 
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi;

yes i am with you; my interface provided use cookie so i don't generate unique instances of the data class also i register only one instance in the rmi stub.

regards.
Mohamed Sulibi
 
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello, Jerry
In the RMI solution, each client receive a different instance of the DVDDatabase class.
This is a mean to identify the client on the server side for reserve/release operations, as a thread is not linked to a client.
In the "ReservationsManager" class, a Map maps UPCs with DvdDatabase instances.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic