users@jersey.java.net

Re: [Jersey] _at_DefaultValue

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Mon, 30 Mar 2009 20:16:40 +0200

On Mar 30, 2009, at 7:31 PM, António Mota wrote:

> Hi all.
>
> My @DefaultValue is not working, so I have two questions about it:
>
> 1) can it be used with primitives - @DefaultValue("false")boolean isOk
> - or only with Objects?
>

The default value can be used with any type that is supported by the
@*Param e.g.:

   https://jsr311.dev.java.net/nonav/javadoc/javax/ws/rs/QueryParam.html

all that happens is if there is no parameter value then the String of
the default takes its place.


> 2) since I'm not using the "normal" Jersey mechanism of parameter
> binding, etc... I probably have to code this myself, where is this
> done in Jersey so I can see if I can reuse the Jersey code?
>

Can you explain a bit more how you are not using the normal mechanism?

BTW it is possible to plug in using a new feature in 1.0.3 SNAPSHOT
using StringReaderProvider and it works with default values. See:

https://jersey.dev.java.net/nonav/apidocs/1.0.3-SNAPSHOT/jersey/com/sun/jersey/spi/StringReaderProvider.html
https://jersey.dev.java.net/nonav/apidocs/1.0.3-SNAPSHOT/jersey/com/sun/jersey/spi/StringReader.html

(the above are what Jersey uses internally to support the specified
JAX-RS types for @*Param).

Otherwise if you are using the injectable provider mechanism with an
@*Param then you need to manage the default value yourself by look at
the annotation.

Paul.

>
> Thanks a million.
> _______________________________________________
>
> Melhores cumprimentos / Beir beannacht / Best regards
>
> António Manuel dos Santos Mota
> _______________________________________________
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>