• 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

EJB Home uses Abstract factory or Factory Method?

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

I have read in many places that the EJB home uses the abstract factory or the factory method, I believe its the abstract factory that is in use, with only one object in the family of objects created by the factory.

It dosn't seem to be the factory method because there is no direct subclassing of this interface by the EJB (the create call is delegated but not via inheritance).

Can anyone clarify or provide any insight...

Regards,

James.
 
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,


If I would have to choose between the two I would choose Factory Method, the reason being that the Home interface is not only about creating objects but also provides other functionality. Hence it is not a pure factory object. On the other hand, the home interface itself does not depend on create() for the implementation of the other methods so that would speak against the factory method again. So it's possible to argue for both of the alternatives.

Luckily I did not encounter such difficult questions on the exam. In those questions 5 alternatives were mentioned of which 4 were absolute nonsense so that made it easier.

Cheers
Erik
 
Ranch Hand
Posts: 372
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I was tempted to say Factory Method at first, but on second thought, I worked out something like this :

The Abstract Factory pattern makes more sense for this scenario. I would say the home interface is the abstract factory, the home object created by the container is the concrete factory. You have one abstract product in the entire family - this is the abstract component interface. There is only one concrete product - the EJBObject created by the container implementing the component interface. The concrete factory (home object) creates the concrete product (the EJB object). The client is composed with the abstract factory (home interface) and with the abstract product (component interface), gets a concrete factory at run-time (by doing a JNDI look-up) and delegates the create call to the composed factory object (home.create()). If you think about it, it perfectly fits the AF class diagram right?
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic