Hi Desmond! Depends what you understand under the term 'Bean'.
Let me explain: The CDI spec defines Bean<T> as meta-information about instances to be created. Kind of a factory rule information. This is different to what CDI understands under 'Contextual Instance' which means the real instances of your e.g. @ApplicationScoped MailService, the @RequestScoped User, etc There is also a 3rd term, the 'Contextual Reference' which is simply a delegating proxy to your contextual instances. This is what you normally get injected if you use @Inject MailService mailSvc; Do you have some samples or give us some hint about what you like to solve? It is not easily possible in CDI to lazily change Bean<T> stuff, because those get scanned at boot time, validated, etc. It is of course possible to lazily load Contextual References. You can use the Instance<T> for this: @Inject @Any // to get all qualifiers private Instance<MailService> mailServiceProvider; ... mailServiceProvider.isAmbiguous()... If you like to have even more control, then you can use the BeanManager#getBeans() to get all the Bean<T> information and later on use BeanManager#getReference(..) to get the exact contextual instance you were looking for. Feel free to ping back on any further question. LieGrue, strub >________________________________ > From: Dessie K <[email protected]> >To: [email protected] >Sent: Wednesday, 16 October 2013, 21:03 >Subject: Lazy load a bean > > > >Hi, > > >How can I lazy load beans? > >
