Description
Daniel Fernández opened SPR-8963 and commented
IMHO, there is a mismatch between the configuration possibilities offered by XML and @Configuration
classes in Spring 3.1, which could be fixed by allowing developers to create custom annotations that could be used in @Configuration
classes (in the same way as @PropertySource
) for performing pre-configured infrastructure tasks.
These annotations could perform these configuration tasks "underneath", hiding their complexities to Spring users, in the same way namespace handlers can in an XML file.
@PropertySource
is the clear example to this, as it registers a PropertySource for the specified ".properties" files, but the object registered is of a specific class hard-coded into Spring's code. This avoids the possibility of creating instances of other implementations of the PropertySource interface that perform more complex processing of .properties entries.
Specifically, the jasypt project [ http://www.jasypt.org ] --of which I'm author-- defines an "encryption" XML namespace which allows developers to register an EncryptablePropertySource that performs automatic transparent decryption of properties with "encryption:encryptable-property-placeholder/", which works in a way equivalent to "context:property-placeholder/", but applying transparent decryption.
I would love to be able to offer this same easiness of configuration in @Configuration
classes with an @EncryptablePropertySource
annotation, but as it happens this is not possible :-(
Please, extend the @Configuration
mechanism for allowing custom annotations (with their associated handlers).
Thanks.
Affects: 3.1 GA
Issue Links:
- Improve @PropertySource loading support [SPR-12116] #16732 Improve
@PropertySource
loading support ("is duplicated by") - Allow @PropertySource to be specified on a test class [SPR-10232] #14865 Allow
@PropertySource
to be specified on a test class - Support declarative PropertySource annotations in the TestContext framework [SPR-11377] #16004 Support declarative PropertySource annotations in the TestContext framework
- SEC-3123 Encrypted property value support
- Add support for UTF-8 and other charset/encoding to
@PropertySource
[SPR-13874] #18447 Add support for UTF-8 and other charset/encoding to@PropertySource
- convertPropertyValue (for reading encrypted values) not working [SPR-14001] #18574 convertPropertyValue (for reading encrypted values) not working
- Custom @Profile annotations not working on @Configuration classes [SPR-11808] #16428 Custom
@Profile
annotations not working on@Configuration
classes - PropertySourcesPlaceholderConfigurer never calls "convertProperties" on merged properties [SPR-8928] #13568 PropertySourcesPlaceholderConfigurer never calls "convertProperties" on merged properties
- Add encryption support for PropertyPlaceholderConfigurer [SPR-10666] #15294 Add encryption support for PropertyPlaceholderConfigurer
- Backport encrypted property functionality from spring-cloud-config environment work [SPR-12635] #17236 Backport encrypted property functionality from spring-cloud-config environment work
- Allow a single element to override an array attribute in a meta-annotation [SPR-13972] #18544 Allow a single element to override an array attribute in a meta-annotation
Referenced from: commits a378912
5 votes, 12 watchers