Thanks...

The problem is actually with these Path annotations :

>> @Path("/users/")
>> public class UserService {
>> 
>>   @Path("/users/{id}/")
>>   public User getUser(@PathParam("id") String id) {
>>     ... // load from db
>>   }
>>   
>>   ...
>> 
>> }

it should be

@Path("/users/")
public class UserService {
 
   @Path("{id}")
   public User getUser(@PathParam("id") String id) {
     ... // load from db
   }
   
}

The Path annotations on the root resource class are 'inherited' and 
concatenated with the one on the resource method getUser()...

For example to get a collection of users one can do

@Path("/users/")
public class UserService {

   @GET 
   public Users getUsers() {
       ...
   }
   
   @Path("{id}")
   public User getUser(@PathParam("id") String id) {
     ... // load from db
   }
   
}

Cheers, Sergey


----- Original Message ----- 
From: "Joshua Purcell" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Monday, April 28, 2008 5:26 AM
Subject: Re: Question about JAX-RS Sub resources


> 
> Your example is a little different from the sample JAX-RS code included with
> the CXF snapshot. This may work better for you:
> @Path("/userservice/")
> public class UserService {
>  @Path("/users/{id}/")
>  public User getUser(@PathParam("id") String id) {
>    ... // load from db
>  }
> }

----------------------------
IONA Technologies PLC (registered in Ireland)
Registered Number: 171387
Registered Address: The IONA Building, Shelbourne Road, Dublin 4, Ireland

Reply via email to