hi ludovic, you don't need to catch an exception, if you are using "true" as 2nd argument to do an optional lookup. (with using an observer for a startup-event, you don't even need to do an optional lookup.)
regards, gerhard 2015-12-16 15:11 GMT+01:00 [email protected] <[email protected]>: > On 16/12/2015 12:45, Gerhard Petracek wrote: > >> hi ludovic, >> >> what you can do right now is to check BeanManagerProvider#isActive + use >> an >> optional lookup via BeanProvider#getContextualReference (or use >> BeanProvider#injectFields lazily) in your config-source. >> > That is exactly what I do ! :-) > > But, as I am sure you understood, I would prefer to not even try to get > configuration values from those sources before CDI is booted. > > In fact, I am using something like > > if(BeanManagerProvider.isActive()) { > try { > myBean = BeanProvider.getContextualReference(MyBean.class); > } catch(IllegalStateException ise) { > // happens sometimes when CDI is not fully booted > myBean = null; > } > } > > As you can see, I have to catch an exception, because > BeanManagerProvider#isActive is not enough. > > > Ludovic > > | > | AVANT D'IMPRIMER, PENSEZ A L'ENVIRONNEMENT. > | > >
