1   /**
2    * Copyright (c) 2000-2009 Liferay, Inc. All rights reserved.
3    *
4    * Permission is hereby granted, free of charge, to any person obtaining a copy
5    * of this software and associated documentation files (the "Software"), to deal
6    * in the Software without restriction, including without limitation the rights
7    * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8    * copies of the Software, and to permit persons to whom the Software is
9    * furnished to do so, subject to the following conditions:
10   *
11   * The above copyright notice and this permission notice shall be included in
12   * all copies or substantial portions of the Software.
13   *
14   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20   * SOFTWARE.
21   */
22  
23  package com.liferay.portal.monitoring.jmx;
24  
25  import com.liferay.portal.kernel.util.ArrayUtil;
26  import com.liferay.portal.monitoring.MonitoringException;
27  import com.liferay.portal.monitoring.statistics.portlet.PortletSummaryStatistics;
28  import com.liferay.portal.monitoring.statistics.portlet.ServerStatistics;
29  
30  import java.util.Set;
31  
32  /**
33   * <a href="PortletManager.java.html"><b><i>View Source</i></b></a>
34   *
35   * @author Michael C. Han
36   * @author Brian Wing Shun Chan
37   */
38  public class PortletManager implements PortletManagerMBean {
39  
40      public PortletManager(
41          ServerStatistics serverStatistics,
42          PortletSummaryStatistics portletSummaryStatistics) {
43  
44          _serverStatistics = serverStatistics;
45          _portletSummaryStatistics = portletSummaryStatistics;
46      }
47  
48      public long getAverageTime() throws MonitoringException {
49          return _portletSummaryStatistics.getAverageTime();
50      }
51  
52      public long getAverageTimeByCompany(long companyId)
53          throws MonitoringException {
54  
55          return _portletSummaryStatistics.getAverageTimeByCompany(companyId);
56      }
57  
58      public long getAverageTimeByCompany(String webId)
59          throws MonitoringException {
60  
61          return _portletSummaryStatistics.getAverageTimeByCompany(webId);
62      }
63  
64      public long getAverageTimeByPortlet(String portletId)
65          throws MonitoringException {
66  
67          return _portletSummaryStatistics.getAverageTimeByPortlet(portletId);
68      }
69  
70      public long getAverageTimeByPortlet(String portletId, long companyId)
71          throws MonitoringException {
72  
73          return _portletSummaryStatistics.getAverageTimeByPortlet(
74              portletId, companyId);
75      }
76  
77      public long getAverageTimeByPortlet(String portletId, String webId)
78          throws MonitoringException {
79  
80          return _portletSummaryStatistics.getAverageTimeByPortlet(
81              portletId, webId);
82      }
83  
84      public long[] getCompanyIds() {
85          Set<Long> companyIds = _serverStatistics.getCompanyIds();
86  
87          return ArrayUtil.toArray(
88              companyIds.toArray(new Long[companyIds.size()]));
89      }
90  
91      public long getErrorCount() throws MonitoringException {
92          return _portletSummaryStatistics.getErrorCount();
93      }
94  
95      public long getErrorCountByCompany(long companyId)
96          throws MonitoringException {
97  
98          return _portletSummaryStatistics.getErrorCountByCompany(companyId);
99      }
100 
101     public long getErrorCountByCompany(String webId)
102         throws MonitoringException {
103 
104         return _portletSummaryStatistics.getErrorCountByCompany(webId);
105     }
106 
107     public long getErrorCountByPortlet(String portletId)
108         throws MonitoringException {
109 
110         return _portletSummaryStatistics.getErrorCountByPortlet(portletId);
111     }
112 
113     public long getErrorCountByPortlet(String portletId, long companyId)
114         throws MonitoringException {
115 
116         return _portletSummaryStatistics.getErrorCountByPortlet(
117             portletId, companyId);
118     }
119 
120     public long getErrorCountByPortlet(String portletId, String webId)
121         throws MonitoringException {
122 
123         return _portletSummaryStatistics.getErrorCountByPortlet(
124             portletId, webId);
125     }
126 
127     public long getMaxTime() throws MonitoringException {
128         return _portletSummaryStatistics.getMaxTime();
129     }
130 
131     public long getMaxTimeByCompany(long companyId) throws MonitoringException {
132         return _portletSummaryStatistics.getMaxTimeByCompany(companyId);
133     }
134 
135     public long getMaxTimeByCompany(String webId) throws MonitoringException {
136         return _portletSummaryStatistics.getMaxTimeByCompany(webId);
137     }
138 
139     public long getMaxTimeByPortlet(String portletId)
140         throws MonitoringException {
141 
142         return _portletSummaryStatistics.getMaxTimeByPortlet(portletId);
143     }
144 
145     public long getMaxTimeByPortlet(String portletId, long companyId)
146         throws MonitoringException {
147 
148         return _portletSummaryStatistics.getMaxTimeByPortlet(
149             portletId, companyId);
150     }
151 
152     public long getMaxTimeByPortlet(String portletId, String webId)
153         throws MonitoringException {
154 
155         return _portletSummaryStatistics.getMaxTimeByPortlet(portletId, webId);
156     }
157 
158     public long getMinTime() throws MonitoringException {
159         return _portletSummaryStatistics.getMinTime();
160     }
161 
162     public long getMinTimeByCompany(long companyId) throws MonitoringException {
163         return _portletSummaryStatistics.getMinTimeByCompany(companyId);
164     }
165 
166     public long getMinTimeByCompany(String webId) throws MonitoringException {
167         return _portletSummaryStatistics.getMinTimeByCompany(webId);
168     }
169 
170     public long getMinTimeByPortlet(String portletId)
171         throws MonitoringException {
172 
173         return _portletSummaryStatistics.getMinTimeByPortlet(portletId);
174     }
175 
176     public long getMinTimeByPortlet(String portletId, long companyId)
177         throws MonitoringException {
178 
179         return _portletSummaryStatistics.getMinTimeByPortlet(
180             portletId, companyId);
181     }
182 
183     public long getMinTimeByPortlet(String portletId, String webId)
184         throws MonitoringException {
185 
186         return _portletSummaryStatistics.getMinTimeByPortlet(portletId, webId);
187     }
188 
189     public String[] getPortletIds() {
190         Set<String> portletIds = _serverStatistics.getPortletIds();
191 
192         return portletIds.toArray(new String[portletIds.size()]);
193     }
194 
195     public long getRequestCount() throws MonitoringException {
196         return _portletSummaryStatistics.getRequestCount();
197     }
198 
199     public long getRequestCountByCompany(long companyId)
200         throws MonitoringException {
201 
202         return _portletSummaryStatistics.getRequestCountByCompany(companyId);
203     }
204 
205     public long getRequestCountByCompany(String webId)
206         throws MonitoringException {
207 
208         return _portletSummaryStatistics.getRequestCountByCompany(webId);
209     }
210 
211     public long getRequestCountByPortlet(String portletId)
212         throws MonitoringException {
213 
214         return _portletSummaryStatistics.getRequestCountByPortlet(portletId);
215     }
216 
217     public long getRequestCountByPortlet(String portletId, long companyId)
218         throws MonitoringException {
219 
220         return _portletSummaryStatistics.getRequestCountByPortlet(
221             portletId, companyId);
222     }
223 
224     public long getRequestCountByPortlet(String portletId, String webId)
225         throws MonitoringException {
226 
227         return _portletSummaryStatistics.getRequestCountByPortlet(
228             portletId, webId);
229     }
230 
231     public long getSuccessCount() throws MonitoringException {
232         return _portletSummaryStatistics.getSuccessCount();
233     }
234 
235     public long getSuccessCountByCompany(long companyId)
236         throws MonitoringException {
237 
238         return _portletSummaryStatistics.getSuccessCountByCompany(companyId);
239     }
240 
241     public long getSuccessCountByCompany(String webId)
242         throws MonitoringException {
243 
244         return _portletSummaryStatistics.getSuccessCountByCompany(webId);
245     }
246 
247     public long getSuccessCountByPortlet(String portletId)
248         throws MonitoringException {
249 
250         return _portletSummaryStatistics.getSuccessCountByPortlet(portletId);
251     }
252 
253     public long getSuccessCountByPortlet(String portletId, long companyId)
254         throws MonitoringException {
255 
256         return _portletSummaryStatistics.getSuccessCountByPortlet(
257             portletId, companyId);
258     }
259 
260     public long getSuccessCountByPortlet(String portletId, String webId)
261         throws MonitoringException {
262 
263         return _portletSummaryStatistics.getSuccessCountByPortlet(
264             portletId, webId);
265     }
266 
267     public long getTimeoutCount() throws MonitoringException {
268         return _portletSummaryStatistics.getTimeoutCount();
269     }
270 
271     public long getTimeoutCountByCompany(long companyId)
272         throws MonitoringException {
273 
274         return _portletSummaryStatistics.getTimeoutCountByCompany(companyId);
275     }
276 
277     public long getTimeoutCountByCompany(String webId)
278         throws MonitoringException {
279 
280         return _portletSummaryStatistics.getTimeoutCountByCompany(webId);
281     }
282 
283     public long getTimeoutCountByPortlet(String portletId)
284         throws MonitoringException {
285 
286         return _portletSummaryStatistics.getTimeoutCountByPortlet(portletId);
287     }
288 
289     public long getTimeoutCountByPortlet(String portletId, long companyId)
290         throws MonitoringException {
291 
292         return _portletSummaryStatistics.getTimeoutCountByPortlet(
293             portletId, companyId);
294     }
295 
296     public long getTimeoutCountByPortlet(String portletId, String webId)
297         throws MonitoringException {
298 
299         return _portletSummaryStatistics.getTimeoutCountByPortlet(
300             portletId, webId);
301     }
302 
303     public String[] getWebIds() {
304         Set<String> webIds = _serverStatistics.getWebIds();
305 
306         return webIds.toArray(new String[webIds.size()]);
307     }
308 
309     public void reset() {
310         _serverStatistics.reset();
311     }
312 
313     public void reset(long companyId) {
314         _serverStatistics.reset(companyId);
315     }
316 
317     public void reset(String webId) {
318         _serverStatistics.reset(webId);
319     }
320 
321     private PortletSummaryStatistics _portletSummaryStatistics;
322     private ServerStatistics _serverStatistics;
323 
324 }