Only one method is executed for a single request. So it is impossible to execute two methods (or more) in single request;
JAX-RS runtime decides which one method should be executed according to request header values sent to to the server.
JAX-RS runtime tries to match:
http method (GET,POST, ...) with proper annotation (@GET, @POST,...);
request path ('/api/something') with the proper @Path annotation;
http content-type header (link) with proper @Consumes annotation;
http accept header with propper @Produces annotation;
So (for example) @Produces annotation does not denote that annotated method produces something. It denotes that method will be executed when matching accept header will be contained in request.
If You need more information abou RestFull webservices i advice You to read these resources:
You should remember that:
JAX-RS
runtime tries to match:http method (
GET
,POST
, ...) with proper annotation (@GET
,@POST
,...);request path (
'/api/something'
) with the proper@Path
annotation;http
content-type
header (link) with proper@Consumes
annotation;http
accept
header with propper@Produces
annotation;So (for example)
@Produces
annotation does not denote that annotated method produces something. It denotes that method will be executed when matchingaccept header
will be contained in request.If You need more information abou RestFull webservices i advice You to read these resources:
rfc2616
RESTful Java with JAX-RS - By Bill Burke