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

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -