Jersey2: Navigating from a Resource to an instance

三世轮回 提交于 2019-12-13 05:51:17

问题


I am attempting to answer this question: What is the Jersey 2 replacement for ResourceContext.matchResource(URI)?

I've managed to navigate from a ResourceModel to a matching Resource, but it's not clear how to instantiate the corresponding user class.

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?

The tricky part is that this needs to invoke subresource locators with values parsed from the URI.


回答1:


Answering my own question:

Take a look at createResource found at https://stackoverflow.com/a/23620747/14731



来源:https://stackoverflow.com/questions/23145871/jersey2-navigating-from-a-resource-to-an-instance

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!