Re: [picocontainer-dev] The constant web design wall I keep hitting [long]
Paul Hammant <[email protected]> Fri, 27 Jun 2008 08:56:09 -0700
| Newsgroups | gmane.comp.java.picocontainer.devel |
|---|---|
| Message-ID | <[email protected]> |
I'm with Mauro Mike.
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.
Remember Pico now no-longer stores whole containers in Servlet Context/
Session. It only stores the session container's instantiated session
components (as a set) in the session scope. ThreadLocal can be over
used, but its appropriate for PicoContainer to use it behind the
scenes for a session/request scoped thing. Components themselves
should not have to know about or participate in ThreadLocal usage.
I.e. we're still honoring our transparency goal. I'm really pleased
with the efficiency and speed improvements for the new stype of Pico
webapps over the old.
Regards,
- Paul
On Jun 27, 2008, at 12:52 AM, Mauro Talevi wrote:
> Michael Rimov wrote:
>
>> So here’s my problem:
>> Since Hibernate Session is a request scope, that means:
>> · SomeDao depends on Hibernate Session, it must reside in
>> Request Scope
>> · SomeService depends on SomeDao which depends on
>> Hibernate: it must reside in Request Scope
>> · And finally, SomeController depends on SomeService which
>> depends on SomeDao which depends on Hibernate: therefore it must
>> reside in the Request Scope.
>
> IMO this is the key aristotelic syllogism: it depends on hibernate
> therefore it must reside in (webapp) request scope.
>
> Why do you assume this? You can happily have a persister/dao living
> in application scope and it will fire off different hibernate
> requests.
>
> I tend to have most dependencies living in app scope and only use
> session or request when strictly necessary.
>
> Am I missing something?
>
> Cheers
>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
> http://xircles.codehaus.org/manage_email
>
>
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email