java - Spring custom scope with multiple prototypes -


i have bean hierarchy in spring: enter image description here

bean1, bean2, bean3 of scope prototype , of same type (bean) , must share same instance of anotherbean. bean must not singleton, in order manage same situation:

public test {      @autowired     private provider<bean> beanprovider;      public void testcustomscope() {          bean rootbean1 = beanprovider.get();         bean rootbean2 = beanprovider.get();          // after following should true         // rootbean1.getanotherbean() == rootbean1.getbean().getanotherbean() == rootbean1.getbean().getbean().getanotherbean()         // rootbean2.getanotherbean() == rootbean2.getbean().getanotherbean() == rootbean2.getbean().getbean().getanotherbean()         // rootbean1.getanotherbean() != rootbean2.getanotherbean() , on     } } 

it seems me anotherbean should defined custom scope in spring can't find way relate anotherbean instances bean instances.

what easiest way manage kind of scopes in spring?

thanks


Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -