-
1. Re: Accessing built-in beans in portable extension
jharting May 30, 2011 9:47 AM (in response to gunnar.gunnar.morling.googlemail.com)You did not mention in which phase you do the check. However, note that you are not allowed to resolve any beans (including built-in ones) before the application is fully initialized.
I assume that you are trying to obtain the ValidatorFactory reference in a container lifecycle method (@AfterBeanDiscovery or similar) which is wrong.
-
2. Re: Accessing built-in beans in portable extension
asiandub May 30, 2011 11:03 AM (in response to gunnar.gunnar.morling.googlemail.com)Just wanted to post that I have exactly the same issue with Seam Validation when I realized that we are talking about this already :-D
@Josef - you are right, the event is ABD, see here for the relevant code here
public void afterBeanDiscovery(@Observes AfterBeanDiscovery abd, BeanManager bm) { addValidatorFactoryIfRequired(abd, bm); addValidatorIfRequired(abd, bm); addMethodValidator(abd, bm); }
So, which is the right event to use (if any)? AfterDeploymentValidation feels like you dont want to modify any beans anymore, or am I wrong?
-
3. Re: Accessing built-in beans in portable extension
asiandub May 30, 2011 11:16 AM (in response to gunnar.gunnar.morling.googlemail.com)I found that JIRA-Issue being proposed for CDI 1.1...
-
4. Re: Accessing built-in beans in portable extension
jharting May 31, 2011 3:23 AM (in response to gunnar.gunnar.morling.googlemail.com)I would try using Solder's @DefaultBean mechanism. Annotating your bean with the annotation will cause it to be registered only if there's no other bean of the type. This should work for built-in beans as well.
-
5. Re: Accessing built-in beans in portable extension
asiandub May 31, 2011 3:36 AM (in response to gunnar.gunnar.morling.googlemail.com)
Default beans allow you to create a default bean with a specified type and set of qualifiers. If no other bean is installed that has the same type and qualifiers, then the default bean will be installed.That looks exactly like the requirement...
The code seems pretty sophisticated :-)
-
6. Re: Accessing built-in beans in portable extension
gunnar.gunnar.morling.googlemail.com Jun 5, 2011 3:38 PM (in response to gunnar.gunnar.morling.googlemail.com)Hi,
first of all, sorry for my late response. Somehow I didn't get any e-mail notifications on your answers, so I thought there were no answers so far and I also didn't check the forum.
I'll give @DefaultBean a try, this looks really promising. Though I'm still a bit surprised that one should not check for registered beans in ABD, in particular as it seems to work under certain circumstances.
Thanks, Gunnar