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.threads;
12  
13  import jakarta.inject.Inject;
14  import jakarta.servlet.http.HttpServletRequest;
15  import jakarta.servlet.http.HttpServletResponse;
16  
17  import java.util.List;
18  
19  import org.springframework.beans.factory.annotation.Value;
20  import org.springframework.stereotype.Controller;
21  import org.springframework.web.bind.annotation.RequestMapping;
22  import org.springframework.web.servlet.ModelAndView;
23  
24  import psiprobe.beans.ContainerListenerBean;
25  import psiprobe.controllers.AbstractTomcatContainerController;
26  import psiprobe.model.ThreadPool;
27  
28  /**
29   * Creates the list of http connection thread pools.
30   */
31  @Controller
32  public class ListThreadPoolsController extends AbstractTomcatContainerController {
33  
34    /** The container listener bean. */
35    @Inject
36    private ContainerListenerBean containerListenerBean;
37  
38    /**
39     * Gets the container listener bean.
40     *
41     * @return the container listener bean
42     */
43    public ContainerListenerBean getContainerListenerBean() {
44      return containerListenerBean;
45    }
46  
47    /**
48     * Sets the container listener bean.
49     *
50     * @param containerListenerBean the new container listener bean
51     */
52    public void setContainerListenerBean(ContainerListenerBean containerListenerBean) {
53      this.containerListenerBean = containerListenerBean;
54    }
55  
56    @RequestMapping(path = "/threadpools.htm")
57    @Override
58    public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response)
59        throws Exception {
60      return super.handleRequest(request, response);
61    }
62  
63    @Override
64    public ModelAndView handleRequestInternal(HttpServletRequest request,
65        HttpServletResponse response) throws Exception {
66  
67      List<ThreadPool> pools = containerListenerBean.getThreadPools();
68      return new ModelAndView(getViewName()).addObject("pools", pools);
69    }
70  
71    @Value("threadpools")
72    @Override
73    public void setViewName(String viewName) {
74      super.setViewName(viewName);
75    }
76  
77  }