Also published on DZone
Create producers and an annotation to direct it.
The examples provided here enable parsing of Strings, Booleans and Integers but you can of course add producers as needed.
Note that the getKey method firsts looks if the @Property annotation has a value and if so it will take that as the key for the property file, but if you don’t provide a value it will take the annotated field name as the key.
Note that when using this method for injecting Strings and stuff it might get difficult to write Unit tests as Mocking frameworks cannot Mock final classes (e.g. String).
If you get to this problem you might want to look at FieldInjection article