Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Without having seen any actual code, could you not set the <code>actualPath</code> on the <code>SupportBean</code> in the setter of the enclosing bean? The <code>SupportBean</code> would need to have a scope of prototype so that the separate state could be maintained.</p> <p>So for example, if your <code>SupportBean</code> looked something like this:</p> <pre><code>@Component @Scope("prototype") public class SupportBean { private String actualPath; public void setActualPath(String actualPath) { this.actualPath = actualPath } } </code></pre> <p>Then you could set the actual path on the <code>SupportBean</code> in the setter in the enclosing bean. So <code>Service1</code> might look something like this:</p> <pre><code>@Service public class Service1 { private String path = "first path"; private SupportBean supportBean; @Autowired public void setSupportBean(SupportBean supportBean) { this.supportBean = supportBean; this.supportBean.setActualPath(this.path); } } </code></pre> <p>And <code>Manager1</code> like this:</p> <pre><code>@Service public class Manager1 { private String path = "second path"; private SupportBean supportBean; @Autowired public void setSupportBean(SupportBean supportBean) { this.supportBean = supportBean; this.supportBean.setActualPath(this.path); } } </code></pre> <p>If you'd rather use constructor injection then just drop the setter and autowire the constructor:</p> <pre><code>@Service public class Service1 { private String path = "first path"; private SupportBean supportBean; @Autowired public Service1(SupportBean supportBean) { this.supportBean = supportBean; this.supportBean.setActualPath(this.path); } } </code></pre>
 

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