1 4 package demo.jmx.web; 5 6 import demo.jmx.ICounter; 7 import demo.jmx.IHistory; 8 import java.util.HashMap ; 9 import java.util.Map ; 10 import javax.servlet.http.HttpServletRequest ; 11 import javax.servlet.http.HttpServletResponse ; 12 import org.springframework.web.servlet.ModelAndView; 13 import org.springframework.web.servlet.mvc.multiaction.MultiActionController; 14 15 18 public class CounterFormController 19 extends MultiActionController 20 { 21 private transient ICounter localCounter; 22 private transient IHistory localHistory; 23 private transient ICounter clusteredCounter; 24 private transient IHistory clusteredHistory; 25 26 public void setLocalCounter(ICounter counter) 27 { 28 this.localCounter = counter; 29 } 30 31 public void setLocalHistory(IHistory history) 32 { 33 this.localHistory = history; 34 } 35 36 public void setClusteredCounter(ICounter clusteredCounter) 37 { 38 this.clusteredCounter = clusteredCounter; 39 } 40 41 public void setClusteredHistory(IHistory clusteredHistory) 42 { 43 this.clusteredHistory = clusteredHistory; 44 } 45 46 49 public ModelAndView handleRefresh(HttpServletRequest request, HttpServletResponse response) 50 throws Exception 51 { 52 Map model = new HashMap (); 53 model.put("localCounter", new Integer (localCounter.getCurrent())); 54 model.put("localHistory", localHistory.getHistory()); 55 model.put("clusteredCounter", new Integer (clusteredCounter.getCurrent())); 56 model.put("clusteredHistory", clusteredHistory.getHistory()); 57 return new ModelAndView("index", model); 58 } 59 60 63 public ModelAndView incrementLocal(HttpServletRequest request, HttpServletResponse response) 64 throws Exception 65 { 66 localCounter.next(); 67 return new ModelAndView("redirect:index.jsp", null); 68 } 69 70 public ModelAndView incrementClustered(HttpServletRequest request, HttpServletResponse response) 71 throws Exception 72 { 73 clusteredCounter.next(); 74 return new ModelAndView("redirect:index.jsp", null); 75 } 76 } 77 | Popular Tags |