Re: [picocontainer-dev] Builder confusion and cycles in annotation
Paul Hammant <[email protected]>
| Newsgroups | gmane.comp.java.picocontainer.devel |
|---|---|
| Message-ID | <[email protected]> |
On Jun 15, 2007, at 10:00 AM, Putrycz, Erik wrote:
> Hi Paul
>
>> What the problem we're trying to solve though there ?
>
> This is in my test cases
> @Single
> public class CircularCat {
> @Inject
> private CircularMouse mouse;
>
> }
>
>
> @Single
> public class CircularMouse {
>
> @Inject
> private CircularCat theCat;
>
> }
>
Yup. Its the same case as we've mulled for years (though I personally
don't see Cat/Mouse classes ;). There are too many downsides to
allowing circular refs for Annotation, Field, Setter (or Getter) DI.
Most enterprises are trying to extinguish circular refs as they move
from Singleton Hairball to decomposed DI solution.
It might be good to allow, some mechanism in Pico-gems that enhances
(somehow) the ComponentInjectors to not barf on circular. Building on
HotSwappingBehaviorAdapter perhaps. Meaning its an explicit choice
for people using Pico.
> Forget the @Single (although I could submit a patch for this one as
> well).
Seperately? Kewl.
> This example would not be resolvable with CDI but with
> annotations, nothing prevents of creating the two instances and then
> injecting the references. Circular injections make only sense when the
> instances are cached. I'll work on a patch for this.
I'd be interested in seeing it.
>
> Then I said something stupid about the builder and caching (it happens
> once in a while).
> By default in the builder, there is no caching. My
> apologies!
Nae problems laddie :)
> However, I'd vote for removing all the constructors in
> DefaultPicoContainer that create CAF factories. DPC has 10 public
> constructors (!).
>
Yeah, there's lots to that. I'll see what it feels like in code.
> Btw, in the CachingBehaviorFactory why is the constructor referencing
> the AnyInjectionFactory? (AdaptiveInjection sounds way better). How
> would this work if you want caching and CDI only?
> public CachingBehaviorFactory() {
> forThis(new AnyInjectionFactory());
> }
Agree. I was working thru them some weeks ago in a bigger refactor,
but risked not being able to finish.
I'll go ahead and complete that ( otherwise I feel I'm coming to the
end of what is the refactor into 2.0 )
- Paul
---------------------------------------------------------------------
To unsubscribe from this list please visit:
http://xircles.codehaus.org/manage_email