关于Karaf的Apache CXF DSOGI + @Context UriInfo

时间:2017-03-27 21:16:14

标签: dosgi

我正在尝试使用Apache CXF DOSGI在Karaf 4.0.8中创建RESTful Web服务。我想在我的实现中添加@Context。怎么做?

    @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未正确注入。

1 个答案:

答案 0 :(得分:0)

您需要添加@Context

的REST API接口

@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;