Search code examples
javaannotations

How are java annotations like "@PathParam(" ") " processed in java? Where can we find the source code of that particular annotation processor?


I have a Service File in jax-rs that has a method which accepts parameters through @QueryParam Annotation.

The annotation clearly is processed somewhere in the compilation process. Which is the class that performs the modification operation? Like for QueryParam to fetch Parameters from the URL.

@PUT
@Path("/score")
@Produces("application/json")
public String update(@QueryParam("wins") int wins, 
                        @QueryParam("losses") int losses, 
                        @QueryParam("ties")   int ties) {
   Hello.wins   = wins;
   Hello.ties   = ties;
   Hello.losses = losses;
   String pattern = 
      "{ \"wins\":\"%s\", \"losses\":\"%s\", \"ties\": \"%s\"}";
   return String.format(pattern,  Hello.wins, Hello.losses, Hello.ties );   
}

Solution

  • Thanks, I found the solution myself. There are InjectableProvider classes for each annotation present in the jersey library which process the incoming annotations.