Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JDO + J2EE best practice?

 
Ben Thurley
Greenhorn
Posts: 6
Eclipse IDE Firefox Browser jQuery
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Currently im getting the PersistenceManagerFactory and PersistenceManager in a Filter and adding it to the request object. However, im not sure if this is the best way to set things up? The filter intercepts all requests.

I have two main concerns:

1 Im not sure if this method yields the best performance?

2 What if a POJO needs access to the PersistenceManager? Like a DAO

Looking forward to your responses.
Thanks
 
Erik Bengtson
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sorry for the short answer, but it may help

http://www.jdocentral.com/forums/index.php?&act=ST&f=11&t=625
 
Ben Thurley
Greenhorn
Posts: 6
Eclipse IDE Firefox Browser jQuery
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the reply Erik

As it happens i'd just stumbled upon a similar solution myself and was about to update this thread.

I use a Filter to intercept *.jsp requests and create a PersistenceManager for this request.



As you can see the Filter stores the PersistenceManager in a static class; PMRegistry. This is adapted from the somewhat lengthy article at TheServerSide



Now whenever I want to access the PersistenceManager I just make the call



This is the best I can come up with. Any comments good or bad would be welcome.
 
Erik Bengtson
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The only comment I have is to put the pm.close in a try finally block, and make sure you are running a multi threaded enviroment



 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic