RE: [picocontainer-dev] Patch for web ... to close that static getter IoC problem
"Michael Rimov" <[email protected]> Sat, 21 Jun 2008 13:34:00 -0700
| Newsgroups | gmane.comp.java.picocontainer.devel |
|---|---|
| Organization | Centerline Computers, Inc |
| Message-ID | <008301c8d3de$26b75a50$74260ef0$@com> |
> > what I am always curious about is, whether there is a real need for
> > the
> > different containers. Do we really have different component types
> > for the
> > sessions or requests or is it that we need separate instances?
>
> It would be possible to have one container and use as(..) to push in
> components to the appropriate scoping level :
>
> container.as(APP_SCOPE).addComponent(Hibernate.class)
> container.as(SESSION_SCOPE).addComponent(ShoppingCart.class)
> container.as(REQUEST_SCOPE).addComponent(AddToCart.class)
Correct. In fact, I _thought_ that's what you were going to do with your last
refactoring of pico-web.
> Then as http requests happen, pre-process the whole container, setting
> the right cached session scoped things, and ensuring that none at the
> request level are cached.
And that's exactly what the ABORT_TRAVERSAL feature of visitor was added for: So
you can process the app-level container for components without accidentally
pre-processing any child containers.
Of course, you would still need the ThreadLocal so each request-level component
adapter instance would know where to store its stuff since ComponentAdapter
instances would be shared across requests. (Which I think, is what you're
trying to say :) )
That said, you wouldn't need a ThreadLocal for the current application
container, like you do in PicoServletContainerFilter, would you?
-Mike
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email