You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<span>@Component</span></nav><articleclass=article><h1>@Component</h1><pclass=subtitle>Inject dependent objects from the Pixie System</p><p><strong>Purpose:</strong> Indicates that a constructor parameter should be injected as a component dependency.</p><h2id=example>Example</h2><divclass=highlight><pretabindex=0class=chroma><codeclass=language-javadata-lang=java><spanclass=line><spanclass=cl><spanclass=kd>public</span><spanclass=w></span><spanclass=kd>class</span><spanclass=nc>ShoppingCart</span><spanclass=w></span><spanclass=p>{</span><spanclass=w>
</span></span></span></code></pre></div><p>Pixie resolves <code>@Component</code> references in several ways:</p><ul><li><ahref=/pixie/references/by-name/><strong>By Name</strong></a> — <code>cart.processor = @stripe</code> references a specific component</li><li><ahref=/pixie/references/by-type/><strong>By Type</strong></a> — omit the property and Pixie finds a match automatically</li><li><ahref=/pixie/references/collections/><strong>Collections</strong></a> — use <code>List<T></code> to inject multiple components</li><li><ahref=/pixie/references/generics/><strong>Generics</strong></a> — generic type arguments narrow which components match</li></ul><p>See the <ahref=/pixie/references/>References</a> section for full details on each resolution mode.</p></article><navclass=page-nav><ahref=/pixie/annotations/default/class=prev><divclass=nav-label>← Previous</div><divclass=nav-title>@Default</div></a><ahref=/pixie/annotations/nullable/class=next><divclass=nav-label>Next →</div><divclass=nav-title>@Nullable</div></a></nav></main><asideclass=page-tocid=toc><divclass=toc-heading>On this page</div><nav><navid=TableOfContents><ul><li><ahref=#example>Example</a></li></ul></nav></nav></aside></div><footerclass=site-footer><divclass=footer-inner><p><spanclass=footer-brand>Pixie</span>
14
+
by Tomitribe</p></div></footer><script>(function(){vart,s,o=document.getElementById("menu-toggle"),n=document.getElementById("sidebar"),e=document.getElementById("sidebar-overlay");if(o&&n&&(o.addEventListener("click",function(){n.classList.toggle("open"),e&&e.classList.toggle("visible")}),e&&e.addEventListener("click",function(){n.classList.remove("open"),e.classList.remove("visible")})),document.querySelectorAll(".article pre").forEach(function(e){vart,n=e.querySelector("code");if(!n)return;t=document.createElement("button"),t.className="copy-btn",t.textContent="Copy",t.addEventListener("click",function(){navigator.clipboard.writeText(n.textContent).then(function(){t.textContent="Copied!",t.classList.add("copied"),setTimeout(function(){t.textContent="Copy",t.classList.remove("copied")},2e3)})}),e.appendChild(t)}),t=document.querySelectorAll(".page-toc nav a"),t.length>0){s=[],t.forEach(function(e){varn,t=e.getAttribute("href");t&&t.startsWith("#")&&(n=document.getElementById(t.slice(1)),n&&s.push({el:n,link:e}))});functioni(){varn=window.scrollY+100,e=null;s.forEach(function(t){t.el.offsetTop<=n&&(e=t)}),t.forEach(function(e){e.classList.remove("active")}),e&&e.link.classList.add("active")}window.addEventListener("scroll",i,{passive:!0}),i()}})()</script></body></html>
<span>@Default</span></nav><articleclass=article><h1>@Default</h1><pclass=subtitle>Provide fallback values for missing properties</p><p><strong>Purpose:</strong> Specifies a default value for a constructor parameter if it is not set in the configuration.</p><h2id=example>Example</h2><divclass=highlight><pretabindex=0class=chroma><codeclass=language-javadata-lang=java><spanclass=line><spanclass=cl><spanclass=kd>public</span><spanclass=w></span><spanclass=kd>final</span><spanclass=w></span><spanclass=kd>class</span><spanclass=nc>Address</span><spanclass=w></span><spanclass=p>{</span><spanclass=w>
</span></span></span></code></pre></div><p>If <code>country</code> is missing from the config, <code>"USA"</code> is used.</p><h2id=with-component>With @Component</h2><p><code>@Default</code> also applies to <code>@Component</code> parameters. When used on <code>@Component</code>, it implies the name of the component that should be injected:</p><divclass=highlight><pretabindex=0class=chroma><codeclass=language-javadata-lang=java><spanclass=line><spanclass=cl><spanclass=kd>public</span><spanclass=w></span><spanclass=kd>final</span><spanclass=w></span><spanclass=kd>class</span><spanclass=nc>OrderService</span><spanclass=w></span><spanclass=p>{</span><spanclass=w>
</span></span></span></code></pre></div><p>If <code>processor</code> is not specified in the config, Pixie will look for a component named <code>stripe</code>.</p></article><navclass=page-nav><ahref=/pixie/annotations/param/class=prev><divclass=nav-label>← Previous</div><divclass=nav-title>@Param</div></a><ahref=/pixie/annotations/component/class=next><divclass=nav-label>Next →</div><divclass=nav-title>@Component</div></a></nav></main><asideclass=page-tocid=toc><divclass=toc-heading>On this page</div><nav><navid=TableOfContents><ul><li><ahref=#example>Example</a></li><li><ahref=#with-component>With @Component</a></li></ul></nav></nav></aside></div><footerclass=site-footer><divclass=footer-inner><p><spanclass=footer-brand>Pixie</span>
23
+
by Tomitribe</p></div></footer><script>(function(){vart,s,o=document.getElementById("menu-toggle"),n=document.getElementById("sidebar"),e=document.getElementById("sidebar-overlay");if(o&&n&&(o.addEventListener("click",function(){n.classList.toggle("open"),e&&e.classList.toggle("visible")}),e&&e.addEventListener("click",function(){n.classList.remove("open"),e.classList.remove("visible")})),document.querySelectorAll(".article pre").forEach(function(e){vart,n=e.querySelector("code");if(!n)return;t=document.createElement("button"),t.className="copy-btn",t.textContent="Copy",t.addEventListener("click",function(){navigator.clipboard.writeText(n.textContent).then(function(){t.textContent="Copied!",t.classList.add("copied"),setTimeout(function(){t.textContent="Copy",t.classList.remove("copied")},2e3)})}),e.appendChild(t)}),t=document.querySelectorAll(".page-toc nav a"),t.length>0){s=[],t.forEach(function(e){varn,t=e.getAttribute("href");t&&t.startsWith("#")&&(n=document.getElementById(t.slice(1)),n&&s.push({el:n,link:e}))});functioni(){varn=window.scrollY+100,e=null;s.forEach(function(t){t.el.offsetTop<=n&&(e=t)}),t.forEach(function(e){e.classList.remove("active")}),e&&e.link.classList.add("active")}window.addEventListener("scroll",i,{passive:!0}),i()}})()</script></body></html>
0 commit comments