How to find out the scope of a spring managed bean
java, spring
Solution
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`)
Problem
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...