Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WildFly management - list/detect REST endpoints deployed in WildFly

Is there a way (e.g. from a WildFly management console) to list all REST endpoints deployed in WildFly? Or to list them in a log while a server is starting?

like image 918
Jakub Godoniuk Avatar asked Feb 17 '16 16:02

Jakub Godoniuk


People also ask

How do I access WildFly management console?

Accessing the web console The web console is served through the same port as the HTTP management API. It can be accessed by pointing your browser to: http://<host>:9990/console. By default the web interface can be accessed here: http://localhost:9990/console.

How do I check WildFly server status?

The simplest way to check the status of an application running on JBoss / WildFly is to use the CLI tool and the deployment-info command.

Where is WildFly configuration file?

Each Host Controller by default reads its configuration from the domain/configuration/host. xml file located in the unzipped WildFly installation on its host's filesystem. The host. xml file contains configuration information that is specific to the particular host.


2 Answers

Using the RegistryStatsResource

With RESTEasy (that is shipped with WildFly), you could add the following to your web.xml:

<context-param>
    <param-name>resteasy.resources</param-name>
    <param-value>org.jboss.resteasy.plugins.stats.RegistryStatsResource</param-value>
</context-param>

And then request the following URL:

http://[hostname]:[port]/[context]/[api-path]/resteasy/registry

Such endpoint can produce XML and JSON content. Just add the Accept header to the request with the desired media type:

  • application/xml
  • application/json

Checking the source code

If you are interested in the source code to create your own implementation, have a look at the RegistryStatsResource class on GitHub.

The most relevant part of the source code is shown below (it's RESTEasy specific):

ResourceMethodRegistry registry = (ResourceMethodRegistry) 
    ResteasyProviderFactory.getContextData(Registry.class);

for (String key : registry.getBounded().keySet()){
List<ResourceInvoker> invokers = registry.getBounded().get(key);

for (ResourceInvoker invoker : invokers) {

    if (invoker instanceof ResourceMethodInvoker) {

        ResourceMethodInvoker rm = (ResourceMethodInvoker) invoker;

        // Extract metadata from the ResourceMethodInvoker
    }
}

Swagger may be an alternative

Depending on your requirements, you can use Swagger to document your API. It comes with a set of annotations to describe your REST endpoints.

Then use Swagger UI to provide a live documentation for your API.


Note: As of February 2017, looks like the RegistryStatsResource class is completely undocumented. I occasionally discovered it when digging into the RESTEasy source code for debugging purposes. Also, I found this JBoss EAP issue that tracks the lack of documentation for that class.

like image 92
cassiomolin Avatar answered Sep 26 '22 00:09

cassiomolin


From the Management Console, you can view the published endpoints.

When you login as an administrator, Click the Runtime option on the top navigation bar as shown below.

Sample Wildfly Page

Click the JAX-RS option, then click the REST Resources option. This will display the endpoints to the far right.

like image 36
Stanley Nguma Avatar answered Sep 26 '22 00:09

Stanley Nguma