Java Magazine, Jan/Feb 2018
ORACLE COM JAVAMAGAZINE JANUARY FEBRUARY 2018 23 reactive programming @ GET @ Path city @ Produces MediaType APPLICATION_ JSON public Response getAverageTemperature @ PathParam city String cityName Temperature temperature new Temperature temperature setTemperature double new Random nextInt 20 30 temperature setScale Celsius try Thread sleep 500 catch InterruptedException ignored return Response ok temperature build I will first show the implementation for the synchronous ForecastResource shown in Listing 9 which first fetches all locations Then for each location it invokes the temperature service to retrieve the Celsius value Listing 9 @ Path forecast public class ForecastResource @ Uri location private WebTarget locationTarget @ Uri temperature city
You must have JavaScript enabled to view digital editions.