java - Mixing prototypes with singletons -


i've got application in spring, on every request creates prototype bean x (from factory). bean x has dao singletons e.g. y, z. , someobject on work (set values etc.)

@scope(value="prototype") public class x{    @autowired     private y y;    @autowired    private z z;     private someobject obj;     public void somemethod(){    obj.setproperty();    } } 

is right approach? mean, in every request spring container must search singleton beans , inject them prototype, effective? or maybe it's better create stateless bean , create someobject instance in appropriate method, , pass in function arguments whenever want use (it's not comfortable)?

it better use singleton scope , stateless beans because stateless beans thread-safe. use statefull beans if can not use stateless.


Comments

Popular posts from this blog

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -