hi kevin,
if the cdi-container isn't ready at the first access, you can just check it
via:
public String getPropertyValue(String key) {
if (!BeanManagerProvider.isActive() || key.startsWith("deltaspike.")) {
return null;
}
//...
}
you need to return null for those lookups and once the cdi-container is
ready, you can access your cdi-beans.
(skip keys used by deltaspike, if your config-source provides values for
your custom keys.)
regards,
gerhard
http://www.irian.at
Your JavaEE powerhouse -
JavaEE Consulting, Development and
Courses in English and German
Professional Support for Apache
MyFaces, DeltaSpike and OpenWebBeans
2016-06-01 17:50 GMT+02:00 Kevin Grüneberg <[email protected]>:
> Hello,
>
> is there any way to get CDI working in a ConfigSource?
>
> Basically, I am trying to define a custom ConfigSource, that injects a DAO
> to retreive the configuration parameters from a database. However, the
> ConfigSource is registered via META-INF/Services and the class is loaded
> very early, even before JNDI lookup or anything else works.
>
> What I tried, for example, is something like
>
> public class DatabaseConfigSource implements ConfigSource {
>
> @Inject
>
> private ConfigDao configDao;
>
> public String getPropertyValue(String key) {
>
> if (configDao == null) {
>
> BeanProvider.injectFields(this);
>
> }
>
> }
>
> }
>
> I cannot call BeanProvider.injectFields(this), because the class is
> instantiated so early, that there is no CDI context available.
>
> Is there a way to get CDI to work for a custom ConfigSource?
>