<div dir="ltr">Köszönöm.<div><br></div><div>Elvi gondom van vele, hogy miért kell megmondanom, hogy konstruktor injektor. Az osztály dolga, meg a framework-é, hogy hogyan adja oda neki. Nekem a konfigurációban csak azt kell(ene) megmondanom, hogy mit adjon oda.</div></div><br><div class="gmail_quote"><div dir="ltr">On Tue, Nov 1, 2016 at 1:27 PM István Székely <<a href="mailto:istvan.szekely1@gmail.com">istvan.szekely1@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr" class="gmail_msg">Szia!<div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">Ezt akkor is át kell írnod, ha XML konfigurációt használsz. <property .../> vagy <constructor-arg .../> , magától akkor sem tudja a Spring.</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">Üdv,</div><div class="gmail_msg">Stivi</div><div class="gmail_msg"><br class="gmail_msg"></div></div><div class="gmail_extra gmail_msg"><br class="gmail_msg"><div class="gmail_quote gmail_msg">2016. november 1. 12:01 Peter Verhas írta, <span dir="ltr" class="gmail_msg"><<a href="mailto:peter@verhas.com" class="gmail_msg" target="_blank">peter@verhas.com</a>></span>:<br class="gmail_msg"><blockquote class="gmail_quote gmail_msg" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr" class="gmail_msg">Van egy interface<div class="gmail_msg"><pre style="font-family:menlo;font-size:9pt" class="gmail_msg"><span style="color:rgb(0,0,128);font-weight:bold" class="gmail_msg">public interface </span>ProductLookup {<br class="gmail_msg"> String getParam();<br class="gmail_msg"><br class="gmail_msg"> ProductInformation byId(String id);<br class="gmail_msg"><br class="gmail_msg"> List<String> byQuery(String query);<br class="gmail_msg">}</pre><pre style="font-family:menlo;font-size:9pt" class="gmail_msg">van több implementációja, az egyik</pre><pre style="font-family:menlo;font-size:9pt" class="gmail_msg"><br class="gmail_msg"></pre><pre style="font-family:menlo;font-size:9pt" class="gmail_msg"><span style="color:rgb(0,0,128);font-weight:bold" class="gmail_msg">public class </span>ResourceBasedProductLookup <span style="color:rgb(0,0,128);font-weight:bold" class="gmail_msg">implements </span>ProductLookup {<br class="gmail_msg"> <br class="gmail_msg"> <span style="color:rgb(0,0,128);font-weight:bold" class="gmail_msg">private </span>String <span style="color:rgb(102,14,122);font-weight:bold" class="gmail_msg">param</span>;<br class="gmail_msg"><br class="gmail_msg"> <span style="color:rgb(0,0,128);font-weight:bold" class="gmail_msg">public void </span>setParam(String param) {<br class="gmail_msg"> <span style="color:rgb(0,0,128);font-weight:bold" class="gmail_msg">this</span>.<span style="color:rgb(102,14,122);font-weight:bold" class="gmail_msg">param </span>= param;<br class="gmail_msg"> }<br class="gmail_msg"><br class="gmail_msg"> <span style="color:rgb(0,0,128);font-weight:bold" class="gmail_msg">public </span>String getParam() {<br class="gmail_msg"><br class="gmail_msg"> <span style="color:rgb(0,0,128);font-weight:bold" class="gmail_msg">return </span><span style="color:rgb(102,14,122);font-weight:bold" class="gmail_msg">param</span>;<br class="gmail_msg"> }<br class="gmail_msg"></pre><pre style="font-family:menlo;font-size:9pt" class="gmail_msg">(folytatódik...)</pre><pre style="font-family:menlo;font-size:9pt" class="gmail_msg">A spring konfiguráció</pre><pre style="font-family:menlo;font-size:9pt" class="gmail_msg"><span style="color:rgb(128,128,0)" class="gmail_msg">@Configuration</span><span style="color:rgb(128,128,0)" class="gmail_msg"><br class="gmail_msg"></span><span style="color:rgb(0,0,128);font-weight:bold" class="gmail_msg">public class </span>SpringConfiguration {<br class="gmail_msg"><br class="gmail_msg"> <span style="color:rgb(128,128,0)" class="gmail_msg">@Bean @Primary<br class="gmail_msg"></span><span style="color:rgb(128,128,0)" class="gmail_msg"> </span><span style="color:rgb(0,0,128);font-weight:bold" class="gmail_msg">public </span>ProductLookup productLookup(){<br class="gmail_msg"><br class="gmail_msg"> ResourceBasedProductLookup pl = <span style="color:rgb(0,0,128);font-weight:bold" class="gmail_msg">new </span>ResourceBasedProductLookup();<br class="gmail_msg"> pl.setParam(<span style="color:rgb(0,128,0);font-weight:bold" class="gmail_msg">"hukk"</span>);<br class="gmail_msg"> <span style="color:rgb(0,0,128);font-weight:bold" class="gmail_msg">return </span>pl;<br class="gmail_msg"> }</pre><pre style="font-family:menlo;font-size:9pt" class="gmail_msg">tud róla, hogy ez egy setter injection. Miért? Ha átírom konstruktor injekcióra a konfigurációnak erről nem kellene tudnia. Nem az ő dolga.</pre><pre style="font-family:menlo;font-size:9pt" class="gmail_msg"><br class="gmail_msg"></pre><pre style="font-family:menlo;font-size:9pt" class="gmail_msg">Ezt nem értem.</pre><pre style="font-family:menlo;font-size:9pt" class="gmail_msg"><br class="gmail_msg"></pre></div></div><br class="gmail_msg"><div class="gmail_quote gmail_msg"><div dir="ltr" class="gmail_msg">On Mon, Oct 31, 2016 at 10:38 AM Zsombor <<a href="mailto:gzsombor@gmail.com" class="gmail_msg" target="_blank">gzsombor@gmail.com</a>> wrote:<br class="gmail_msg"></div><blockquote class="gmail_quote gmail_msg" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr" class="m_8150047022728850352m_3992281679383646610gmail_msg gmail_msg"><div class="m_8150047022728850352m_3992281679383646610gmail_msg gmail_msg">Nem teljesen értem, de azt hiszem a válasz a kérdésre igen. Az elég zavarossá tenné az inicializálást, ha valamely mezők konstruktorban inicializálódnának, valamelyeket meg utána a spring bele-mágiázná. <br class="m_8150047022728850352m_3992281679383646610gmail_msg gmail_msg"></div><div class="m_8150047022728850352m_3992281679383646610gmail_msg gmail_msg">Jobb, szerintem, teljesen a spring-re bízni a bean létrehozást, és csak a legszükségesebbeket manuálisan életre pofozgatni.<br class="m_8150047022728850352m_3992281679383646610gmail_msg gmail_msg"><br class="m_8150047022728850352m_3992281679383646610gmail_msg gmail_msg"></div><div class="m_8150047022728850352m_3992281679383646610gmail_msg gmail_msg">Zs<br class="m_8150047022728850352m_3992281679383646610gmail_msg gmail_msg"></div><div class="m_8150047022728850352m_3992281679383646610gmail_msg gmail_msg"><br class="m_8150047022728850352m_3992281679383646610gmail_msg gmail_msg"></div><div class="m_8150047022728850352m_3992281679383646610gmail_msg gmail_msg"><br class="m_8150047022728850352m_3992281679383646610gmail_msg gmail_msg"></div></div><div class="gmail_extra m_8150047022728850352m_3992281679383646610gmail_msg gmail_msg"><br class="m_8150047022728850352m_3992281679383646610gmail_msg gmail_msg"><div class="gmail_quote m_8150047022728850352m_3992281679383646610gmail_msg gmail_msg"></div></div><div class="gmail_extra m_8150047022728850352m_3992281679383646610gmail_msg gmail_msg"><div class="gmail_quote m_8150047022728850352m_3992281679383646610gmail_msg gmail_msg">2016-10-31 9:47 GMT+01:00 Peter Verhas <span dir="ltr" class="m_8150047022728850352m_3992281679383646610gmail_msg gmail_msg"><<a href="mailto:peter@verhas.com" class="m_8150047022728850352m_3992281679383646610gmail_msg gmail_msg" target="_blank">peter@verhas.com</a>></span>:<br class="m_8150047022728850352m_3992281679383646610gmail_msg gmail_msg"></div></div><div class="gmail_extra m_8150047022728850352m_3992281679383646610gmail_msg gmail_msg"><div class="gmail_quote m_8150047022728850352m_3992281679383646610gmail_msg gmail_msg"><blockquote class="gmail_quote m_8150047022728850352m_3992281679383646610gmail_msg gmail_msg" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr" class="m_8150047022728850352m_3992281679383646610gmail_msg gmail_msg">Amikor egy Java nyelvű konfigurációs osztállyal kofigurálom a Spring-et, akkor jól látom, hogy a @Bean metódusok nincsenek szétválasztva az injektálás implementációjától? Ha tehát egy mezőt eddig setter-rel injektáltam és mostantól konstruktorban szeretném, akkor meg kell változtatnom a @Bean metódust a konfigurációban?</div>
<br class="m_8150047022728850352m_3992281679383646610gmail_msg gmail_msg"></blockquote></div></div><div class="gmail_extra m_8150047022728850352m_3992281679383646610gmail_msg gmail_msg"><div class="gmail_quote m_8150047022728850352m_3992281679383646610gmail_msg gmail_msg"><blockquote class="gmail_quote m_8150047022728850352m_3992281679383646610gmail_msg gmail_msg" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">_______________________________________________<br class="m_8150047022728850352m_3992281679383646610gmail_msg gmail_msg">
Javalist mailing list<br class="m_8150047022728850352m_3992281679383646610gmail_msg gmail_msg">
<a href="mailto:Javalist@lists.javaforum.hu" class="m_8150047022728850352m_3992281679383646610gmail_msg gmail_msg" target="_blank">Javalist@lists.javaforum.hu</a><br class="m_8150047022728850352m_3992281679383646610gmail_msg gmail_msg">
<a href="http://lists.javaforum.hu/mailman/listinfo/javalist" rel="noreferrer" class="m_8150047022728850352m_3992281679383646610gmail_msg gmail_msg" target="_blank">http://lists.javaforum.hu/mailman/listinfo/javalist</a><br class="m_8150047022728850352m_3992281679383646610gmail_msg gmail_msg">
<br class="m_8150047022728850352m_3992281679383646610gmail_msg gmail_msg"></blockquote></div><br class="m_8150047022728850352m_3992281679383646610gmail_msg gmail_msg"></div>
_______________________________________________<br class="m_8150047022728850352m_3992281679383646610gmail_msg gmail_msg">
Javalist mailing list<br class="m_8150047022728850352m_3992281679383646610gmail_msg gmail_msg">
<a href="mailto:Javalist@lists.javaforum.hu" class="m_8150047022728850352m_3992281679383646610gmail_msg gmail_msg" target="_blank">Javalist@lists.javaforum.hu</a><br class="m_8150047022728850352m_3992281679383646610gmail_msg gmail_msg">
<a href="http://lists.javaforum.hu/mailman/listinfo/javalist" rel="noreferrer" class="m_8150047022728850352m_3992281679383646610gmail_msg gmail_msg" target="_blank">http://lists.javaforum.hu/mailman/listinfo/javalist</a><br class="m_8150047022728850352m_3992281679383646610gmail_msg gmail_msg">
</blockquote></div>
<br class="gmail_msg">_______________________________________________<br class="gmail_msg">
Javalist mailing list<br class="gmail_msg">
<a href="mailto:Javalist@lists.javaforum.hu" class="gmail_msg" target="_blank">Javalist@lists.javaforum.hu</a><br class="gmail_msg">
<a href="http://lists.javaforum.hu/mailman/listinfo/javalist" rel="noreferrer" class="gmail_msg" target="_blank">http://lists.javaforum.hu/mailman/listinfo/javalist</a><br class="gmail_msg">
<br class="gmail_msg"></blockquote></div><br class="gmail_msg"></div>
_______________________________________________<br class="gmail_msg">
Javalist mailing list<br class="gmail_msg">
<a href="mailto:Javalist@lists.javaforum.hu" class="gmail_msg" target="_blank">Javalist@lists.javaforum.hu</a><br class="gmail_msg">
<a href="http://lists.javaforum.hu/mailman/listinfo/javalist" rel="noreferrer" class="gmail_msg" target="_blank">http://lists.javaforum.hu/mailman/listinfo/javalist</a><br class="gmail_msg">
</blockquote></div>