[英]Jersey2: Navigating from a Resource to an instance
I am attempting to answer this question: What is the Jersey 2 replacement for ResourceContext.matchResource(URI)? 我试图回答这个问题: 什么是ResourceContext.matchResource(URI)的Jersey 2替代品?
I've managed to navigate from a ResourceModel
to a matching Resource
, but it's not clear how to instantiate the corresponding user class. 我已经设法从
ResourceModel
导航到匹配的Resource
,但是还不清楚如何实例化相应的用户类。
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
? 意思是, 给定映射到某些用户定义的类
CompaniesResource
org.glassfish.jersey.server.model.Resource
,如何从Resource
获取CompaniesResource
实例?
The tricky part is that this needs to invoke subresource locators with values parsed from the URI. 棘手的部分是,这需要使用从URI解析的值来调用子资源定位符。
Answering my own question: 回答我自己的问题:
Take a look at createResource
found at https://stackoverflow.com/a/23620747/14731 看看位于https://stackoverflow.com/a/23620747/14731的
createResource
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.