Configuring the Microservice

After the temperature resource has been finished, it is necessary to define the context path of the final URL where the temperature resource will be available. Start with creating the JAX-RS configuration class, named WeatherApplication, in the com.packtpub.microservices.weather package. In order for WeatherApplication to be recognized as a JAX-RS configuration class, it must extend the javax.ws.rs.core.Application class. The configuration of the application's path is achieved with the javax.ws.rs.ApplicationPath annotation. The annotation takes a String that represents the context path root of the application's resources. Annotating the class with @ApplicationPath("/weather") tells the JAX-RS implementation to expose all resources under the /weather base context path. The slash in the path is optional; its absence is automatically resolved:

package com.packtpub.microservices.weather;

import javax.ws.rs.ApplicationPath;
import javax.ws.rs.core.Application;

/**
* Configuration of Weather Service's REST API's context path.
*/
@ApplicationPath("/weather")
public class WeatherMicroService extends Application {
}

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
52.15.80.101