Thanks Sergey,

I did little bit more analysis, Here is some additional information related
to the answer of this question, it may help to someone

"The documentation for how CXF selects which method is executed is here: CXF
resource selection overview
<http://cxf.apache.org/docs/jax-rs-basics.html#JAX-RSBasics-Overviewoftheselectionalgorithm.>.
The docs talks about which method it prefers by looking at which has more
path parameters or more a more specific path but each method in your first
scenario has the same path so the first one is chosen. To differentiate
between them you could use a path parameter.

The Second scenario requires you to change the HTTP method used with the
URL so:

   - POST /customer
   - GET /customer
   - PUT /customer

would each invoke the different methods."

For the scenarios See the below link :

http://stackoverflow.com/questions/33216733/how-cxf-handles-apis-if-those-are-not-annotated-with-the-path-variable

On Mon, Oct 19, 2015 at 8:04 PM, Sergey Beryozkin <[email protected]>
wrote:

> If @Path is not set then it is default to the empty value, ex, all the
> methods getText1...getText6 match
>
> GET /testqa
> Accept: application/json
>
> and the selection between those methods is random, possibly the 1st of
> those methods but is not guaranteed...This is a standard 2.0 selection
> process
>
>
>
> Sergey
>
>
>
>
> On 19/10/15 15:04, Sumit Arora wrote:
>
>> During my work I encountered below scenario, On which : getText1,
>> getText2,getText3,getText4,getText5,getText6 are without @Path
>> annotations,
>>
>> But when I call the API (http://localhost:8080/.../testqa/ )it always
>> show
>> : {"name":"Sumit1 Arora","age":21,"address":"Lakshay1 Arora"}
>>
>>
>> @Service("qaservice")
>> @Path("/testqa")
>> public class SimpleQAImpl {
>>
>>      @GET
>>      @Produces(MediaType.APPLICATION_JSON)
>>      @Path("/simpleqa")
>>      public Person getText() {
>>          return new Person("Sumit Arora",21,"Lakshay Arora");
>>      }
>>
>>      @GET
>>      @Produces(MediaType.APPLICATION_JSON)
>>      public Person getText1() {
>>          return new Person("Sumit1 Arora",21,"Lakshay1 Arora");
>>      }
>>
>>
>>
>>      @GET
>>      @Produces(MediaType.APPLICATION_JSON)
>>      public Person getText3() {
>>          return new Person("Sumit3 Arora",21,"Lakshay3 Arora");
>>      }
>>
>>      @GET
>>      @Produces(MediaType.APPLICATION_JSON)
>>      public Person getText4() {
>>          return new Person("Sumit4 Arora",21,"Lakshay4 Arora");
>>      }
>>
>>      @GET
>>      @Produces(MediaType.APPLICATION_JSON)
>>      public Person getText5() {
>>          return new Person("Sumit5 Arora",21,"Lakshay5 Arora");
>>      }
>>
>>      @GET
>>      @Produces(MediaType.APPLICATION_JSON)
>>      public Person getText6() {
>>          return new Person("Sumit6 Arora",21,"Lakshay6 Arora");
>>      }
>> }
>>
>>
>> May you please tell me how Apache CXF works, if @Path not given like the
>> case above or on other scenarios as well ?
>>
>> 'Sumit
>>
>>
>
> --
> Sergey Beryozkin
>
> Talend Community Coders
> http://coders.talend.com/
>

Reply via email to