Re: [picocontainer-dev] The constant web design wall I keep hitting [long]

Daniel Wellman <[email protected]> Sat, 22 Nov 2008 06:50:12 -0800 (PST)
Newsgroups gmane.comp.java.picocontainer.devel
Message-ID <[email protected]>
I'm experiencing the same issue as Mike: we used PicoContainer 1.x and
NanoContainer to build our WebWork 2 webapp.  Our DAOs accept a
request-scope Hibernate Session object, which we've wrapped with an
implementation that implements the Pico Startable interface.  On start() we
get the session from the HibernateSessionFactory, and on stop() we close the
Session.  We use this to implement the Open Session in View pattern in our
webapp, since we wrap the Pico Request Listener around our WebWork action
servlet.

It looks like PicoContainer 2 Persistence allows both strategies; the
documentation suggests passing a HibernateSessionFactory to every DAO --
HibernatePersister takes a SessionFactory parameter, and the app registers
both ConstructableAnnotationConfiguration and ConfigurableSessionFactory:

http://picocontainer.org/persistence/hibernate.html

But then how do you implement the Open Session in View with this pattern? 
Don't you need to stop the Session at the end of every request?

Thanks,
Dan



Paul Hammant-3 wrote:
> 
> hibernate and DAO stuff should definitely be in app scope (standard  
> picocontainer + caching)
> 
> Take a look at
> http://svn.codehaus.org/picocontainer/java/2.x/trunk/web/examples/struts2-webapp/ 
>   and the WebappComposer class for it -
> http://svn.codehaus.org/picocontainer/java/2.x/trunk/web/examples/web-example/src/java/org/picocontainer/web/sample/ExampleWebappComposer.java
> 
> The DAO is at app level. There is a DefaultCheeseService is at session  
> level for the example, but could as easily be in app scope.  Requests  
> scope things like "AddCheese" "RemoveCheese" are added laziily later
> 
> 

-- 
View this message in context: http://www.nabble.com/The-constant-web-design-wall-I-keep-hitting--long--tp18142468p20637108.html
Sent from the NanoContainer - PicoContainer - Dev mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email