File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes EJB and other Java EE Technologies and the fly likes Caching in factory.... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Caching in factory...." Watch "Caching in factory...." New topic

Caching in factory....

Gaurav Jain
Ranch Hand

Joined: Mar 11, 2004
Posts: 108
Is it a good practise to cache the object which is created using a factory?
For example i create a Customer DAO using the DAO factory then after creating it i store it in a hashmap in the factory and then when a different request comes instead of creating the CustomerDAO again i serve the same from the hashmap.
Valentin Tanase
Ranch Hand

Joined: Feb 17, 2005
Posts: 704
It is an attractive option as long as your cached object is designed thread safe or multithreading is not an issue in your application.

I think, therefore I exist -- Rene Descartes
I agree. Here's the link:
subject: Caching in factory....
It's not a secret anymore!