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.cluster;
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  
19  import psiprobe.TomcatContainer;
20  import psiprobe.beans.ClusterWrapperBean;
21  import psiprobe.controllers.AbstractTomcatContainerController;
22  import psiprobe.model.jmx.Cluster;
23  
24  /**
25   * The Class BaseClusterStatsController.
26   */
27  public class BaseClusterStatsController extends AbstractTomcatContainerController {
28  
29    /** The cluster wrapper. */
30    @Inject
31    private ClusterWrapperBean clusterWrapper;
32  
33    /** The load members. */
34    private boolean loadMembers = true;
35  
36    /** The collection period. */
37    private long collectionPeriod;
38  
39    /**
40     * Gets the cluster wrapper.
41     *
42     * @return the cluster wrapper
43     */
44    public ClusterWrapperBean getClusterWrapper() {
45      return clusterWrapper;
46    }
47  
48    /**
49     * Sets the cluster wrapper.
50     *
51     * @param clusterWrapper the new cluster wrapper
52     */
53    public void setClusterWrapper(ClusterWrapperBean clusterWrapper) {
54      this.clusterWrapper = clusterWrapper;
55    }
56  
57    /**
58     * Checks if is load members.
59     *
60     * @return true, if is load members
61     */
62    public boolean isLoadMembers() {
63      return loadMembers;
64    }
65  
66    /**
67     * Sets the load members.
68     *
69     * @param loadMembers the new load members
70     */
71    public void setLoadMembers(boolean loadMembers) {
72      this.loadMembers = loadMembers;
73    }
74  
75    /**
76     * Gets the collection period.
77     *
78     * @return the collection period
79     */
80    public long getCollectionPeriod() {
81      return collectionPeriod;
82    }
83  
84    /**
85     * Sets the collection period.
86     *
87     * @param collectionPeriod the new collection period
88     */
89    public void setCollectionPeriod(long collectionPeriod) {
90      this.collectionPeriod = collectionPeriod;
91    }
92  
93    @Override
94    protected ModelAndView handleRequestInternal(HttpServletRequest request,
95        HttpServletResponse response) throws Exception {
96  
97      TomcatContainer container = getContainerWrapper().getTomcatContainer();
98      Cluster cluster = getClusterWrapper().getCluster(container.getName(), container.getHostName(),
99          isLoadMembers());
100     return new ModelAndView(getViewName()).addObject("cluster", cluster)
101         .addObject("collectionPeriod", getCollectionPeriod());
102   }
103 
104 }