-1
@Path("/users/A")
public class UserResource1 {

    @GET
    @Produces("text/xml")
    public String getUser(@PathParam("username") String userName) {
        ...
    }
}

@Path("/users/B")
public class UserResource2 {

    @GET
    @Produces("text/xml")
    public String getUser(@PathParam("username") String userName) {
        ...
    }
}
halfelf
  • 9,737
  • 13
  • 54
  • 63

1 Answers1

0

you can have same method name and request mapping with different path url

/*
  To handle A type users logic
    http://localhost:8080/users/A
*/
@Path("/users/A") 
public class UserResource1 {

@GET
@Produces("text/xml")
public String getUser(@PathParam("username") String userName) {

    }
}
/*
 To handle B type users logic 
    http://localhost:8080/users/B
*/
@Path("/users/B")
public class UserResource2 {

@GET
@Produces("text/xml")
public String getUser(@PathParam("username") String userName) {

    }
}

finally you have two end points

http://localhost:8080/users/A?username=bob

http://localhost:8080/users/B?username=testUser

sk1030
  • 52
  • 4