Thanks for your answers... @Mark
So the first business method invocation should then call the producer method followed by a call to the @PostConstruct annotated method? So I assume something was wrong with my tests then? I did take a look at the article (but have not read it all yet), thanks for the pointer... @Romain I assume you are talking about dependent scoped beans when you say "generally" ? Regards Lars-Fredrik On Mon, Dec 2, 2013 at 7:49 PM, Mark Struberg <[email protected]> wrote: > > > Hi! > > The answer to your question is: The @Produces method only gets created > when a 'Contextual Instance' is created. > > > > This might need some further explanation about what a Contextual Instance > is in contrast to a Contextual Reference. You might read up on it in an > article I wrote together with Pete a few years ago: > http://jaxenter.com/java-tech-journal-issue-16-cdi-41534.html > just follow the link to the article. > > The short answer is: if you inject a bean into your class, then you will > only get a proxy (the Contextual Reference). And the first method > invocation to this bean will trigger the producer method to be called. > > This has nothing to do with OWB but is within the very nature of CDI > itself. > > > LieGrue, > strub > > >________________________________ > > From: Lars-Fredrik Smedberg <[email protected]> > >To: "[email protected]" <[email protected]> > >Sent: Monday, 2 December 2013, 19:41 > >Subject: How "lazy" is OWB? > > > > > > > >Hi! > > > >How "lazy" is OWB? I might have done something wrong in my tests but I > think I've seen the following: > > > > > >- For both tests I created the bean using a @Produces method in a factory > class (I tried creating the bean with @RequestScoped and @SessionScoped > scopes) > >- For both tests the bean had a @PostConstruct annotated method and a > simple "business method". > > > > > >Test 1) > > > > > >- The bean being created did inject other CDI managed beans using @Inject > >=> In this case I could see that the @Produces method was called when the > bean being created was injected into my test resource BUT the > @PostConstruct was not called until i called the business method from the > test resource. > > > > > >Test 2) > > > > > >- The bean being created did NOT inject other CDI managed beans using > @Inject > >=> In this case the @PostConstruct method was called right after the > @Produces method, that is without I have to call the business method first. > > > > > >Questions: > > > > > >1) Did I do something wrong when I did test the two cases above? > >2) Can anyone explain the some of the different optimizations OWB does or > where I can read about them? > > > > > >Regards > >Lars-Fredrik > > > > > >-- > >Med vänlig hälsning / Best regards > > > >Lars-Fredrik Smedberg > > > >STATEMENT OF CONFIDENTIALITY: > >The information contained in this electronic message and any > >attachments to this message are intended for the exclusive use of the > >address(es) and may contain confidential or privileged information. If > >you are not the intended recipient, please notify Lars-Fredrik Smedberg > >immediately at [email protected], and destroy all copies of this > >message and any attachments. > > > > > -- Med vänlig hälsning / Best regards Lars-Fredrik Smedberg STATEMENT OF CONFIDENTIALITY: The information contained in this electronic message and any attachments to this message are intended for the exclusive use of the address(es) and may contain confidential or privileged information. If you are not the intended recipient, please notify Lars-Fredrik Smedberg immediately at [email protected], and destroy all copies of this message and any attachments.
