Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>CDI is a specification about Dependecy Injection and Context so it doesn't have such configuration things out of the box. But it also provides a very powerful extension mechanism that allows third party projects to add new portable features (i.e that works with all CDI implementation and that are not tied to a server). The most important project providing CDI extensions is <a href="http://deltaspike.apache.org" rel="nofollow">Apache Deltaspike</a> and good news, it provides what you need.</p> <p>So you need to add deltaspike-core in your project. If you use Maven, you need to add this dependencies to your pom.xml</p> <pre><code> &lt;dependency&gt; &lt;groupId&gt;org.apache.deltaspike.core&lt;/groupId&gt; &lt;artifactId&gt;deltaspike-core-api&lt;/artifactId&gt; &lt;version&gt;0.4&lt;/version&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;org.apache.deltaspike.core&lt;/groupId&gt; &lt;artifactId&gt;deltaspike-core-impl&lt;/artifactId&gt; &lt;version&gt;0.4&lt;/version&gt; &lt;/dependency&gt; </code></pre> <p>After that if you don't care about your properties filename, just add <code>META-INF/apache-deltaspike.properties</code> to your project and put your properties in it. If you need more than one file or want to choose the name you'll have to implement <code>PropertyFileConfig</code> interface for each file like this :</p> <pre><code>public class MyCustomPropertyFileConfig implements PropertyFileConfig { @Override public String getPropertyFileName() { return "myconfig.properties"; } } </code></pre> <p>After that you'll be able to inject values like this </p> <pre><code>@ApplicationScoped public class SomeRandomService { @Inject @ConfigProperty(name = "endpoint.poll.interval") private Integer pollInterval; @Inject @ConfigProperty(name = "endpoint.poll.servername") private String pollUrl; ... } </code></pre> <p>As you see in this example taken from Deltaspike documentation, you can inject your value in String but also in Integer, Long, Float, Boolean fields. You could provide your own type if you need something more specific. Deltaspike config documentation can be found <a href="https://deltaspike.apache.org/documentation/configuration.html" rel="nofollow">here</a>. </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload