cxf-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sergey Beryozkin" <sergey.beryoz...@iona.com>
Subject RE: Apache CXF REST url resolution issue
Date Sun, 28 Sep 2008 17:13:25 GMT
Hi,

I don't think JAX-RS allows for this but perhaps there's a space for a
CXF-specific extension here.

In meantime you can probably do something like this : 

@Context UriInfo ui;


@GET
        @Path("/employee/{employeeId}/hello/{helloId}")
        public Employee getEmployee2(@PathParam("employeeId")
        String employeeId,@PathParam("helloId")String
helloId)
        {

                  if (ui.getQueryParameters().contains("hi1") {
                      // do hi1 processing
                  }

                  //etc

        }

There's also a cxf private feature :


@GET
        @Path("/employee/{employeeId}/hello/{helloId}")
        public Employee getEmployee2(@PathParam("employeeId")
        String employeeId,@PathParam("helloId")String
helloed, @QueryParam("") HiBean bean)
        {

        }


So if you have HiBean class with setHi1 and setHi2 methods, then HiBean
instance will have either or all of these methods called. Depending on what
is provided in the query list

Cheers, Sergey 
 
-----Original Message-----
From: Sourashis Roy [mailto:sourashis@gmail.com] 
Sent: 28 September 2008 11:41
To: users@cxf.apache.org
Subject: Apache CXF REST url resolution issue

Hi,
    I am trying to use CXF for building some REST services. However I
am having some problems trying to resolve the urls. It seesm that CXF
only resolves the url to API call based on the path annotation and
does not take into account the queryparam annotation. For example I
have 2 API calls

        @GET
        @Path("/employee/{employeeId}/hello/{helloId}")
        public Employee getEmployee2(@PathParam("employeeId")
        String employeeId,@PathParam("helloId")String
helloId,@QueryParam("hi2") String val)
        {

                  //Do something

        }




        @GET
        @Path("/employee/{employeeId}/hello/{helloId}")

        public Employee getEmployee1(@PathParam("employeeId")
        String employeeId,@PathParam("helloId")String
helloId,@QueryParam("hi1") String val)
        {

                        //Do something
        }


        For the 2 calls the @Path annotation is the same but if you
look at the @QueryParam annotation
        they are different (one take "hi1" and the other takes "hi2").
However, CXF doesnt seem to recognize
        this. It always calls the same function irrespective of
whether we pass hi1 or hi2 as the query
        parameter. Is there some way to tell CXF to distinguish
between the two urls.

        I need to resolve this issue pretty urgently and I will
appreciate any help in this regard.

        Regards
        Sourashis

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

Mime
View raw message