<html><head></head><body><div style="font-family:Helvetica Neue, Helvetica, Arial, sans-serif;font-size:16px;"><div>you could look at Apache DeltaSpike @Configuration and he whole DS config mechanism.</div><div><br></div><div><a href="http://deltaspike.apache.org/documentation/configuration.html" rel="nofollow" target="_blank">http://deltaspike.apache.org/documentation/configuration.html</a></div><div><br></div><div>It's battle proven and also the origin of microprofile-config and JSR-382.</div><div>Runs on anything EE6 ++, from Java7 to Java10</div><div><br></div><div>LieGrue,</div><div>strub</div><div><br></div>
<div><br></div><div><br></div>
<div id="yahoo_quoted_3014636097" class="yahoo_quoted">
<div style="font-family:'Helvetica Neue', Helvetica, Arial, sans-serif;font-size:13px;color:#26282a;">
<div>
On Tuesday, 3 April 2018, 10:25:38 CEST, Matej Novotny <manovotn@redhat.com> wrote:
</div>
<div><br></div>
<div><br></div>
<div><div dir="ltr">Hi Alex,<br></div><div dir="ltr"><br></div><div dir="ltr">Not sure if I get what you need to do, but I'll take a shot at it.<br></div><div dir="ltr">What about using @PostConstruct interceptor, in which you take the injected Application bean and use it to set internal state in SomeManagerImpl?<br></div><div dir="ltr">Same could be done directly within constructor (with @Inject annotation) or an initializer method.<br></div><div dir="ltr"><br></div><div dir="ltr">E.g.<br></div><div dir="ltr"><br></div><div dir="ltr">@ApplicationScoped<br></div><div dir="ltr">public class SomeManagerImpl implements SomeManager{} {<br></div><div dir="ltr"><br></div><div dir="ltr"> private MyConfiguration config;<br></div><div dir="ltr"><br></div><div dir="ltr"> @Inject<br></div><div dir="ltr"> Application app;<br></div><div dir="ltr"><br></div><div dir="ltr"> @PostConstruct<br></div><div dir="ltr"> public void doSomeInit() {<br></div><div dir="ltr"> config = app.getConfig(); // get config from Application and appply here<br></div><div dir="ltr"> }<br></div><div dir="ltr">}<br></div><div dir="ltr"><br></div><div dir="ltr">If I misunderstood your question, please correct me :)<br></div><div dir="ltr"><br></div><div dir="ltr">Matej<br></div><div dir="ltr"><br></div><div dir="ltr"><br></div><div dir="ltr">----- Original Message -----<br></div><div dir="ltr">> From: "Alex Sviridov" <<a ymailto="mailto:ooo_saturn7@mail.ru" href="mailto:ooo_saturn7@mail.ru">ooo_saturn7@mail.ru</a>><br></div><div dir="ltr">> To: "weld-dev" <<a ymailto="mailto:weld-dev@lists.jboss.org" href="mailto:weld-dev@lists.jboss.org">weld-dev@lists.jboss.org</a>><br></div><div dir="ltr">> Sent: Saturday, March 31, 2018 1:07:59 PM<br></div><div dir="ltr">> Subject: [weld-dev] What is the best way to pass cofiguration to CDI bean using Weld?<br></div><div dir="ltr">> <br></div><div dir="ltr">> Hi all<br></div><div dir="ltr">> <br></div><div dir="ltr">> Could anyone suggest solution for the following situation.<br></div><div dir="ltr">> Lets suppose we have:<br></div><div dir="ltr">> <br></div><div dir="ltr">> public interface SomeManager{}<br></div><div dir="ltr">> <br></div><div dir="ltr">> @ApplicationScoped<br></div><div dir="ltr">> public class SomeManagerImpl implements SomeManager{}<br></div><div dir="ltr">> <br></div><div dir="ltr">> @ApplicationScoped<br></div><div dir="ltr">> public class Application {} //application entry point<br></div><div dir="ltr">> <br></div><div dir="ltr">> In Application I need to pass configuration to SomeManagerImpl, but I don't<br></div><div dir="ltr">> want to<br></div><div dir="ltr">> add setConfiguration method to SomeManager interface. What is the best way<br></div><div dir="ltr">> to do it in Weld? Maybe I use some CDI mechanisms, or add extra classes.<br></div><div dir="ltr">> Please, help.<br></div><div dir="ltr">> <br></div><div dir="ltr">> Best regards, Alex Sviridov<br></div><div dir="ltr">> <br></div><div dir="ltr">> _______________________________________________<br></div><div dir="ltr">> weld-dev mailing list<br></div><div dir="ltr">> <a ymailto="mailto:weld-dev@lists.jboss.org" href="mailto:weld-dev@lists.jboss.org">weld-dev@lists.jboss.org</a><br></div><div dir="ltr">> <a href="https://lists.jboss.org/mailman/listinfo/weld-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/weld-dev</a><br></div><div dir="ltr">_______________________________________________<br></div><div dir="ltr">weld-dev mailing list<br></div><div dir="ltr"><a ymailto="mailto:weld-dev@lists.jboss.org" href="mailto:weld-dev@lists.jboss.org">weld-dev@lists.jboss.org</a><br></div><div dir="ltr"><a href="https://lists.jboss.org/mailman/listinfo/weld-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/weld-dev</a><br></div></div>
</div>
</div></div></body></html>