Re: [picocontainer-dev] comments on injection

Paul Hammant <[email protected]>
Newsgroups gmane.comp.java.picocontainer.devel
Message-ID <[email protected]>
Expand that a little more with testcode will ya Erik?

-ph

On Jun 1, 2007, at 11:21 AM, Putrycz, Erik wrote:

> My other (main) use case is injection…
>
> When I have
>
> @Inject
>
> private MyClass _myClass;
>
>
> If MyClass is not registered then it gets registered automatically  
> in Pico. With this feature, I hardly have any “initialization” code  
> in my projects. I just start my project by creating a container and  
> everything else gets wired automatically. I’m not sure how this  
> could work out with “getInstance”.
>
>
> Erik.
>
> From: Paul Hammant [mailto:[email protected]]
> Sent: June 1, 2007 13:27
> To: dev-qxt/[email protected]
> Subject: Re: [picocontainer-dev] comments on injection
>
>
> What other usecase is there Erik ?
>
>
> For the one you;ve given :-
>
>
> +          @Test
>
> +          public void testDynamicRegistration() {
>
> +                      MutablePicoContainer pico = new  
> DefaultPicoContainer();
>
> +                      ComponentLocator dynamicReg = new  
> DynamicRegistrationLocator();
>
> +                      pico.addLocator(dynamicReg);
>
> +                      LinkedList<String> list = pico.getComponent 
> (LinkedList.class);
>
> +                      assertNotNull(list);
>
> +          }
>
>
>
> I might prefer ..
>
>
> +          @Test
>
> +          public void testDynamicRegistration() {
>
> +                      MutablePicoContainer pico = new  
> DefaultPicoContainer();
>
> +                      LinkedList<String> list = pico.addComponent 
> (LinkedList.class).getInstance();  // getInstance() is new and  
> implicitly on the last component added ~  v easy to implement
>
> +                      assertNotNull(list);
>
> +          }
>
>
> I know you have a 'bigger' use of your way up your sleeve :-)
>
>
> - Paul
>
>
> On Jun 1, 2007, at 9:46 AM, Putrycz, Erik wrote:
>
>
>
>
> <Pico2-locator.patch>
>
>
>
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.