1

Is there a possibility to get a list of all registered REST resources at runtime?

With REST resources I mean:

  • either classes which have annotations such as @Path(...) and are considered by the server at runtime (so traversing all classes using reflection would not do),
  • or URIs of all paths (REST class can have multiple paths).

NOTE 1: I am using automatic configuration (that new feature of JavaEE 6) and Netbeans just generates an empty ApplicationConfig class.

NOTE 2: Using Netbeans 6.9, JavaEE 6, Glassfish 3. Is more information on my ecosystem needed?

0

2 Answers 2

5

Are you using Jersey? If so, then a WADL is generated automatically at /application.wadl. The WADL contains a lot of information about registered resource paths.

See also: WADL Support

2
  • WOW! http://localhost:8080/application.wadl really worked! Thank you! Before marking as correct, I will wait, if other (better suited for me) answers will appear. Jun 28, 2010 at 14:07
  • Link mention is now broken, but this may be the new version: Jersey and WADL
    – bobtheowl2
    Jul 9, 2012 at 21:44
-1
public synchronized Response doSomething(@Context Application c, @FormParam("someParam") String someParam)
    throws Exception {

    // gives a list of classes which are used by this Jersey instance
    // and have REST-related annotations
    c.getSingletons(); // returns Set<Object>

    return something;
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.