问题描述
我正在尝试回答以下问题:什么是Jersey 2替代ResourceContext.matchResource(URI)?
I am attempting to answer this question: What is the Jersey 2 replacement for ResourceContext.matchResource(URI)?
我设法从ResourceModel
导航到匹配的Resource
,但是目前尚不清楚如何实例化相应的用户类.
I've managed to navigate from a ResourceModel
to a matching Resource
, but it's not clear how to instantiate the corresponding user class.
意思是,因为org.glassfish.jersey.server.model.Resource
映射到某些用户定义的类CompaniesResource
,如何从Resource
中获取CompaniesResource
实例?
Meaning, given org.glassfish.jersey.server.model.Resource
that maps to some user-defined class CompaniesResource
, how do I get a CompaniesResource
instance out of the Resource
?
棘手的是,这需要使用从URI解析的值来调用子资源定位符.
The tricky part is that this needs to invoke subresource locators with values parsed from the URI.
推荐答案
回答我自己的问题:
看看在 https://stackoverflow.com/a/23620747/14731 中找到的createResource
这篇关于Jersey2:从资源导航到实例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!