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).
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.
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?
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
subject: EJB Home uses Abstract factory or Factory Method?