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

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -