IDP-1004 and @Duration
Rod Widdowson
rdw at steadingsoftware.com
Wed Jul 6 05:20:09 EDT 2016
I think I know what the answer here is but I said in the case that I'd take
this to the list....
In this case the automatic conversion from a suitable XML duration ("PT5S")
to an "@Duration long" wasn't happening. Since we use this absolutely
everywhere and it mostly works we needed to understand why.
It turns out to be what I believe to be a bug in Spring which I have entered
as https://jira.spring.io/browse/SPR-14434
In order for the @Duration to be available to our converter, one of the
following need to be appropriately annotated:
- The field (private @Duration long foo)
- The getter (public @Duration long getFoo())
- The setter method (public @Duration void setFoo(long what))
In particular having the setter parameter marked (public void setFoo(long
@Duration what)) isn't sufficient. In nearly all the cases we lucked out
with the field.
Scott's suggestion (which I like) is to add a new annotation
@DurationPropertySetter and put that onto all out setters (as well as the
annotation on the parameter).
Does anyone think this is a bad idea?
/Rod
More information about the dev
mailing list