<div dir="ltr"><div>James,</div><div><br></div><div>I agree with Antoine as IMHO this would exceed the scope of core CDI a bit.</div><div>There was a discussion by Anatole Tresch (also member of this EG) about creating a dedicated Configuration JSR (modeled among others also a lot after what DeltaSpike does) but so far JCP officials first and foremost Oracle saw either no need or no resources to do this.</div><div><br></div><div>Apache Tamaya was a logical result. If that could become a blue-print or initial contribution of a future JSR, let&#39;s see, maybe for EE 9. It uses other Apache projects like DeltaSpike where applicable, but may also define such annotations and types of its own, so I suggest you also share your ideas on a Tamaya mailing list or JIRA: <a href="http://tamaya.incubator.apache.org/index.html">http://tamaya.incubator.apache.org/index.html</a></div><div><br></div><div>On Fri, Feb 6, 2015 at 11:02 AM,  <span dir="ltr">&lt;<a href="mailto:cdi-dev-request@lists.jboss.org" target="_blank">cdi-dev-request@lists.jboss.org</a>&gt;</span> wrote:<br></div><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;padding-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-left-style:solid">Send cdi-dev mailing list submissions to<br>
        <a href="mailto:cdi-dev@lists.jboss.org">cdi-dev@lists.jboss.org</a><br>
<br>
To subscribe or unsubscribe via the World Wide Web, visit<br>
        <a href="https://lists.jboss.org/mailman/listinfo/cdi-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/cdi-dev</a><br>
or, via email, send a message with subject or body &#39;help&#39; to<br>
        <a href="mailto:cdi-dev-request@lists.jboss.org">cdi-dev-request@lists.jboss.org</a><br>
<br>
You can reach the person managing the list at<br>
        <a href="mailto:cdi-dev-owner@lists.jboss.org">cdi-dev-owner@lists.jboss.org</a><br>
<br>
When replying, please edit your Subject line so it is more specific<br>
than &quot;Re: Contents of cdi-dev digest...&quot;<br>
<br>
<br>
Today&#39;s Topics:<br>
<br>
   1. [JBoss JIRA] (CDI-504) have a standard CDI annotation like<br>
      @ConfigProperty from deltapsike (James Strachan (JIRA))<br>
   2. [JBoss JIRA] (CDI-504) have a standard CDI annotation like<br>
      @ConfigProperty from deltapsike (Martin Kouba (JIRA))<br>
   3. [JBoss JIRA] (CDI-504) have a standard CDI annotation like<br>
      @ConfigProperty from deltapsike (John Ament (JIRA))<br>
   4. [JBoss JIRA] (CDI-504) have a standard CDI annotation like<br>
      @ConfigProperty from deltapsike (James Strachan (JIRA))<br>
   5. [JBoss JIRA] (CDI-504) have a standard CDI annotation like<br>
      @ConfigProperty from deltapsike (James Strachan (JIRA))<br>
   6. [JBoss JIRA] (CDI-504) have a standard CDI annotation like<br>
      @ConfigProperty from deltapsike (James Strachan (JIRA))<br>
   7. [JBoss JIRA] (CDI-504) have a standard CDI annotation like<br>
      @ConfigProperty from deltapsike (Antoine Sabot-Durand (JIRA))<br>
<br>
<br>
----------------------------------------------------------------------<br>
<br>
Message: 1<br>
Date: Thu, 5 Feb 2015 05:01:49 -0500 (EST)<br>
From: &quot;James Strachan (JIRA)&quot; &lt;<a href="mailto:issues@jboss.org">issues@jboss.org</a>&gt;<br>
Subject: [cdi-dev] [JBoss JIRA] (CDI-504) have a standard CDI<br>
        annotation like @ConfigProperty from deltapsike<br>
To: <a href="mailto:cdi-dev@lists.jboss.org">cdi-dev@lists.jboss.org</a><br>
Message-ID:<br>
        &lt;JIRA.12562481.1423130482000.44616.1423130509034@Atlassian.JIRA&gt;<br>
Content-Type: text/plain; charset=UTF-8<br>
<br>
James Strachan created CDI-504:<br>
----------------------------------<br>
<br>
             Summary: have a standard CDI annotation like @ConfigProperty from deltapsike<br>
                 Key: CDI-504<br>
                 URL: <a href="https://issues.jboss.org/browse/CDI-504" target="_blank">https://issues.jboss.org/browse/CDI-504</a><br>
             Project: CDI Specification Issues<br>
          Issue Type: Feature Request<br>
            Reporter: James Strachan<br>
<br>
<br>
Docker and containerisation is the new hotness; in the docker world images are static and the main way of injecting configuration is via environment variables - so that the same image can be reused but configured at run time with different configuration values. (Changing configuration files requires either different images to be created or using custom volumes which is less ideal in a containerized world).<br>
<br>
So IMHO CDI should provide a simple, natural way to allow environment variables (or system properties) to be easily injected via CDI.<br>
<br>
Delta Spike as a @ConfigProperty annotation which works very nicely<br>
<a href="http://deltaspike.apache.org/documentation/configuration.html" target="_blank">http://deltaspike.apache.org/documentation/configuration.html</a><br>
<br>
you can specify a name, default value and use it on an @Inject to provide a value from env vars, system properties or provide a default.<br>
<br>
Given how core and useful this is - it feels like it should be part of the CDI specification; its one simple annotation.<br>
<br>
Currently deltaspike provides a way to configure different sources and whatnot which is cool; I&#39;d be happy if CDI just had a simpler annotation which was only bound to env vars / system properties.<br>
<br>
e.g. @EnvironmentProperty(name = &quot;envvar&quot;, deafultValue=&quot;cheese&quot;)<br>
<br>
There could be debate on whether env vars or system properties should win if the same name is used for both; in a dockerized world I&#39;d prefer env vars to win but folks can always tinker with their run command to make sure they pass in env vars as system properties to work around this I guess.<br>
<br>
<br>
<br>
--<br>
This message was sent by Atlassian JIRA<br>
(v6.3.11#6341)<br>
<br>
<br>
------------------------------<br>
<br>
Message: 2<br>
Date: Thu, 5 Feb 2015 10:30:50 -0500 (EST)<br>
From: &quot;Martin Kouba (JIRA)&quot; &lt;<a href="mailto:issues@jboss.org">issues@jboss.org</a>&gt;<br>
Subject: [cdi-dev] [JBoss JIRA] (CDI-504) have a standard CDI<br>
        annotation like @ConfigProperty from deltapsike<br>
To: <a href="mailto:cdi-dev@lists.jboss.org">cdi-dev@lists.jboss.org</a><br>
Message-ID:<br>
        &lt;JIRA.12562481.1423130482000.45712.1423150250888@Atlassian.JIRA&gt;<br>
Content-Type: text/plain; charset=UTF-8<br>
<br>
<br>
    [ <a href="https://issues.jboss.org/browse/CDI-504?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&amp;focusedCommentId=13038005#comment-13038005" target="_blank">https://issues.jboss.org/browse/CDI-504?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&amp;focusedCommentId=13038005#comment-13038005</a> ]<br>
<br>
Martin Kouba commented on CDI-504:<br>
----------------------------------<br>
<br>
What&#39;s wrong with {{java.lang.System.getProperty()}} and {{java.lang.System.getenv()}}? I mean the main advantage of DS Configuration is IMO the resolution mechanism and the ability to extend the set of {{ConfigSource}} s. If you only need system properties and env variables a simple producer method and qualifier (or even a simple util method) would be sufficient. In other words I see no reason to standardize this.<br>
<br>
&gt; have a standard CDI annotation like @ConfigProperty from deltapsike<br>
&gt; -------------------------------------------------------------------<br>
&gt;<br>
&gt;                 Key: CDI-504<br>
&gt;                 URL: <a href="https://issues.jboss.org/browse/CDI-504" target="_blank">https://issues.jboss.org/browse/CDI-504</a><br>
&gt;             Project: CDI Specification Issues<br>
&gt;          Issue Type: Feature Request<br>
&gt;            Reporter: James Strachan<br>
&gt;<br>
&gt; Docker and containerisation is the new hotness; in the docker world images are static and the main way of injecting configuration is via environment variables - so that the same image can be reused but configured at run time with different configuration values. (Changing configuration files requires either different images to be created or using custom volumes which is less ideal in a containerized world).<br>
&gt; So IMHO CDI should provide a simple, natural way to allow environment variables (or system properties) to be easily injected via CDI.<br>
&gt; Delta Spike as a @ConfigProperty annotation which works very nicely<br>
&gt; <a href="http://deltaspike.apache.org/documentation/configuration.html" target="_blank">http://deltaspike.apache.org/documentation/configuration.html</a><br>
&gt; you can specify a name, default value and use it on an @Inject to provide a value from env vars, system properties or provide a default.<br>
&gt; Given how core and useful this is - it feels like it should be part of the CDI specification; its one simple annotation.<br>
&gt; Currently deltaspike provides a way to configure different sources and whatnot which is cool; I&#39;d be happy if CDI just had a simpler annotation which was only bound to env vars / system properties.<br>
&gt; e.g. @EnvironmentProperty(name = &quot;envvar&quot;, deafultValue=&quot;cheese&quot;)<br>
&gt; There could be debate on whether env vars or system properties should win if the same name is used for both; in a dockerized world I&#39;d prefer env vars to win but folks can always tinker with their run command to make sure they pass in env vars as system properties to work around this I guess.<br>
<br>
<br>
<br>
--<br>
This message was sent by Atlassian JIRA<br>
(v6.3.11#6341)<br>
<br>
<br>
------------------------------<br>
<br>
Message: 3<br>
Date: Thu, 5 Feb 2015 10:34:49 -0500 (EST)<br>
From: &quot;John Ament (JIRA)&quot; &lt;<a href="mailto:issues@jboss.org">issues@jboss.org</a>&gt;<br>
Subject: [cdi-dev] [JBoss JIRA] (CDI-504) have a standard CDI<br>
        annotation like @ConfigProperty from deltapsike<br>
To: <a href="mailto:cdi-dev@lists.jboss.org">cdi-dev@lists.jboss.org</a><br>
Message-ID:<br>
        &lt;JIRA.12562481.1423130482000.45725.1423150489341@Atlassian.JIRA&gt;<br>
Content-Type: text/plain; charset=UTF-8<br>
<br>
<br>
    [ <a href="https://issues.jboss.org/browse/CDI-504?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&amp;focusedCommentId=13038007#comment-13038007" target="_blank">https://issues.jboss.org/browse/CDI-504?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&amp;focusedCommentId=13038007#comment-13038007</a> ]<br>
<br>
John Ament commented on CDI-504:<br>
--------------------------------<br>
<br>
A separate config JSR has been proposed previously to address this.  They want to see more options before trying to standardize it.<br>
<br>
&gt; have a standard CDI annotation like @ConfigProperty from deltapsike<br>
&gt; -------------------------------------------------------------------<br>
&gt;<br>
&gt;                 Key: CDI-504<br>
&gt;                 URL: <a href="https://issues.jboss.org/browse/CDI-504" target="_blank">https://issues.jboss.org/browse/CDI-504</a><br>
&gt;             Project: CDI Specification Issues<br>
&gt;          Issue Type: Feature Request<br>
&gt;            Reporter: James Strachan<br>
&gt;<br>
&gt; Docker and containerisation is the new hotness; in the docker world images are static and the main way of injecting configuration is via environment variables - so that the same image can be reused but configured at run time with different configuration values. (Changing configuration files requires either different images to be created or using custom volumes which is less ideal in a containerized world).<br>
&gt; So IMHO CDI should provide a simple, natural way to allow environment variables (or system properties) to be easily injected via CDI.<br>
&gt; Delta Spike as a @ConfigProperty annotation which works very nicely<br>
&gt; <a href="http://deltaspike.apache.org/documentation/configuration.html" target="_blank">http://deltaspike.apache.org/documentation/configuration.html</a><br>
&gt; you can specify a name, default value and use it on an @Inject to provide a value from env vars, system properties or provide a default.<br>
&gt; Given how core and useful this is - it feels like it should be part of the CDI specification; its one simple annotation.<br>
&gt; Currently deltaspike provides a way to configure different sources and whatnot which is cool; I&#39;d be happy if CDI just had a simpler annotation which was only bound to env vars / system properties.<br>
&gt; e.g. @EnvironmentProperty(name = &quot;envvar&quot;, deafultValue=&quot;cheese&quot;)<br>
&gt; There could be debate on whether env vars or system properties should win if the same name is used for both; in a dockerized world I&#39;d prefer env vars to win but folks can always tinker with their run command to make sure they pass in env vars as system properties to work around this I guess.<br>
<br>
<br>
<br>
--<br>
This message was sent by Atlassian JIRA<br>
(v6.3.11#6341)<br>
<br>
<br>
------------------------------<br>
<br>
Message: 4<br>
Date: Thu, 5 Feb 2015 10:39:49 -0500 (EST)<br>
From: &quot;James Strachan (JIRA)&quot; &lt;<a href="mailto:issues@jboss.org">issues@jboss.org</a>&gt;<br>
Subject: [cdi-dev] [JBoss JIRA] (CDI-504) have a standard CDI<br>
        annotation like @ConfigProperty from deltapsike<br>
To: <a href="mailto:cdi-dev@lists.jboss.org">cdi-dev@lists.jboss.org</a><br>
Message-ID:<br>
        &lt;JIRA.12562481.1423130482000.45741.1423150789541@Atlassian.JIRA&gt;<br>
Content-Type: text/plain; charset=UTF-8<br>
<br>
<br>
    [ <a href="https://issues.jboss.org/browse/CDI-504?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&amp;focusedCommentId=13038012#comment-13038012" target="_blank">https://issues.jboss.org/browse/CDI-504?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&amp;focusedCommentId=13038012#comment-13038012</a> ]<br>
<br>
James Strachan commented on CDI-504:<br>
------------------------------------<br>
<br>
@Resource is supported - injecting values from JNDI. I don&#39;t see why injecting values (with a default value) from the environment isn&#39;t also supported too. There&#39;s a Java API for JNDI too so folks could look stuff up in JNDI by hand and do the type conversions - but we&#39;ve injection for those values.<br>
<br>
Its also much cleaner code and can easily deal generically with type conversion to long/double/float/date etc.<br>
<br>
Compare:<br>
{code}<br>
@Inject Foo(int bar, ...) {<br>
bar = System.getenv(&quot;FOO&quot;);<br>
if (bar == null) {<br>
   bar = &quot;someDefault&quot;;<br>
}<br>
// now convert to a String with error handling....<br>
}<br>
{code}<br>
to just:<br>
{code}<br>
@Inject Foo(@Environment(&quot;FOO&quot;, &quot;someDefault&quot;) int bar, ...) {<br>
}<br>
{code}<br>
<br>
Also by using an annotation it means its very easy to generate documentation and tooling. (e.g. using APT you can know what all the environment variables are used by CDI; either to report on demand or to generate user documentation).<br>
<br>
<br>
<br>
&gt; have a standard CDI annotation like @ConfigProperty from deltapsike<br>
&gt; -------------------------------------------------------------------<br>
&gt;<br>
&gt;                 Key: CDI-504<br>
&gt;                 URL: <a href="https://issues.jboss.org/browse/CDI-504" target="_blank">https://issues.jboss.org/browse/CDI-504</a><br>
&gt;             Project: CDI Specification Issues<br>
&gt;          Issue Type: Feature Request<br>
&gt;            Reporter: James Strachan<br>
&gt;<br>
&gt; Docker and containerisation is the new hotness; in the docker world images are static and the main way of injecting configuration is via environment variables - so that the same image can be reused but configured at run time with different configuration values. (Changing configuration files requires either different images to be created or using custom volumes which is less ideal in a containerized world).<br>
&gt; So IMHO CDI should provide a simple, natural way to allow environment variables (or system properties) to be easily injected via CDI.<br>
&gt; Delta Spike as a @ConfigProperty annotation which works very nicely<br>
&gt; <a href="http://deltaspike.apache.org/documentation/configuration.html" target="_blank">http://deltaspike.apache.org/documentation/configuration.html</a><br>
&gt; you can specify a name, default value and use it on an @Inject to provide a value from env vars, system properties or provide a default.<br>
&gt; Given how core and useful this is - it feels like it should be part of the CDI specification; its one simple annotation.<br>
&gt; Currently deltaspike provides a way to configure different sources and whatnot which is cool; I&#39;d be happy if CDI just had a simpler annotation which was only bound to env vars / system properties.<br>
&gt; e.g. @EnvironmentProperty(name = &quot;envvar&quot;, deafultValue=&quot;cheese&quot;)<br>
&gt; There could be debate on whether env vars or system properties should win if the same name is used for both; in a dockerized world I&#39;d prefer env vars to win but folks can always tinker with their run command to make sure they pass in env vars as system properties to work around this I guess.<br>
<br>
<br>
<br>
--<br>
This message was sent by Atlassian JIRA<br>
(v6.3.11#6341)<br>
<br>
<br>
------------------------------<br>
<br>
Message: 5<br>
Date: Thu, 5 Feb 2015 10:49:49 -0500 (EST)<br>
From: &quot;James Strachan (JIRA)&quot; &lt;<a href="mailto:issues@jboss.org">issues@jboss.org</a>&gt;<br>
Subject: [cdi-dev] [JBoss JIRA] (CDI-504) have a standard CDI<br>
        annotation like @ConfigProperty from deltapsike<br>
To: <a href="mailto:cdi-dev@lists.jboss.org">cdi-dev@lists.jboss.org</a><br>
Message-ID:<br>
        &lt;JIRA.12562481.1423130482000.45763.1423151389408@Atlassian.JIRA&gt;<br>
Content-Type: text/plain; charset=UTF-8<br>
<br>
<br>
    [ <a href="https://issues.jboss.org/browse/CDI-504?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&amp;focusedCommentId=13038012#comment-13038012" target="_blank">https://issues.jboss.org/browse/CDI-504?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&amp;focusedCommentId=13038012#comment-13038012</a> ]<br>
<br>
James Strachan edited comment on CDI-504 at 2/5/15 10:49 AM:<br>
-------------------------------------------------------------<br>
<br>
@Resource is supported - injecting values from JNDI. I don&#39;t see why injecting values (with a default value) from the environment isn&#39;t also supported too. There&#39;s a Java API for JNDI too so folks could look stuff up in JNDI by hand and do the type conversions - but we&#39;ve injection for those values.<br>
<br>
Its also much cleaner code and can easily deal generically with type conversion to long/double/float/date etc.<br>
<br>
Compare:<br>
{code}<br>
@Inject Foo(int bar, ...) {<br>
bar = System.getenv(&quot;FOO&quot;);<br>
if (bar == null) {<br>
   bar = &quot;someDefault&quot;;<br>
}<br>
// now convert the String to an int with nice error handling and reporting....<br>
}<br>
{code}<br>
to just:<br>
{code}<br>
@Inject Foo(@Environment(&quot;FOO&quot;, &quot;someDefault&quot;) int bar, ...) {<br>
}<br>
{code}<br>
<br>
Also by using an annotation it means its very easy to generate documentation and tooling. (e.g. using APT you can know what all the environment variables are used by CDI; either to report on demand or to generate user documentation).<br>
<br>
<br>
<br>
<br>
was (Author: jastrachan):<br>
@Resource is supported - injecting values from JNDI. I don&#39;t see why injecting values (with a default value) from the environment isn&#39;t also supported too. There&#39;s a Java API for JNDI too so folks could look stuff up in JNDI by hand and do the type conversions - but we&#39;ve injection for those values.<br>
<br>
Its also much cleaner code and can easily deal generically with type conversion to long/double/float/date etc.<br>
<br>
Compare:<br>
{code}<br>
@Inject Foo(int bar, ...) {<br>
bar = System.getenv(&quot;FOO&quot;);<br>
if (bar == null) {<br>
   bar = &quot;someDefault&quot;;<br>
}<br>
// now convert to a String with error handling....<br>
}<br>
{code}<br>
to just:<br>
{code}<br>
@Inject Foo(@Environment(&quot;FOO&quot;, &quot;someDefault&quot;) int bar, ...) {<br>
}<br>
{code}<br>
<br>
Also by using an annotation it means its very easy to generate documentation and tooling. (e.g. using APT you can know what all the environment variables are used by CDI; either to report on demand or to generate user documentation).<br>
<br>
<br>
<br>
&gt; have a standard CDI annotation like @ConfigProperty from deltapsike<br>
&gt; -------------------------------------------------------------------<br>
&gt;<br>
&gt;                 Key: CDI-504<br>
&gt;                 URL: <a href="https://issues.jboss.org/browse/CDI-504" target="_blank">https://issues.jboss.org/browse/CDI-504</a><br>
&gt;             Project: CDI Specification Issues<br>
&gt;          Issue Type: Feature Request<br>
&gt;            Reporter: James Strachan<br>
&gt;<br>
&gt; Docker and containerisation is the new hotness; in the docker world images are static and the main way of injecting configuration is via environment variables - so that the same image can be reused but configured at run time with different configuration values. (Changing configuration files requires either different images to be created or using custom volumes which is less ideal in a containerized world).<br>
&gt; So IMHO CDI should provide a simple, natural way to allow environment variables (or system properties) to be easily injected via CDI.<br>
&gt; Delta Spike as a @ConfigProperty annotation which works very nicely<br>
&gt; <a href="http://deltaspike.apache.org/documentation/configuration.html" target="_blank">http://deltaspike.apache.org/documentation/configuration.html</a><br>
&gt; you can specify a name, default value and use it on an @Inject to provide a value from env vars, system properties or provide a default.<br>
&gt; Given how core and useful this is - it feels like it should be part of the CDI specification; its one simple annotation.<br>
&gt; Currently deltaspike provides a way to configure different sources and whatnot which is cool; I&#39;d be happy if CDI just had a simpler annotation which was only bound to env vars / system properties.<br>
&gt; e.g. @EnvironmentProperty(name = &quot;envvar&quot;, deafultValue=&quot;cheese&quot;)<br>
&gt; There could be debate on whether env vars or system properties should win if the same name is used for both; in a dockerized world I&#39;d prefer env vars to win but folks can always tinker with their run command to make sure they pass in env vars as system properties to work around this I guess.<br>
<br>
<br>
<br>
--<br>
This message was sent by Atlassian JIRA<br>
(v6.3.11#6341)<br>
<br>
<br>
------------------------------<br>
<br>
Message: 6<br>
Date: Thu, 5 Feb 2015 10:50:49 -0500 (EST)<br>
From: &quot;James Strachan (JIRA)&quot; &lt;<a href="mailto:issues@jboss.org">issues@jboss.org</a>&gt;<br>
Subject: [cdi-dev] [JBoss JIRA] (CDI-504) have a standard CDI<br>
        annotation like @ConfigProperty from deltapsike<br>
To: <a href="mailto:cdi-dev@lists.jboss.org">cdi-dev@lists.jboss.org</a><br>
Message-ID:<br>
        &lt;JIRA.12562481.1423130482000.45773.1423151449139@Atlassian.JIRA&gt;<br>
Content-Type: text/plain; charset=UTF-8<br>
<br>
<br>
    [ <a href="https://issues.jboss.org/browse/CDI-504?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&amp;focusedCommentId=13038012#comment-13038012" target="_blank">https://issues.jboss.org/browse/CDI-504?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&amp;focusedCommentId=13038012#comment-13038012</a> ]<br>
<br>
James Strachan edited comment on CDI-504 at 2/5/15 10:50 AM:<br>
-------------------------------------------------------------<br>
<br>
@Resource is supported - injecting values from JNDI. I don&#39;t see why injecting values (with a default value) from the environment isn&#39;t also supported too. There&#39;s a Java API for JNDI too so folks could look stuff up in JNDI by hand and do the type conversions - but we&#39;ve injection for those values.<br>
<br>
Its also much cleaner code and can easily deal generically with type conversion to long/double/float/date etc.<br>
<br>
Compare:<br>
{code}<br>
int bar;<br>
@Inject Foo() {<br>
barText = System.getenv(&quot;FOO&quot;);<br>
if (barText == null) {<br>
   barText = &quot;someDefault&quot;;<br>
}<br>
// now convert the String to an int with nice error handling and reporting....<br>
bar = someConvertCode(barText);<br>
}<br>
{code}<br>
to just:<br>
{code}<br>
@Inject Foo(@Environment(&quot;FOO&quot;, &quot;someDefault&quot;) int bar, ...) {<br>
}<br>
{code}<br>
<br>
Note that in the second case, folks could use the constructor explicitly without being bound to environment variables too; much cleaner, more modular code.<br>
<br>
Also by using an annotation it means its very easy to generate documentation and tooling. (e.g. using APT you can know what all the environment variables are used by CDI; either to report on demand or to generate user documentation).<br>
<br>
<br>
<br>
<br>
was (Author: jastrachan):<br>
@Resource is supported - injecting values from JNDI. I don&#39;t see why injecting values (with a default value) from the environment isn&#39;t also supported too. There&#39;s a Java API for JNDI too so folks could look stuff up in JNDI by hand and do the type conversions - but we&#39;ve injection for those values.<br>
<br>
Its also much cleaner code and can easily deal generically with type conversion to long/double/float/date etc.<br>
<br>
Compare:<br>
{code}<br>
@Inject Foo(int bar, ...) {<br>
bar = System.getenv(&quot;FOO&quot;);<br>
if (bar == null) {<br>
   bar = &quot;someDefault&quot;;<br>
}<br>
// now convert the String to an int with nice error handling and reporting....<br>
}<br>
{code}<br>
to just:<br>
{code}<br>
@Inject Foo(@Environment(&quot;FOO&quot;, &quot;someDefault&quot;) int bar, ...) {<br>
}<br>
{code}<br>
<br>
Also by using an annotation it means its very easy to generate documentation and tooling. (e.g. using APT you can know what all the environment variables are used by CDI; either to report on demand or to generate user documentation).<br>
<br>
<br>
<br>
&gt; have a standard CDI annotation like @ConfigProperty from deltapsike<br>
&gt; -------------------------------------------------------------------<br>
&gt;<br>
&gt;                 Key: CDI-504<br>
&gt;                 URL: <a href="https://issues.jboss.org/browse/CDI-504" target="_blank">https://issues.jboss.org/browse/CDI-504</a><br>
&gt;             Project: CDI Specification Issues<br>
&gt;          Issue Type: Feature Request<br>
&gt;            Reporter: James Strachan<br>
&gt;<br>
&gt; Docker and containerisation is the new hotness; in the docker world images are static and the main way of injecting configuration is via environment variables - so that the same image can be reused but configured at run time with different configuration values. (Changing configuration files requires either different images to be created or using custom volumes which is less ideal in a containerized world).<br>
&gt; So IMHO CDI should provide a simple, natural way to allow environment variables (or system properties) to be easily injected via CDI.<br>
&gt; Delta Spike as a @ConfigProperty annotation which works very nicely<br>
&gt; <a href="http://deltaspike.apache.org/documentation/configuration.html" target="_blank">http://deltaspike.apache.org/documentation/configuration.html</a><br>
&gt; you can specify a name, default value and use it on an @Inject to provide a value from env vars, system properties or provide a default.<br>
&gt; Given how core and useful this is - it feels like it should be part of the CDI specification; its one simple annotation.<br>
&gt; Currently deltaspike provides a way to configure different sources and whatnot which is cool; I&#39;d be happy if CDI just had a simpler annotation which was only bound to env vars / system properties.<br>
&gt; e.g. @EnvironmentProperty(name = &quot;envvar&quot;, deafultValue=&quot;cheese&quot;)<br>
&gt; There could be debate on whether env vars or system properties should win if the same name is used for both; in a dockerized world I&#39;d prefer env vars to win but folks can always tinker with their run command to make sure they pass in env vars as system properties to work around this I guess.<br>
<br>
<br>
<br>
--<br>
This message was sent by Atlassian JIRA<br>
(v6.3.11#6341)<br>
<br>
<br>
------------------------------<br>
<br>
Message: 7<br>
Date: Fri, 6 Feb 2015 05:02:49 -0500 (EST)<br>
From: &quot;Antoine Sabot-Durand (JIRA)&quot; &lt;<a href="mailto:issues@jboss.org">issues@jboss.org</a>&gt;<br>
Subject: [cdi-dev] [JBoss JIRA] (CDI-504) have a standard CDI<br>
        annotation like @ConfigProperty from deltapsike<br>
To: <a href="mailto:cdi-dev@lists.jboss.org">cdi-dev@lists.jboss.org</a><br>
Message-ID:<br>
        &lt;JIRA.12562481.1423130482000.47108.1423216969246@Atlassian.JIRA&gt;<br>
Content-Type: text/plain; charset=UTF-8<br>
<br>
<br>
    [ <a href="https://issues.jboss.org/browse/CDI-504?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&amp;focusedCommentId=13038271#comment-13038271" target="_blank">https://issues.jboss.org/browse/CDI-504?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&amp;focusedCommentId=13038271#comment-13038271</a> ]<br>
<br>
Antoine Sabot-Durand commented on CDI-504:<br>
------------------------------------------<br>
<br>
James, I don&#39;t get what&#39;s the problem with using DeltaSpike config solution?<br>
<br>
&gt; have a standard CDI annotation like @ConfigProperty from deltapsike<br>
&gt; -------------------------------------------------------------------<br>
&gt;<br>
&gt;                 Key: CDI-504<br>
&gt;                 URL: <a href="https://issues.jboss.org/browse/CDI-504" target="_blank">https://issues.jboss.org/browse/CDI-504</a><br>
&gt;             Project: CDI Specification Issues<br>
&gt;          Issue Type: Feature Request<br>
&gt;            Reporter: James Strachan<br>
&gt;<br>
&gt; Docker and containerisation is the new hotness; in the docker world images are static and the main way of injecting configuration is via environment variables - so that the same image can be reused but configured at run time with different configuration values. (Changing configuration files requires either different images to be created or using custom volumes which is less ideal in a containerized world).<br>
&gt; So IMHO CDI should provide a simple, natural way to allow environment variables (or system properties) to be easily injected via CDI.<br>
&gt; Delta Spike as a @ConfigProperty annotation which works very nicely<br>
&gt; <a href="http://deltaspike.apache.org/documentation/configuration.html" target="_blank">http://deltaspike.apache.org/documentation/configuration.html</a><br>
&gt; you can specify a name, default value and use it on an @Inject to provide a value from env vars, system properties or provide a default.<br>
&gt; Given how core and useful this is - it feels like it should be part of the CDI specification; its one simple annotation.<br>
&gt; Currently deltaspike provides a way to configure different sources and whatnot which is cool; I&#39;d be happy if CDI just had a simpler annotation which was only bound to env vars / system properties.<br>
&gt; e.g. @EnvironmentProperty(name = &quot;envvar&quot;, deafultValue=&quot;cheese&quot;)<br>
&gt; There could be debate on whether env vars or system properties should win if the same name is used for both; in a dockerized world I&#39;d prefer env vars to win but folks can always tinker with their run command to make sure they pass in env vars as system properties to work around this I guess.<br>
<br>
<br>
<br>
--<br>
This message was sent by Atlassian JIRA<br>
(v6.3.11#6341)<br>
<br>
<br>
------------------------------<br>
<br>
_______________________________________________<br>
cdi-dev mailing list<br>
<a href="mailto:cdi-dev@lists.jboss.org">cdi-dev@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/cdi-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/cdi-dev</a><br>
<br>
Note that for all code provided on this list, the provider licenses the code under the Apache License, Version 2 (<a href="http://www.apache.org/licenses/LICENSE-2.0.html" target="_blank">http://www.apache.org/licenses/LICENSE-2.0.html</a>).  For all other ideas provided on this list, the provider waives all patent and other intellectual property rights inherent in such information.<br>
<br>
End of cdi-dev Digest, Vol 51, Issue 9<br>
**************************************<br>
</blockquote></div><br></div></div>