users@jersey.java.net

WadlGenerator does not generate resource methods for subresources?

From: Martin Grotzke <martin.grotzke_at_freiheit.com>
Date: Tue, 10 Jun 2008 13:48:07 +0200

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