Reputation: 11672
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
Upvotes: 8
Views: 4151
Reputation: 3554
You have a API boolean isPrototype(String name)
in ApplicationContext
to check it.
Upvotes: 12