1
2
3
4
5
6
7
8
9
10
11 package psiprobe.controllers.connectors;
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.Connector;
27 import psiprobe.model.RequestProcessor;
28 import psiprobe.tools.TimeExpression;
29
30
31
32
33 @Controller
34 public class ListConnectorsController extends AbstractTomcatContainerController {
35
36
37 @Inject
38 private ContainerListenerBean containerListenerBean;
39
40
41 private boolean includeRequestProcessors;
42
43
44 private long collectionPeriod;
45
46
47
48
49
50
51 public ContainerListenerBean getContainerListenerBean() {
52 return containerListenerBean;
53 }
54
55
56
57
58
59
60 public void setContainerListenerBean(ContainerListenerBean containerListenerBean) {
61 this.containerListenerBean = containerListenerBean;
62 }
63
64
65
66
67
68
69 public long getCollectionPeriod() {
70 return collectionPeriod;
71 }
72
73
74
75
76
77
78 public void setCollectionPeriod(long collectionPeriod) {
79 this.collectionPeriod = collectionPeriod;
80 }
81
82
83
84
85
86
87 @Value("${psiprobe.beans.stats.collectors.connector.period}")
88 public void setCollectionPeriod(String collectionPeriod) {
89 this.collectionPeriod = TimeExpression.inSeconds(collectionPeriod);
90 }
91
92
93
94
95
96
97 public boolean isIncludeRequestProcessors() {
98 return includeRequestProcessors;
99 }
100
101
102
103
104
105
106 @Value("true")
107 public void setIncludeRequestProcessors(boolean includeRequestProcessors) {
108 this.includeRequestProcessors = includeRequestProcessors;
109 }
110
111 @RequestMapping(path = "/connectors.htm")
112 @Override
113 public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response)
114 throws Exception {
115 return super.handleRequest(request, response);
116 }
117
118 @Override
119 protected ModelAndView handleRequestInternal(HttpServletRequest request,
120 HttpServletResponse response) throws Exception {
121
122 boolean workerThreadNameSupported = false;
123 List<Connector> connectors = containerListenerBean.getConnectors(includeRequestProcessors);
124
125 if (!connectors.isEmpty()) {
126 List<RequestProcessor> reqProcs = connectors.get(0).getRequestProcessors();
127 if (!reqProcs.isEmpty()) {
128 RequestProcessor reqProc = reqProcs.get(0);
129 workerThreadNameSupported = reqProc.isWorkerThreadNameSupported();
130 }
131 }
132
133 return new ModelAndView(getViewName()).addObject("connectors", connectors)
134 .addObject("workerThreadNameSupported", workerThreadNameSupported)
135 .addObject("collectionPeriod", getCollectionPeriod());
136 }
137
138 @Value("connectors")
139 @Override
140 public void setViewName(String viewName) {
141 super.setViewName(viewName);
142 }
143
144 }