1

Say I have @Path("/abc") annotated on class ABCResource, does Jersey provide interface to retrospect which Class will be handling the coming uri, like this: public Class getHandlerClassForURL(URL url), by invoking with 'abc' I would expecting ABCResource.class returned.

Is it possible in Jersey?

The reason why I need such utility is I have to provide a util to test if a specific menu-item(corresponding to @Path) is authorized to be visited before a real invocation occurs. So dynamic way won't help, such as uriInfo.getMatchedResources(), as I'm not intend to do this in a 'filter' or 'interceptor' circumstance. I suppose inside Jersey, there should be a mapping like the <servlet-mapping> in web.xml, actually I do find one here, sadly the key-value is opposite to my need.

pu.guan
  • 97
  • 4
  • I am not sure about Jersey but you can use plain Java reflection to match annotation values to your path value - provided you have a master list of classes to inspect to. Does [this](http://stackoverflow.com/questions/7402288/get-handler-from-uri-in-jersey) help? – Sabir Khan Apr 27 '16 at 07:38
  • The link you paste resembles my question, but the answer can not apply to my situation, since I want this method to be invoked 'static', i.e. not invoking when there is a real request, thus depending on the injected request-related resource. And the reflection is a solution, if Jersey not provide such way, I might have to do like that. – pu.guan Apr 27 '16 at 08:26

1 Answers1

0

I would answer myself NO. According to 2 related questions, and the accepted answers show that they both have to workaround this instead of using a Jersey provided API directly at last. Links here and here

Community
  • 1
  • 1
pu.guan
  • 97
  • 4