Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@Property annotation to "autowire" properties [SPR-5659] #10330

Closed
spring-projects-issues opened this issue Apr 8, 2009 · 4 comments
Closed
Assignees
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: enhancement A general enhancement
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

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

@spring-projects-issues
Copy link
Collaborator Author

Juergen Hoeller commented

This sounds very similar to our new @Value annotation in Spring 3.0, in particular now in the upcoming 3.0 M3 where @Value values support not only #{...} expressions but ${...} placeholders as well. Please have a look at M3 once it's out early next week. If this is basically what you had in mind, then let's further refine @Value if you encounter any gaps.

Juergen

@spring-projects-issues
Copy link
Collaborator Author

Bruno Navert commented

Thanks, I'll take a look next week and update this Jira then.

@spring-projects-issues
Copy link
Collaborator Author

Juergen Hoeller commented

FYI, 3.0 M3 will be going out around SpringOne Europe (next week) now.

For the time being, I assume that @Value does the job for you as of M3. Let's reopen this issue if that turns out not to be the case.

Juergen

@spring-projects-issues
Copy link
Collaborator Author

Ricardo Gladwell commented

Created a project to support configuration property injection for Spring 2.5+:

https://code.google.com/p/spring-property-annotations/

@spring-projects-issues spring-projects-issues added type: enhancement A general enhancement in: core Issues in core modules (aop, beans, core, context, expression) labels Jan 11, 2019
@spring-projects-issues spring-projects-issues added this to the 3.0 M3 milestone Jan 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

2 participants