Re: [picocontainer-dev] RE: [picocontainer-scm] [4525] java/2.x/trunk/pico/container/src/test/org/picocontainer/defaults: constructor injection speedup : remembers (optionally) the constructor to use

Paul Hammant <[email protected]>
Newsgroups gmane.comp.java.picocontainer.devel
Message-ID <[email protected]>
It is about twice as fast for a simple case now (the speed measurement  
is printed out).  It could be more for something with more  
constructors, or more parameters in a constructor.

There are scenarios where a new instance is required for the same  
getComponent() call .. like for webapps in the session or request  
scopes.  Seeing as we are not newing Pico's for each session and  
request now, there no reason for it repeatedly to do the  
getGreediestConstructor stuff.

Now the cost of Pico doing its traversal is rather small compared to  
any IO, but Joe Walnes (when I last bumped into him) felt that Pico  
could be quicker in the web tier.

I've not finished the change yet, but the old 'forgetful' way will  
still be supported.  People can add components to pico after the first  
lookup. It is supported, and I'm sure someone can make a case for it,  
but I can't think of when I'd want to do that.

Feel free to make it smarter, in terms of impl :-)

- Paul


On May 29, 2008, at 8:29 PM, Michael Rimov wrote:

> Silly question:  is there a reason why you wouldn’t want to remember  
> the constructor to use?  I can only think of memory resources, but  
> if we did SoftReferences, we probably could strike a happy medium  
> and save all the if/else clauses.
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.