• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Factory Pattern

 
priya shankar
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all
In ejb ,home interface acts as a factory to create ejbobjects ...huv..
huv it implements the decoupling ...
thanks
priya
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't understand the question. Could you please elaborate?
 
priya shankar
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ilja
I mean that , Ejb home object is factory for creating EJBObjects ....huv it is?
priya
 
Lasse Koskela
author
Sheriff
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
EJBHome is a factory because it's managing the creation of EJBObjects. I.e. you don't say "new MySessionBean()" but call a factory method called "EJBHome.create(...)".
 
priya shankar
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks
But what makes EjbHome to act as Factory ....A factory should allow its subclasse to create instances...
where it happens ..
priya
 
Lasse Koskela
author
Sheriff
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But what makes EjbHome to act as Factory ....A factory should allow its subclasse to create instances...

The intent of the GoF pattern "Factory Method":
Define an interface for creating an object, but let subclasses decide which class to instantiate.
"Define an interface" has been fulfilled with javax.ejb.EJBHome.
"let subclasses decide which class to instantiate" is fulfilled by the container generating vendor-specific decorating classes of the EJBHome interface specified by the bean developer, such as com.foobar.MySessionHome_impl for a home interface called com.foobar.MySessionHome.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic