dosgi

Apache CXF DSOGI on Karaf + @Context UriInfo


I am trying to create a RESTful web service in Karaf 4.0.8 with Apache CXF DOSGI. I am trying to add @Context in my implementation. How to do it?

    @Component(immediate = true, property = {
    "service.exported.interfaces=*", 
    "service.exported.configs=org.apache.cxf.rs",
    "org.apache.cxf.rs.provider=com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider",
    "org.apache.cxf.rs.address=/integr" })
    public class AccountRestService implements AccountWebUserIdResource {

       @Context
       private UriInfo context;
           ...
     }

UriInfo is not getting injected properly.


Solution

  • REST API Interface you need to add your @Context

    @GET @Path("{memberid}") @Produces({"application/json"}) MembersResource.GetMembersByMemberidResponse getMembersByMemberid( @PathParam("memberid") String memberid,@QueryParam("fields") String fields, @Context javax.ws.rs.core.UriInfo uriInfo) throws Exception;