Hi Matt,
Jersey supports the addition of other types for query parameters (and
other parameters).
You can do the following:
@Provider
public JodaDateTimeProvider implements
InjectableProvider<QueryParam, Parameter> {
public ComponentProvider.Scope getScope() {
return ComponentProvider.Scope.PerRequest
}
public Injectable getInjectable(InjectableContext ic,
QueryParam a, Parameter c) {
if (!DateTime.isAssignableFrom(c.getParameterClass())
return null;
final String name = c.getSourceName();
return new Injectable<DateTime>() {
public DateTime getValue(HttpContext c) {
String value = c.getUriInfo().getQueryParameters().getFirst(name);
DateTime d = ...
return d;
}
};
}
}
Paul.
Matt Brozowski wrote:
> I noticed in the spec that the only Types supported by the various
> XXXParam options are those that take a String constructor, have a
> valueof() etc.
>
> I think it is important that you add suport for something like
> PropertyEditors to the kinds of things that show here. The current
> support makes supporting Date formats as an example tricky because it
> can only be the formats that Date object supports directly unless I
> write my own Date wrapper.
>
> A java.beans.PropertEditor could be added as either a @Provider for a
> certain type for the entire app or an an optional 'editor' or param to
> he XXXParam tag.
>
> This would make it easy to support any type you like as a Parameter.
> This is also the way Spring supports conversion from various types so
> there's a source for comparison.
>
> Any thoughts,
> Matt
--
| ? + ? = To question
----------------\
Paul Sandoz
x38109
+33-4-76188109