samedi 21 mars 2015

Can I autowire a proptotype bean in a singelton bean directly

I was viewing some legacy code and found that here is a singelton bean say X and i have autowire a prototype bean in it like



@Controller
public class X
{
@Autowired
private Y y ;
....

}

And Y is defined as

@Component
@scope("prototype")
public class Y
{

}


Now as per my understanding to inject a prototype bean in a singelton bean we have two approach 1)scoped Proxy 2)method injection


Now in the above code none of the above mentioned approach is used . So shall I believe that although a prototype bean is injected in class X but still it will behave as singelton bean that is only single instance of Y will be available inside X class throughout the application scope


Aucun commentaire:

Enregistrer un commentaire