@Property annotation to "autowire" properties [SPR-5659] #10330
Labels
in: core
Issues in core modules (aop, beans, core, context, expression)
type: enhancement
A general enhancement
Milestone
Bruno Navert opened SPR-5659 and commented
We (Morgan Stanley) have developed code to support a new annotation, similar to
@Autowired
:@Property
This, combined with a BeanPostProcessor instance, will inject property values into fields/setters automatically, as if the bean had been registered in XML with ${xxx} placeholders.
The code uses a PropertyPlaceholderConfigurer subclass to be able to programmatively get the value of a given property name, using the same logic of system property override/fallback.
Benefits are clear: beans can then be annotated with
@Component
, and there's no need to define them in XML anymore when they depend on a property. Without this,@Autowired
takes care of all the dependencies, but the moment you need a property, you still need to define your bean in XML in order to use the ${xxx} placeholder syntax. With this new annotation, everything can be done through code.Since this code is very generic, we feel it would be best to be integrated into the core Spring framework.
Code will be attached to this JIRA issue as soon as we get legal approval internally to share it.
Affects: 2.5.4
1 votes, 2 watchers
The text was updated successfully, but these errors were encountered: