Skip to content
This repository was archived by the owner on May 28, 2018. It is now read-only.

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

README.MD

Resource Configuration Reload Example

This example demonstrates how to create a simple Jersey application with resource reloading capability using Grizzly HTTP Server container.

Contents

The mapping of the URI path space is presented in the following table:

URI path Resource class Content HTTP methods
/flights/arrivals org.glassfish.jersey.examples.reload.ArrivalsResource Dummy Arrivals Information GET
/flights/departures org.glassfish.jersey.examples.reload.DeparturesResource Dummy Departures Information GET
/flights/stats org.glassfish.jersey.examples.reload.StatsResource Statistics on application resource utilization GET

The application gets configured via a plain text file named resources. The file contains a list of resource classes to be published by the application. After the application gets started, it watches the file system and reloads the application as file updates are being detected. Changes in JAX-RS resource source files and updates of the above mentioned resources file are being detected. Java code re-compilation is done as required.

Running the Example

Run the example as follows:

mvn clean compile exec:java

This deploys current example usingGrizzly container. StatsResource should be available at http://localhost:8080/flights/stats

You may want to check the other resources as well:

Updated information on number of hits should be available at http://localhost:8080/flights/stats. Now you can try to edit the resources file and comment the stats resource out by using the # prefix. The point is you leave the application running while editing the file. The changes wil get picked up automatically. No need to manually restart the application. The resource file content should now look like follows:

org.glassfish.jersey.examples.reload.DeparturesResource
org.glassfish.jersey.examples.reload.ArrivalsResource
#org.glassfish.jersey.examples.reload.StatsResource

Once you save the change, the stats resource should not be available, but the other, departures/arrivals, resources should remain functional.

Now you can revert the change back and check the stats resource is back providing actual statistics information.

You can also try to change the JAX-RS resources source code. These changes will be also picked up automatically.