View Javadoc

1   /**
2    * Copyright 2011-2012 The Kuali Foundation Licensed under the
3    * Educational Community License, Version 2.0 (the "License"); you may
4    * not use this file except in compliance with the License. You may
5    * obtain a copy of the License at
6    *
7    * http://www.osedu.org/licenses/ECL-2.0
8    *
9    * Unless required by applicable law or agreed to in writing,
10   * software distributed under the License is distributed on an "AS IS"
11   * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
12   * or implied. See the License for the specific language governing
13   * permissions and limitations under the License.
14   */
15  
16  package org.kuali.mobility.weather.service;
17  
18  import javax.ws.rs.GET;
19  import javax.ws.rs.Path;
20  
21  import org.kuali.mobility.weather.dao.WeatherDao;
22  import org.kuali.mobility.weather.entity.Weather;
23  
24  public class WeatherServiceImpl implements WeatherService {
25  	
26  	private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(WeatherServiceImpl.class);
27  	
28  	private WeatherDao weatherDao;
29      
30      private Weather weatherData;
31      
32      @GET
33      @Path("/getWeatherForecast")
34      @Override
35  	public Weather getWeatherForecast() {
36  		if (weatherData == null) {
37  			weatherData = weatherDao.parseWeather();
38  		}
39  		return weatherData;
40  	}	
41  	
42  	public void refreshWeather() {
43  		LOG.info("Refreshing weather cache...");
44  		Weather cache = weatherDao.parseWeather();
45  		setWeatherData(cache);
46  		LOG.info("Finished refreshing weather cache.");
47  	}
48  
49  	public Weather getWeatherData() {
50  		return weatherData;
51  	}
52  
53  	public void setWeatherData(Weather weatherData) {
54  		this.weatherData = weatherData;
55  	}
56  	
57      public WeatherDao getWeatherDao() {
58  		return weatherDao;
59  	}
60  
61  	public void setWeatherDao(WeatherDao weatherDao) {
62  		this.weatherDao = weatherDao;
63  	}
64  	
65  }
66  
67