views:

31

answers:

2

Hello, everyone!

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?

+1  A: 

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: Jersey and WADL

Daniel Trebbien
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.*
java.is.for.desktop
A: 
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;
}
java.is.for.desktop