users@jersey.java.net

Re: [Jersey] WadlGenerator does not generate resource methods for subresources?

From: Martin Grotzke <martin.grotzke_at_freiheit.com>
Date: Tue, 10 Jun 2008 14:34:56 +0200

Hi Paul

On Tue, 2008-06-10 at 14:05 +0200, Paul Sandoz wrote:
> Hi Martin,
>
> The main issue we do not know at compile/deploy time what concrete
> resources are returned by sub-resource locater methods.
You're speaking of the cases when resource methods simply return a
Response instead of a concrete type?

I thought that one should be able to specify several response
representations in the javadoc so that application.wadl _can_ be
generated at build time.

>
> This is why we support the serving of WADL via the HTTP OPTIONS method
> for each resource.
Ok, sounds interesting, but I have no clue how this is realized :)

Cheers,
Martin


>
> Paul.
>
> Martin Grotzke wrote:
> > Hi,
> >
> > we have a root resource UsersResource with a subresource locator that
> > returns a UserResource that provides a resource method getUser().
> >
> > The generated application.wadl only contains the UserResource, but not
> > the resource methods that are provided by the UserResource.
> >
> > Here comes the UsersResource:
> >
> > @PerRequest
> > @Path("/"+ PathParams.USERS +"/")
> > public class UsersResource {
> >
> > @Path("{username}/")
> > public UserResource getUser( @PathParam("username")
> > final String username ) {
> > final UserResource user = _facade.getUserByUsername( username );
> > if ( user == null ) {
> > throw new NotFoundException("username " + username + " does
> > not exist!");
> > }
> > return new UserResource( user, getUriInfo(), _facade,
> > _dataTypeFactory, _securityContext );
> > }
> >
> > ...
> >
> > }
> >
> > This is a part of the UserResource:
> >
> > public class UserResource {
> >
> > ...
> >
> > @GET
> > @ProduceMime({ "application/xml" })
> > public User getUser() {
> > return new User( _user ); // just for
> > }
> >
> > @PUT
> > @Path( "{version}" )
> > @ConsumeMime( { "application/xml" } )
> > @ProduceMime({ "application/xml" })
> > public Response updateUser( @PathParam( "version" )
> > final int version,
> > UpdateUserRequest updateUserRequest ) {
> > ...
> > }
> >
> > ...
> >
> > }
> >
> > The relevant part of the generated application.wadl does not show the
> > methods provided by the UserResource:
> >
> > <resource path="/users/">
> > <method name="POST">
> > <request>
> > <representation mediaType="application/xml" />
> > </request>
> > <response>
> > <representation mediaType="application/xml" />
> > </response>
> > </method>
> > <resource path="{username}/">
> > <param xmlns:xs="http://www.w3.org/2001/XMLSchema"
> > type="xs:string"
> > style="template" name="username" />
> > </resource>
> > </resource>
> >
> > Can please s.o. confirm that this is an issue of the WadlGenerator and
> > not of our resource classes?
> >
> > Cheers,
> > Martin
> >
> >