如何使用 WSO2 MSf4J 创建 JAX-RS 子资源

How to create JAX-RS Sub Resources with WSO2 MSf4J

我已经使用 WSO2 MSF4J 创建了一个示例微服务。但我无法访问子资源(服务)。以下是我的服务 类。

消息资源 -

@Path("/messages")
@Consumes(MediaType.APPLICATION_JSON) 
@Produces(MediaType.APPLICATION_JSON) 
public class MessageResource {

    @Path("/{messageId}/comments")
    public CommentResource getCommentResource(){

        System.out.println("inside the getCommentResource method");
        return new CommentResource();
    }
}

评论资源 -

@Path("/") 
public class CommentResource {

    @GET
    @Path("/{commentId}")
    public String test2(@PathParam("messageId") long messageId, @PathParam("commentId") long commentId){

        System.out.println("method to return comment Id : " + commentId + " for message : " + messageId);
        return "method to return comment Id : " + commentId + " for message : " + messageId;
    }
}

我使用以下 URI 访问此服务。

获取:http://localhost:8080/messages/1/comments/5

但是我的 REST 客户端得到了以下结果。

404 Not Found

Problem accessing: /messages/1/comments/5. Reason: Not Found

请帮忙解决这个问题。

这是不支持的。 MSF4J 并不声称 100% JAXRS 兼容,而是一个用于构建微服务的轻量级框架。 我为此创建了 JIRA [1]。我们将在未来的版本中实现这一点。

[1] - https://wso2.org/jira/browse/WMS-83