users@jersey.java.net

Re: Usage of JSR-308

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Mon, 14 Jan 2008 11:55:58 +0100

Hi Jose,

Jose Antonio Illescas del Olmo wrote:
> JSR-311 can use "Extended Annotations" to annotate throws clause
> exceptions as:
>
> @Path("/some/<id>")
> @GET
> public Some getSome(@UriParameter("id" String id) throws @Status(404)
> NotFoundException, OtherException {
> ...
> }
>
> note: any not annotated exception must be response a status=500
> (Server Error)
>
> This new feature (of annotations) avoids the use of
> WebApplicationException, but JSR308 must be available on Java SE 7...
>

We cannot depend on SE 7 :-( [*]

I think that could be useful when one wants to reuse an existing
exception rather than catching and throwing WebApplicationException or a
subtype of.

Note that in Jersey i have extended WebApplicationException for some
common errors like NotFoundException.

Paul.

[*] I wish 308 specify the creation of default annotations for method
parameters with values that are the names of those method parameters, so
we can do this:

    @QueryParam String foo

instead of repeating "foo" like this:

    @QueryParam("foo") String foo

-- 
| ? + ? = To question
----------------\
    Paul Sandoz
         x38109
+33-4-76188109