I did a good job of searching and tried to paste the source code of Jersey , but as far as I can tell, Jersey does not support an arbitrarily deep nesting of auxiliary resources combined with annotations @Ref.
Here is my setup:
MemberResource.java
@Component
@Scope("prototype")
@Validated
@Path("/member")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public class MemberResource extends BaseResource {
@Autowired
private MemberFriendResource memberFriendResource;
@Path("/{memberId}/friend/")
public MemberFriendResource getMemberFriendResource() {
return memberFriendResource;
}
}
MemberFriendResource.java
@Component
@Scope("prototype")
@Validated
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public class MemberFriendResource extends BaseResource {
@GET
public JResponse<FriendListRepresentation> getAllFriends() {
}
@GET
@Path("/recent")
public JResponse<FriendListRepresentation> getRecentFriends() {
}
}
MemberRepresentation.java
public class MemberRepresentation {
@Ref(resource=MemberResource.class, method="getMemberFriendResource", bindings = {
@Binding(name="memberId", value="${instance.id}")
})
public URI allFriendsURI;
@Ref(resource=MemberResource.class, method="??????????", bindings = {
@Binding(name="memberId", value="${instance.id}")
})
public URI recentFriendsURI;
}
I want it to be recentFriendsURIdynamically generated in the same way as allFriendsURI(which itself works, just to be clear). I understand that I can manually type the path line by line @Ref(value="/member/{memberId}/friend/recent", etc), but I would not really like to hard-code the lines of my path in every random view that needs a link.
, URI , , resource/method, String?
, , .
, , . , .