Can I programmatically determine if a spring bean is not singleton?
java, scope, spring
Solution
You have a API `boolean isPrototype(String name)` in `ApplicationContext` to check it.
Problem
When I get a spring bean (via getBean()), is there any way to verify from java code that the bean has been defined with scope=prototype ? Spring config: ``` <bean class="foo.Bar" scope="prototype" /> ``` Java:sc ``` MyBean bean = springApplicationContext.getBean("MyBean"); ``` I could just instantiate it twice and compare the objects, but I'd like to avoid unnecessary object creation. Something like the opposite of this answer would do the trick: https://stackoverflow.com/a/9125610/156477