java - Spring 4. does getBeanFromClass trigger bean's constructor for prototype beans? -
spring 4. getbeanfromclass() trigger bean's constructor prototype beans? if so, should careful calling function, right? in code getbeanfromclass this:
public static <t> t getbeanfromclass(class<t> abeanclass) throws beansexception { return getapplicationcontext().getbean(abeanclass); }
thanks
i'm assuming method. care applicationcontext#getbean(class)
(which beanfactory#getbean(class)
) method. javadoc states
return bean instance uniquely matches given object type, if any.
so, yes, returns instance. prototype beans, it'll return newly created instance every time.
do have careful? depends entirely on you're doing. if need prototype bean instance, need use (if you're working applicationcontext
directly).
Comments
Post a Comment