Of course the first is the most obvious, but about the other two ways: I did a research through the javadoc/api and current Reference Documentation for these two interfaces and there is no mention about when an approach should be used over the other.
Even when it is trivial I think is fair give some indication.
Affects: 4.3 GA, 4.3.6
The text was updated successfully, but these errors were encountered:
I also analyzed javadoc/api. I found that "prototype" and ConfigurableBeanFactory.SCOPE_PROTOTYPE may be used with the @Scope annotation, while BeanDefinition.SCOPE_PROTOTYPE is preferably used when definining scope in code by BeanDefinitionBuilder.setScope(BeanDefinition.SCOPE_PROTOTYPE) method.
Since the scopeName attribute of the @Scope annotation clearly references ConfigurableBeanFactory.SCOPE_PROTOTYPE and ConfigurableBeanFactory.SCOPE_SINGLETON, I don't think there is any need for further clarifying documentation regarding the constants.
In addition, all that really matters is that the @Scope annotation be supplied a constant expression that evaluates "prototype" for a prototype-scoped bean. Thus, @Scope("prototype") is also perfectly valid (as previously pointed out), but some people prefer not to use String literals for fear of making a typo and may therefore prefer the use of a constant.
Please keep in mind that BeanDefinition.SCOPE_PROTOTYPE does not redefine the constant value but rather simply references ConfigurableBeanFactory.SCOPE_PROTOTYPE.
When working programmatically with bean definitions, one may prefer to reference the BeanDefinition.SCOPE_PROTOTYPE constant, but in the end it's really just a matter of preference.
In any case, I'll tidy up our internal use of those constants for greater consistency.