Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You have three solutions to your need:</p> <h2>Use a producer</h2> <p>CDI provides a way to transform non CDI class in beans. It is called a producer. If you want to create a bean from a class named <code>NonCdiClass</code> You only have to create something like that </p> <pre><code>public class MyProducers { @Produces public NonCdiClass produceNonCdiClass() { return new NonCdiClass(); }; } } </code></pre> <p>You can now <code>@Inject</code> this bean when needed.</p> <p>You can put as many producer method as you want in your class.</p> <p>If you need to simulate injection in your produced bean you can do it thanks to CDI that injects parameters in producer methods calls.</p> <pre><code>@Produces public NonCdiClass produceNonCdiClass(MyFisrtBean param1, MySecondBean param2) { NonCdiClass res = new NonCdiClass(param1); res.setParam(param2); return res; }; } </code></pre> <p>In this example <code>MyFirstBean</code> and <code>MySecondBean</code> are existing bean classes that will be injected by CDI at producing time.</p> <p>Producers can also have Qualifiers (on them or on their parameters) or inject the <code>InjectionPoint</code> which is a CDI internal bean allowing you to produce your bean differently in function of where is the injection and what annotation it has.</p> <p>You have a nice <code>InjectionPoint</code> example in <a href="http://docs.jboss.org/weld/reference/1.1.5.Final/en-US/html_single/#d0e1624" rel="nofollow">Weld reference documentation</a>.</p> <h2>Develop an extension</h2> <p>I won't go into much details here since I don't know if it's your need, but you can register bean in an extension in the AfterBeanValidation phase. These registered beans can be of any class you want. Should you need more info I could develop here.</p> <h2>Use Seam Solder (legacy) or wait for Deltaspike 0.6</h2> <p>Solder integrated a <a href="http://docs.jboss.org/seam/3/solder/latest/reference/en-US/html_single/#part4" rel="nofollow">config module</a> but this project is no more maintained since it's been in the process to be merged in <a href="http://deltaspike.org" rel="nofollow">Apache Deltaspike</a>. This merge is in Deltaspike roadmap for version 0.6: <a href="http://issues.apache.org/jira/browse/DELTASPIKE-271" rel="nofollow">http://issues.apache.org/jira/browse/DELTASPIKE-271</a>. So you could start using Solder config and switch to Deltaspike when it'll have the feature (which should be quite close). This solution is not my favorite but if you really want to have a config file à la Spring, it's the closest solution</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.
    3. VO
      singulars
      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