Is it ok to put DAOs and Gateways that will be called many times but only need to be instantiated once in the Application scope?
Thanks
Join Stack Overflow to learn, share knowledge, and build your career.
Is it ok to put DAOs and Gateways that will be called many times but only need to be instantiated once in the Application scope?
Thanks
Yes, absolutely.
Another option is to use an IOC framework such as ColdSpring or some other bean factory. The bean factory can then be stored in the application scope and instantiated onApplicationStart() (effectively achieving the same thing but possibly with more control).
That's the perfect place to put them ;-).
Add them into onApplicationStart() as application.myDAO = xxxx & application.myGateway = xxxx and you're good to go!