• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

an architecure issue with dbcp

Lidia Cyc
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi gurus, i need an advice for the right application architecture.
i am working on a webapp with a lot of different features which include a work with a db. i use tomcat's data pooling management - dbcp.
the InitialContext.lookup() is needed to get the DataSource object. i was thinking about the right way to make the number of lookups as few as possible-i belive this operation is really slow.
the first think i thought about is a servlet which gets the DataSource in its
init(). but pretty quickly i understood that this servlet will become a huge mess of control and business logics. to keep the mvc clean i wanna refactor it into one controller and a lot of servlets - each of them will deal with its own business objects. now, i still don't wanna make the lookup() in each of those sevlets.
i was thinking about a ServletContextListener which will make one lookup in its contextInitialized() method and set an attribute in the ServletContext with the DataSource object , which will be available through the whole context.
what do you think? is there anything impportant in this kind of design i didn't think about ?
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic