Is it possible to ascertain whether a bean is a prototype bean or not?
I'm hoping for a method on one of the variants of application Context like getScope or getBeanMetaData...
You can "ask" the BeanFactory for the BeanDefintion, it contains the scope
@Autowired
ConfigurableApplicationContext applicationContext;
...
applicationContext.getBeanFactory().getBeanDefinition("beanName").getScope()
(getBeanFactory() is defined at ConfigurableApplicationContext which is an interface that is implemented by every concrete ApplicationContext except StubWebApplicationContext)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With