View Javadoc

1   package ch.busyboxes.agoo.controller;
2   
3   import org.apache.log4j.Logger;
4   import org.springframework.beans.factory.annotation.Autowired;
5   import org.springframework.stereotype.Controller;
6   import org.springframework.ui.ModelMap;
7   import org.springframework.web.bind.annotation.RequestMapping;
8   import org.springframework.web.bind.annotation.RequestMethod;
9   
10  import ch.busyboxes.agoo.service.WatchedFileService;
11  
12  /**
13   * This class represents the controller of the index page
14   * 
15   * @author julien@busyboxes.ch
16   */
17  @Controller
18  @RequestMapping("/agoo.html")
19  public class IndexController {
20  	
21  	/** Logger for this class */
22  	private Logger logger = Logger.getLogger(IndexController.class);
23  	
24  	/** The watched file service */
25  	private WatchedFileService watchedFileService;
26  	
27  	/**
28  	 * Default constructor
29  	 */
30  	public IndexController() {
31  		logger.info("Index controller initiated");
32  	}
33  	
34  	/**
35  	 * This method responds to a GET request on the index page
36  	 * 
37  	 * @param model the model for the page
38  	 */
39  	@RequestMapping(method = RequestMethod.GET)
40  	public void indexPage(ModelMap model) {
41  		
42  		// Getting number of files watched
43  		long numberOfFilesWatched = watchedFileService.getNumberOfFilesWatched();
44  		
45  		// Passing values to the view
46  		model.addAttribute("numberFiles", numberOfFilesWatched);
47  	}
48  
49  	/**
50  	 * Sets the watched file service
51  	 * 
52  	 * @param watchedFileService the watched file service
53  	 */
54  	@Autowired
55  	public void setWatchedFileService(WatchedFileService watchedFileService) {
56  		this.watchedFileService = watchedFileService;
57  	}
58  
59  }