View Javadoc
1   /*
2    * Licensed under the GPL License. You may not use this file except in compliance with the License.
3    * You may obtain a copy of the License at
4    *
5    *   https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
6    *
7    * THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
8    * WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
9    * PURPOSE.
10   */
11  package psiprobe.controllers.system;
12  
13  import javax.inject.Inject;
14  import javax.servlet.http.HttpServletRequest;
15  import javax.servlet.http.HttpServletResponse;
16  
17  import org.springframework.web.servlet.ModelAndView;
18  import org.springframework.web.servlet.mvc.ParameterizableViewController;
19  
20  import psiprobe.beans.JvmMemoryInfoAccessorBean;
21  
22  /**
23   * The Class BaseMemoryStatsController.
24   */
25  public class BaseMemoryStatsController extends ParameterizableViewController {
26  
27    /** The jvm memory info accessor bean. */
28    @Inject
29    private JvmMemoryInfoAccessorBean jvmMemoryInfoAccessorBean;
30  
31    /** The collection period. */
32    private long collectionPeriod;
33  
34    /**
35     * Gets the jvm memory info accessor bean.
36     *
37     * @return the jvm memory info accessor bean
38     */
39    public JvmMemoryInfoAccessorBean getJvmMemoryInfoAccessorBean() {
40      return jvmMemoryInfoAccessorBean;
41    }
42  
43    /**
44     * Sets the jvm memory info accessor bean.
45     *
46     * @param jvmMemoryInfoAccessorBean the new jvm memory info accessor bean
47     */
48    public void setJvmMemoryInfoAccessorBean(JvmMemoryInfoAccessorBean jvmMemoryInfoAccessorBean) {
49      this.jvmMemoryInfoAccessorBean = jvmMemoryInfoAccessorBean;
50    }
51  
52    /**
53     * Gets the collection period.
54     *
55     * @return the collection period
56     */
57    public long getCollectionPeriod() {
58      return collectionPeriod;
59    }
60  
61    /**
62     * Sets the collection period.
63     *
64     * @param collectionPeriod the new collection period
65     */
66    public void setCollectionPeriod(long collectionPeriod) {
67      this.collectionPeriod = collectionPeriod;
68    }
69  
70    @Override
71    protected ModelAndView handleRequestInternal(HttpServletRequest request,
72        HttpServletResponse response) throws Exception {
73  
74      ModelAndView mv = new ModelAndView(getViewName());
75      mv.addObject("pools", getJvmMemoryInfoAccessorBean().getPools());
76      mv.addObject("collectionPeriod", getCollectionPeriod());
77      return mv;
78    }
79  
80  }