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.
|

Reply via email to